Platformer Game




Death Animations




Death Code/Defining Death




Adding animation to a sprites death is a good way to add a little flavor to the experience of failing! It's also good for practing adding more animations and methods to trigger them. Obviously here we need to make sure our player has died first and also that he wasn't already dead.


This block of code starts with just that. After it makes sure the player has died it then runs it through the dying method which runs the death sprites. The gamestate is changed the moment the player dies and we even run a short sound clip as the player dies and another as the gameover sound.













After the player dies the endscreen is engaged when the Gamestate changes and we are given a nice little menu that asks us to try again or rage quit. The nice look of the image changing once the image is hovered over is quite a task to get going, but once you wrote the code out once and get it functioning you can copy it later.


The code on the bottom right draws the menu frame and places both the replay and menu buttons into the menu frame. The 0 at the end of the section that says "play" under "creatButtons" represents the first row of urm buttons and the 2 at the end of the "menu" section respresents the 3rd line.


The "createImg" Section loads the urm buttons into the Death Screen menu.