Freeze Gun

Added the first gun socket tonight, which is the freeze gun.  First of all, a freeze variable was added to the enemy.  I represented this as an integer, which is zero if the enemy is not frozen.  When the enemy is frozen, then that variable is set to the number of frames that the freeze will last.  On each enemy update, the freeze value is decremented if it is greater than zero.

I added a method that returns true if the frozen value is positive.  This is used in the GameScreen class to determine if the enemy should be drawn frozen.  For now, if an enemy is frozen then it is drawn with a blue shade.  In the EquippedSockets class, I created a method to flip the zero gun socket between None and Ice when the confirm button is pressed when the gun is selected.  I’m starting to think about removing the two gun (zero and one) concept from the game, because it may make the game too complex with the socket system.

The projectile class was also updated to include a boolean to indicate if the pellet has the ice attribute.  If the ice gun socket is equipped and the gun is shot, then the ice boolean for the projectile gets set to true.  I created a simple diamond shape in Gimp to represent the ice projectile.  I’ll work on the graphics later, but this will at least let me know if the ice projectile is correctly shooting.

I’m going to leave it at that tonight.  Sorry, no videos this time.  I think I’ll hold off on those until I have something a little more impressive to show.  The ice gun functions correctly and properly freezes enemies, but one change I may make is the ability to land on enemies that are frozen, so they can be used as stepping stones.  Currently, frozen enemies will still hurt the player.

Eight Way Shooting

http://www.youtube.com/watch?v=YTmCgEdq4Fw

Added eight way shooting to the game, so that the player can aim vertically as well as horizontally.  Pressing up will set a flag that keeps track if the player can shoot upward.  When looking upward, then the Y velocity is set to the projectile speed.  If the player is not walking, then the player should shoot directly up, so the projectile’s X velocity is set to zero.  If the player is walking, then the projectile will move diagonally up/left or up/right depending on which way the player is walking.  I don’t have graphics for the player lookup up or down yet, so for now it just displays “looking up” or “looking down” over the player’s head.  One feature I plan to add is making the player aim diagonally up or down when the left or right trigger is pressed.  However, that will require an update to ResistorKit to handle those inputs, as well as adding methods in the ResistorKit screen class.

I went back and modified the velocity for the up/right and up/left shots, since it will actually go slightly faster than the projectile moving directly vertically or directly horizontally.  Currently the projectile speed is set to 10, so that it moves 10 pixels each second.  When shooting diagonally, the projectile will actually move 14.142 pixels according to the Pythagorean theorem ( square root of (10 squared plus 10 squared) ).  To make the diagonal speed match, the values of the X and Y components can be found by dividing the projectile speed by 1.414 (or multiplying by 0.707) which is the square root of two.  This is because Sqrt(1^2 + 1^2) = Sqrt(1 + 1) = Sqrt(2).  Fortunately, finding the length of the two sides (projectile’s X and Y velocity) of the triangle from the hypotenuse just requires multiplying by a constant.  I believe this is because the two sides of the right (90 degree) angle are equal, but I don’t have any formal proof of this.  If I allowed precision aiming where the X velocity was not equal to the Y velocity, then more complex calculations would probably be needed.

The projectile collection class has been modified to handle more than one projectile using a List.  A projectile is removed from the projectile from the List whenever it is inactive.  The alive flag now indicates that the projectile is ready for removal from the collection.  This may be slightly inefficient, since it is allocating memory for a projectile each time one is shot.  I may revisit this later if there are performance issues.  One problem is that I couldn’t just simply increase a counter variable to loop through each element and delete it if it is inactive, since that will modify the structure of the List which could result skipping elements if not careful.  Therefore, I looped through the List in reverse starting at the List size minus one and going down to zero.  That way if I delete an element then it will not effect the iterator.

Similar to enemies, I added code to handle passing a projectile from one room to the next.  I removed the condition that if a projectile hits the room boundary, then it disappears.  One interesting side effect is that now the projectile will live forever if it does not collide with an enemy, so it will loop forever as long as it is in the player’s room or an adjacent room.  Therefore, I added a variable to track the lifetime of a projectile, which I currently have set to  60 frames.  This may be upgradeable in the future with a socket.

Finally, on each projectile update I now check to see if the projectile has collided with a block.  This uses the same collision method that I created in the map class to do the enemy collision.  If the projectile has collided, then I set the alive flag to false, which will mark it for removal from the projectile list.  I also added the player’s width to the starting position of a projectile when shooting right, that way it doesn’t look like the projectile is going through the player’s body.

Socket System

http://www.youtube.com/watch?v=fHCdj7LGueQ

Socket system allows special abilities to be assigned to equipment.

I decided to scrap the magic based system for a socket system instead.  Currently, I plan on having five socketable pieces of equipment, which are the helmet, zero gun, one gun, body armor, and boots.  For now, I only allow one socket for each piece of equipment, but I believe I will be able to expand that in the future in some cases.  Some abilities may conflict with others, so I will need to limit what combinations can be used.  A new socket equip screen has been added to allow the player to assign a socket for each piece of equipment.

The helmet sockets will enable visual items such as night vision (to see in dark places) and enemy information.  The zero gun and one gun sockets will modify how the guns work, such as modifying recoil rate and projectile trajectory.  The body armor socket will expand the player’s health and defense.  The boot sockets will modify the player’s jumping ability.  I may also add a hands socket, which will allow the player to hang and climb on walls.

The boot socket is the only one I currently have implemented.  The player can choose between four socketable abilities, which are Jump +1, Jump +2, Jump + 3, and Double Jump.  The three jump abilities will increase the player’s jump height.  The Double Jump ability will allow the player to jump again before touching the ground.