Story Added

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

Attract screens included and parallax background added.

Story

Created a simple story about having to save the world from cyber terrorists who have hacked the global network.  Created an attract screen which cycles through the four story screens that I have created.  Created some really simple graphics in Gimp, which I hope to improve later.

Updated the title screen with a simple title logo that I created with Gimp.  Added logic to the title screen to use the user created world if it exists, or generate the default world if no user created world exists.

Parallax

Added a simple scrolling background to the level.  For now, I just used one of the images that I created for Resistor.  Added a parallax effect by offsetting the background image by the room offset divided by two.  That means the background is scrolling at half speed of the room.  When creating the background image, the grid option in Gimp really helped with placing the background images, which were placed over a blue to black gradient.  I could have set my background image as a pattern and used bucket fill, but that would have been more effort than needed.  My Gimp toolbox kept disappearing for some reason, and getting it to show again with the tool options was really a hassle.  Once I got the background image added to the game, there was a noticeable jump that occurs when the player crosses rooms, which will need to be fixed later.  I’m thinking about copying all of the room data to one huge array, which would solve a lot of problems like that.

Gameplay Changes

Added a check in the draw method of the game screen to determine if the player is facing right.  If so, then the player sprite is flipped horizontally.  This throws off the baked-in lighting, but it is good enough for now.

Modified the player’s jump speed to 10 (pixels per frame) instead of 5, which makes the jumps feel less floaty.  Still need to add some calculations to make jumps more parabolic and less linear.

Realized that the player’s health wasn’t getting re-initialized after dying and starting a new game.  I went ahead and created a newGame method in the game screen class which handles things like that.

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.