Level Editor

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

Basic level editor created which currently supports one room.

ResistorKit Update

Updated ResistorKit so that it sets the next screen value to -1 by default instead of 0, which was a valid next screen state.  Created simple title screen, and added code to handle switch to the game screen.  This time I am using a List of Screens, instead of having each Screen declared as an instance variable in the main game class.  That way I am able to reference the next Screen as an index to the Screen list, instead of having a mess of if/then statements.  Added bounds checking for the screen array, just to ensure that the game doesn’t crash if the getNextScreen method returns a value higher than the Screen array size.

Level Editor

Created a simple graphical 2D array editor, which allows blocks to be placed in the array.  These will be used as the blocks of the game room.  Set the action button to save the current array.  Added a method to return the currently created level, or null if no level has been created.  When the player selects to start the game, then the main game loop checks to see if the world created by the level editor is not null.

Reworked a lot of the World, Level, and Map code so that it accepts those values as parameters.  This allows those to be created in the level editor, and then passed as a parameter to the GameScreen object, which holds a reference to the game world data object.  Added quite a few null checks, since initially the level or map may be null if no level has been created by the level editor.  Set the action button as the save button in the game level editor.

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.