Health and Special Abilities

http://www.youtube.com/watch?v=-lMDTY9ndBw

Heap (health) and Stack (special ability) added.  High jump is the first special ability.

Health

Added a health variable in the player class, which keeps represents how much life the player has until dying.  I also added a max health variable, which will be useful for energy pickups, since the player should not be able to infinitely increase their health.  The max health will also be used for resetting the player after death or starting a new level.  The max health is an instance variable and not a constant, just in case I want to increase the player’s maximum health through an upgrade or level system.  For now, to go along with the computer theme I am calling health “Heap”.

In the Player class, I added a method to detect collision between the player and all of the enemies on the screen.  If the player collides with an enemy, then the health is reduced by 20.  Since the player may collide with the enemy for multiple frames, I added another variable which is a counter for invincibility.  The player stays invincible for 60 frames.  At that time, I draw the character with a 50% transparency which signifies that the player is invincible.  If the player’s health is equal to or below zero, then the player’s alive variable gets set to false, which removes the character from the screen and displays the message “You Died”.

Special Abilities

Additionally, I added variables for special ability and the maximum amount of special ability.  This works in a similar way to MP (magic points) in an RPG.  Using an ability will decrease the amount of special ability left.  For now, I just have one special ability which is a high jump.  The player starts out with 50 points of special ability.  The special ability can be activated/deactivated by pressing the B button.  When active, the player will jump six blocks high instead of the regular three.  Each time the player jumps with the ability active, the special meter will reduce by 10.  This will allow the player to jump over obstacles which can’t be jumped over using the regular jump.  To go along with the computer theme, I am calling the special ability points “Stack”.

Other

The bounds for the scroll seemed to be too close to the edges of the screen, so I increased the bounds values to 400.  This way, the player has a better chance of seeing enemies coming from off screen.  I did notice that sometimes the player will not be correctly moved to the next map now.  This could be due to me changing the bounds, which is something I will have to double check.

Levels

http://www.youtube.com/watch?v=sH-Juho6Kqs

Now with doors and level changes.

The latest build now contains many more improvements.  I created a Door object, which represents a door which will take the player another level.  An array of Doors is contained in the Map object, but I doubt I’ll ever have more than one door on a map.  However, I may have multiple doors in a level, and each door will take the player to a different level.  A World class has also been created to keep track of all the levels and the current level.

 

A method to determine if all of the enemies in a level have been defeated has also been added.  When the level is cleared of enemies, the message “DEFRAGMENTATION COMPLETE” is displayed.  At this time, all doors in the level will be unlocked.  For now, this is visually represented by the door changing from red to black.  At that time, if the player collides with the door then they will be taken to the next level as determined by the World object.

On the player class, I added a method which translates the player’s screen coordinates to the room coordinates, since calculating that value each time when needed became confusing.

In the enemy class, the binary code for each enemy is now randomly generated.  At first, I was getting the same binary code for each enemy, since the Random object was declared as an instance variable for each enemy.  To get random codes for each enemy, I had to make the Random object static so it is shared between all of the instances.

One problem that I need to fix is when the player shoots and moves across the room boundary.  In that case, the projectile isn’t associated to a room, so warps over to the next room.  Additionally, I need to work out the issue with the bock collision when moving across a room boundary, which usually pushes the player back a noticeable amount.

Name Change

I did some web searches, and found there is already an academic game called Binary Blaster.  I’m not sure if that is an official trademark or registered copyright, but I don’t want a legal fight so I am going to change the name since it is still early.  Now the working title is Blasting Bits, which was the heading from my previous post.  Binary Blaster is catchy, but people could also confuse it with a game called Blaster already on XBLIG.  Also, it may be a little too similar to Blaster Master for the NES.  I also like the word Blasting in the title, because it is more of an active verb which makes it seem more exciting.