Graphical and Music Assets

screen069

I took a break from engine programming, and I started working on some of the graphical and audio aspects of the game.  I would like to have a small playable demo in the near future.  For now I am just using royalty free assets, but I would like to go back later and make my own custom art and music.  The font I used is called Ethnocentric, which was downloaded from 1001freefonts.com.  Be careful to read the license agreement for any font downloaded form this site, because not all give you permission to use the font for sale in commercial works.  However, most fonts allow inclusion in commercial works as long as the font is not modified or sold as a part of a font compilation.  The title background texture was acquired from CGTextures.com, which allow use of their textures as long as those are not sold as a part of a texture compilation and it is not used in an open source project.  For the background music, I used two songs from Kevin MacLeod’s incompetech site.  Again, I would like to make my own music in the future, but for now I will use those pieces which only require attribution in the credits screen.

Again, writing good code to play music can be more difficult than it looks.  When going from the game to a menu, I would like the music to change.  However, I don’t want to game music to start all over again when going back to the game.  I could just have the game music play through the menu at a lower volume.  One idea I had was to create a Song variable in the ResistorKit screen class, since usually one only song is associated with each Screen type.  I would just need to have methods to modify it, so that the music could be changed for each game screen.  Additionally, it would be nice to have a way for the music to fade from one song to another when changing areas in the game world.

I reworked some of the screen handling code to add the new credits screen.  One problem is that the “QUIT” state did not have a corresponding screen, so I made a dummy quit screen so that the game states are aligned with the game screens.  I can probably also use the quit screen to display information as the game is closing, such as “thank you for playing” or information on how to buy if the game is running in trial mode.

On the title screen, I went ahead and implemented a scrolling background.  This seems to be a running theme in my games.  I set the scroll rate to 8 pixels per frame, so it scrolls really quickly.  I may need to slow it down if it makes people dizzy.

On the game screen, I went ahead and updated the bounding box display code so that when the instance variable that controls its display is set to true, then the bounding boxes for all game objects (player, enemies, collectibles, projectiles) are displayed.  I also updated the graphic for the player’s projectile, using a supernova effect that I created with Gimp but I’m still not happy with it.

Equipment Menu

screen066

In the player class, I added instance variables to hold the equipped helmet, chest piece, gloves, and boots.  These start out as null, but I added logic to automatically equip one of those items if the equipment slot for it is null when an item for that slot is collected.  I also decided to go ahead and make separate lists for each item type, which will make looping those those lists much easier for the menu.  The collection code was updated to handle these items in the same way that weapons are collected, which adds each piece of armor to the appropriate list.  A method to calculate the total defense was also added, which is the sum of the defense values for each armor equipped.

I recreated almost all of the equipment menu, so that it now handles armor.  Now, the player must select the weapon or armor to replace it.  When selecting a piece of equipment, it will display a selectable list with all of the items that can replace it.

The Weapon and Armor classes were updated to accept a new parameter in the constructor, which is the number of socket slots for each item.  The player will not be able to equip more sockets than this value.  Unfortunately, since the socket for each item is implemented as List, I can only add the socket to the end of the list.  This means that it works in a stack fashion.  I believe I can insert an item into a list at a specific index, but I can’t insert null into the list.  Null signifies that a socket location is empty.  Alternatively, I could implement the Socket list as an array, but that will limit the maximum number of socketable abilities.  Pressing the action (X) button will bring up the list of socket abilities that can be equipped for the currently selected item.  For now, any socket can be equipped into any item.  I already have constants defined for the body location of each socket ability, so I will just need to modify the code to only display the sockets for the selected body location.  All acquired socket abilities are currently stored in one list, but I may want to make separate lists of sockets for each body location to make generating the menus simpler.

I have updated the ResistorKit menu to accept a texture image as part of a menu item.  Unfortunately, I didn’t have any way to access the texture array from the method where the equipment menu is created.

screen067

The player’s current attack and defense values are displayed below the character model.  When equipping an item, if the new value is greater than the current value, then the text is displayed in blue.  If the new value is lower, then the text is red.  If the value is the same, then the text is white.  Currently, all collected items for the selected slot are displayed, so the player’s equipped item for that slot is also displayed in the list.  Removing the currently equipped item would be a slight improvement for later, but will probably be a headache to keep the menu indexes straight since it is currently parallel with the list of acquired items for that body slot.  Alternatively, I could just remove the equipped item from the acquired list whenever it is equipped, which is probably the simplest solution.

screen068

Gun Model

screen063

Created a gun model in Blender.  The gun was created using three cubes, which have three different textures.  I deleted half of the cube vertices to make a plane, and I moved the remaining vertices to trace around the gun image that I added as the background image.  Additional vertices were added to the plane by selecting two vertices and pressing “W”.  That will subdivide the line, adding a new vertex.  After I had the outline, I extruded the points out in the y direction to give the model depth.  Since this will be used for a small image, I wasn’t concerned with making the depth very detailed.  It just needed to be simple enough to make the gun not appear to be flat like a piece of paper.  For now, the textures are just using different diffuse coloring, which are dark green, light green, and white for the trigger.  I would like to make it so that I can programmtically change these colors to make different weapons, without generating new weapon sprites.  Just like with the player and socket sprites, I added an armature.  In this case, the armature looks like a “T”.  I turned on automatic keyframing (red record button), set the frames to 20, and rotated the model 90 degrees for each 5 frames.  Then I exported the animation to image files, cropped and shrunk those images with Gimp and exported those into new PNG images.  Finally, I added the images as content objects in the Blasting Bits project.  I updated the code to display a CollectibleWeapon to use these image textures instead of the default image.  As with the socket images, I had to set the maximum number of frames to 20, since the default is 30 frames.

screen064

When I tried running the game, the gun sprites would display and rotate, but it seemed to rotate extremely quickly.  Therefore, I updated the Collectible class with two new instance variables which add a frame delay and maximum frame delay.  The frame delay is private, and gets decremented on each update.  When the frame delay reaches zero, then the animation frame is incremented and the frame delay is set to the maximum frame delay.  The maximum frame delay variable is protected, since subclasses will need to set the delay value for its collectible type.  For the CollectibleWeapon, I set the maximum frame dealy to 2, so that there are two frames of delay before the next image is displayed.  This makes the gun rotate much more slowly and looks better.

screen065