Health Sockets

Added four new body sockets tonight, which increases the player’s health.  Actually, I just had to write the health socket code once and just change the variable that controls the health bonus magnitude.  The player can choose from Health +1, Health + 2, Health + 3, and Health + 4.  I modified the method in the player class that returns the player’s maximum health to account for these sockets if they are active.  Currently, the player can only socket one ability to the body.  I think it’s more important to get it working for one, and then later I can modify the sockets for each body part to a dynamically sized list.  I still haven’t decided if socket slots will be statically bound to each piece of equipment, or if additional slots  can be purchased from an in-game store.

The player’s base health is currently set to 200.  Each +1 health socket adds 40 additional health.  I will need to decide if the Health sockets will stack when multiple body sockets are available.  For instance, equipping a Health +1 and Health +2 socket would result in 120 additional health.  I will also need to handle the case where the player unequips a health socket, which would result in the player possibly having more health than the maximum.

I also modified the health meter display while I was working with the health code.  Now there are segmented bars for each 20 health.  Green bars are health remaining and gray bars are health lost.  I added a variable to the enemy class that indicates how much damage the enemy inflicts, which I now have set to 5.  Previously, I just subtracted a static 20 value from the player’s health when they collide with an enemy.  This way, when an enemy is subclassed, specific damage values can be assigned for the enemy subclass.  The reason I chose 5 for default was because it lets me see the fraction of a health bar left over when the player is hit.  This will need to be rebalanced later, because  40 hits (200/5) seems to be too generous.  Filling the full health bars is easily completed in a loop, but determining how much to fill the last bar which may only be a portion of a bar requires some additional calculations.  Basically, the value of  modulo current health of health unit size (20) is used to determine how much of the last bar should be displayed.

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.

Hand Full of Heads

Play online

Hand Full of Heads is a demo written using HTML5 and Canvas.  This application has heads that can be happy, sad, or angry.  Heads are happy if they are near other heads.  Heads become angry when they collide with other heads and begin moving at an accelerated pace.  Heads are sad when there are no other heads around and move at a slower pace.  Additional heads can be added by clicking anywhere on the hand.

Requires a web browser capable of rendering HTML5 and Canvas.

 

 

 

 

 

Released