Long post including artifact.

This post will be both my log of yesterday and today as well as my artifact post for this week so please excuse me if it’s a bit long.

First of all, the log. 

Tuesday i started by altering the interaction method slightly by making it run it’s own method including a relevant object and performing the necessary things depending on the object type.

I then started work on items for the game which is what I’ve been doing for most of these two days and will be my artifact so i’ll try not to go into too much detail yet. When making items i added some functionality to the HUD class so that it would show what item or items the player had picked up, i did this by adding a few bools to the player object and then having the HUD only draw the corresponding symbols if the corresponding bool was true.

Today i added some groundwork for doors, added an enum for them and a placeholder sprite. I intended to finish them once i was done with the items. Hard to think of anything else that didn’t involve items so i’ll get right to them.

Image

The first thing i did was to add a couple of enums in our GameObject class for the new items to be able to easily differentiate them, then i had the level draw them out in predetermined locations rather than from a picture for testing purposes. I used the same pictures as used in the Alpha HUD to make new sprites which is why the sprites only contain the top left corner and the baton looks like a huge blue glowy dildo. With that done i added checks in the new interact method to handle what to do depending on which of the items was picked up, based on the enum i mentioned earlier. For now the only items with an effect other than just setting the player’s bool for having picked up the item to true is the baton which also changes the player’s attack into covering a slightly larger area, which would be useful later. Now that i could pick up the items i needed them to disappear once picked up and through several hours of vectors getting out of range i managed to use an existing method in the gameobject manager (by adding a pointer to the manager in the player’s constructor) to clear out specific objects from the world, what had happened was that since the player is one of the earlier objects to be updated and the interact function is in the player’s update method the item picked up was being removed before the vector containing it was through with it’s own update method, this caused the loop to attempt to access an empty object and crashed the compiler. Once that was done however, i managed to pick up items properly.

Image

I decided to do the same for the guards and started trying to use the same function in the guard’s update method for reacting to being hit by a player. This was earlier just to set a bool to make the guard stop updating and move the guard 5000 pixels horizontally and vertically. In order to do this i spent several hours adding a pointer to the gameobject manager and the Level class(in order to access the list of objects) to everywhere a guard was created. In the end however we decided that it would be easier to just have each object have a bool for being removed from play or not, while this made the guards’ pointers redundant i still kept them in there in case they would come in useful later. I then added a bool in the gameobject class and added methods of reading and changing it from outside the class, then in every draw and update method for guards and items i added a check that exits the method if this bool is false. The result of this is of course that the item is no longer drawn out or updated but i also had to and a few more checks for this bool in other classes in order to not, for example pick up an removed item again after it had been removed.

After that i started adding functionality for having guards drop keycards when being killed by the player, for this is used the gameobject manager i added to the guards from earlier and i used the Sprite manager included in the Level class in order to create a new keycard with the right sprite. I added it to the Level’s list of gameobjects but aparently it didn’t work properly as while the player is able to make cards appear after killing a guard, the item could not be picked up by the player. Oliver suggested i made the pick up items their own class which i started on but then realized i had nothing to put in that class that was not shared by some other game object already so i abandoned that idea for now. I have good hopes of fixing this issue tomorrow as well as adding some functionality to doors.

Image