Platformer Game




Potions & Boxes










Adding potions requires 3 sets of sprite arrays to cycle through. Also addional code needs to be added to create the hovering animation of the potions along with the offsets. On top of that, we must add the method for creating the potion once a box or barrel is hit. Then we have to add the functoinality of increasing the players health after they pick up a health potion.


Simple things can actually take a lot of time and code to implement especially if a game engine isnt being used.









These lines of code load in all imgs needed to create the animations and display the objects in the game. The array lists are arrays of the sprites that are cycled through in that order to give the illusion of light reflecting off the tops of the potions.



The crate and Barrel have animation sets that are only triggered once their hitboxes intersect the players hit box and the player uses the left mouse button to attack. This is yet another process of code used to check that the hitboxes intersect and that the player has preformed an attack.




Even through these processes of putting a few hundread lines of code together to just add an image to a window and perhaps another few hundread to animate them seem tedious, the process will later payoff as it makes adding more and more objects and methods much easier and it will feel more and more rewarding as you build on top of the base you created.











Loading these objects into the game was done in an intresting way that took me some time to wrap my head around. We used a method of assigning color values to objects, but instead of just making one object one color we made all the objects one color.


In this instance we made our objects all blue and used the rgb color system to allow us to add a value to the color.


For us to add the objects into the game we used GIMP as a map editor and creater. By changing the Blue color value on the square we are picking which object we are placing.








If it is still a little confusing thats okay. Ive gone ahead and attempted to put togther some images from the game along with the code and level map with red boxes to help see how it is we can use the color value to place objects in the game. Now dont worry that the square looks green just pay attention to the alpha value in the red box.


Notice how the blue value says 0 and the Constant value for the red potion is 0. Then look at how the code for loading the objects says .getBlue. And notice that the red potion is the first in the line just like in the map editor. Hopfully seeing all these together and having what it is you need to know in boxes can help put together how it is Ive loaded these objects into the game.