Saturday, September 8, 2018

Added Life Counter, Health Bar, and Game Over Screen

I am still working out my understanding of fixed math variables and what not so that I can reprogram the cart/car collision so that I can create a difficulty option and implement power ups.  My original goal tonight was to work on the fixed math and variables, as well as the spawning of the cart.  I don't know if I did something by accident but it seemed like the cart movement was a bit wonky.  At times it pauses and at other times it seems to speed up if moving in the same direction as the player.  This wasn't too big of a deal for me since I need to rework that section anyway so instead I decided to add a little more to the game by way of a life counter, status bar, a "Game Over" screen, and some music.

The additions are as follows:


  • When a collision is detected between the player and the car a life is lost.
  • When a collision is detected between the cart and the car the status bar is incrementally decreased.
  • Currently, if all lives are lost or the status bar is depleted, game is over.
  • The game over screen was added by making another playfield with varied colors.  I also threw in some sound for fun.

I am still trying to determine if the loss of the status bar should equate to game over or a loss of life.

The purpose of the game over screen was an exercise. 

The game needed a logical conclusion but I also wanted to figure out how to change playfields.  This was a good way for me to practice coding that.  I also wanted to try flashing colors because when I eventually add power ups I want the pixels to be flashing so that they stand out in the playfield.  Same reason for adding music.  Since I had a variable for the flashing colors, I decided to use that same variable for the duration of the sounds and see how that would work.  I had originally tried programming a game over song (as well as a titlescreen song) but had a hard time getting it to work.  For some reason I could get the music to play but the playfield would not draw.  I assume I probably forgot a "drawscreen" command somewhere. 



1 comment:

  1. I am leaning more towards the status bar leads to a loss of life or maybe it reaching zero changes to another screen since there is also the possibility of game over from a score of zero, although I don't really want the game to be so difficult to result in such low scores...

    ReplyDelete

Manatee Madness!

Stage work is coming along nicely, with the foundations laid down for the Rain, Snow, and Volcano stage. The Black Friday stage is proving ...