Model Animation

http://www.youtube.com/watch?v=0qEkqUv6CRQ

New model created using keyframes which generates the animation images.  Now using a 20 frame walk cycle.  FPS meter drops slightly due to XSplit recording software.

Engine

Spent some time streamlining the game engine.  There were a few glitches when moving from one room to another, so almost all of those should be resolved now.  It can be really tricky detecting collision with a block in an adjacent map array, while keeping the map offset straight and moving the player to the next map at the appropriate time.  I was thinking that it may be easier to just keep a single array which holds the blocks of the current screen, and then copying the blocks from the room arrays to the current screen array.  However, I think the method I have now seems to work, but it is a little bit of a pain to keep track of which room the player, projectiles, and enemies are located, especially when they cross the room boundary.  When the projectiles and enemies cross the room boundary, they will need to be removed from their current room and added to the next room.

Modeling with Animation

I found another tutorial on YouTube for making a model with animation in Blender.  Well, the first 12 minutes are just making the armature, which I learned how to do last week.  Then it shows how to create the keyframes and animation, which is really easy once you know how to do it.  I think before I didn’t have the record button pressed, along with dragging the keyframe, which caused my first model attempt to not animate.  With those settings enabled, I was able to get my simple model to run.

Pressing the play button makes my model run.  There is another animation button which renders each frame, but it doesn’t display if or where the images for each frame are saved.  After some searching, I found the output directory hidden by scrolling to the bottom of the right pane.  I set that to my project directory in a folder named anim, and then pressed the animation button which generated a png for each frame.  The first set of files didn’t have transparency, so I had to go back and select the RGBA option next to the PNG option.  It actually just displays as a second RGB button, probably due to limited button space.

 

The next problem is that the image is way too big (960×540) and out of proportion to be used as a character sprite.  I did some searching on the Gimp forums and found that multiple files can be cropped and modified at once by using Open as Layers.  This way, I was able to crop, scale, and resize the image to 48×96 which is the size of two tiles in the game.

.

Now the problem is getting each layer back out as an image.  Unfortunately, I didn’t find any information on how to do this in Gimp.  I started by copying each layer and then pasting as a new image, and saving after each paste.  However, this got really old after doing it about 8 times out of 20 frames.

Did some searching a found a Python script that someone wrote to save all of the layers in an image to PNG.  This worked (after dealing with file extensions and figuring out where to put the plugin), but it saved the file with the .png extension, even though the layer name already has .png, which resulted in the files coming out at image.png.png.  I just had to modify one line to not add the .png extension to the end.

Now that I had the images, I imported all of them into my game project’s Content area.  It may be more efficient to make a sprite sheet, but I doubt it will make that much of a performance enhancement.  It’s something I can look into later.  I added all of the images to my texture array, and modified the walk animation of my character to use 20 frames instead of 3.

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.