Comes Full Circle

Back Where We Started

After almost two months of development, I’m back to doing what I started on the first days of development which is updating the sprite graphics.  Updated all of the wire graphics, so now those are filled with light gray (#e0e0e0) with white (#ffffff) and black (#000000) around the edges.  It seems to make the wires stand out a lot better.  Unfortunately, since the shading is on specific sides of the sprites, I can’t do the quick flip/rotate trick that I used when first creating these sprites.  However, Gimp provides the ability to zoom to make the pixels really large, which makes adding the outlines rather easy.  Just tedious.  It should just display as a slightly darker shade of yellow, since Yellow is used as the color parameter of the draw method.  Thought about adding an option to allow the player to select their flow color, but it’s too late to add that now.  Maybe a new flow color will be the reward for completing all of the stages.

 

While I was making graphics, I went ahead and replaced the GameThumbnail.png and Game.ico graphics.  I modified the resistor image with four connections, and replaced the number with just the letter R.  The size for the GameThumbnail was 64×64 pixels, which I believe is used for the dashboard.  The graphic I created is simple, but it does the job.  The Game.ico I believe is only used for when it is running under Windows, and maybe under the XBox system menu.

 

You’re on Trial

Made a trail screen in the game, which subclasses the basic Screen class.  It was a little frustrating to test this, since the game is not in trial mode as I am developing it.  There is a Guide.SimulateTrialMode value that can be set to make the game run in trial mode for testing.  Or I can run the game as trial mode from My Game list, but the game has to be deployed from Xbox Studio Connect first.

Copied a lot of code from the Pause screen to implement two selections, “Buy” and “Back to Title”.  Choosing “Buy” will call the Guide.ShowMarketplace method.  This doesn’t actually purchase the game, but instead takes the player to a standard XBox screen where they can purchase the game.

Added a check in the update method of the trial screen to see if the game has been purchased.  If it has been purchased, then it displays the “Thank you” message and removes the buy option from the screen (leaving only the “Return to Title” option).  From there, the player will have to use level select to pick up at the last level they were playing, because it’s too late now to rework the code for an event that will just happen once for each player.  Ideally, I would have a “Continue” option from the main menu, but I wanted to keep the main menu simple.  Having to find the last level played in the level select screen is the “price” the user has to pay in time for having the simple menu.

Added my cheesy Indie game “song” into the trial screen.  I had to work it in somewhere.

  


Other Fixes

Had to add a special case to fix the level 10 LED (piece ID 30), just as I had to do with the level 10 battery.  Made comments in the code that these should be optimized later.

Added code to center the numeric text of the batteries and LEDs, since the “10” value was displaying near the edge  of the battery and LED.

Maybe it’s just me, but the scrolling background for the game level screen on the XBox seems choppy.  It doesn’t do this for the PC version.  Not sure if that is fixable, or if it’s just my eyes playing tricks on me from looking at monitors too long.  The scrolling background for the title screen doesn’t look this way either.  I may have to re-evaluate some of the code that I used for the slow scroll method.  Alternatively, I could just set the level select background to scroll one pixel per update, just like the title screen does.

Noticed a problem when the level ends and tries to save.  If the Guide is already open, then the game will crash, because the file save operation uses the BeginShowSelector method which conflicts with the Gudie.  To fix this rare scenario, I think I can just pause the game when Game.IsActive is false which is suggested by this article.  This only happens if the player draws the connections to complete the level, and then presses the Guide button before the level is complete, which will cause the level to complete while the Guide is open.

Even Software Developers Need a Break Sometimes

Burnout

Took a coding break on Sunday, since I was starting to feel the burnout.  Participating in a programming competition on Saturday really pushed me to the limit as far as writing code goes.  I had done little game playing in April, so I’ve dropped a few places in the XBox gamerscore leaderboards on TrueAchievements.  Therefore, I picked up an easy game from Redbox and scored a quick 700 gamerscore for a quick rank boost.  I also played a few Indie and XBLA games to check out some of the currently independent developed games.

Level Design

I was able to do a little level design, but that was about it.  One thing I’ve got to watch out for is placing two LEDs next to each other, because the GameLight class is derived from the GamePiece class, which means an LED will automatically start filling other adjacent LEDs.  This prevents the player from using resistors to change the flow values for the adjacent LEDs.  This could lead to an automatic bust in some cases.  Noticed that I also need to display the level/stage number on the level complete screen, which would also help me with recording my scores for the rank information.  There are now 50 total levels to play in the game.

  

Did some more playtesting of the game through the XBox, and began recording my scores, which will be used for the ranks.  I want the S Rank to be difficult to obtain, but I’ve got to ensure that it is possible to get the values that I define for the S Ranks.

Level Select Screen Glitch

Noticed an issue on the Level Select screen where the cursor keeps going back to index 0  from index 1 when the down button is pressed.  Not sure what is causing this, but I will check to see if the pause value is getting set properly in the setActiveScreen method.  Pressing up seems to fix it so that down properly moves the cursor down the screen.  Looked at the code, and I realized that it happens when the user holds up and then presses the confirm button on the Level Select screen (to select a level) before releasing up.  The boolean that tracks if up is pressed was not getting set to false, because the Level Select screen never saw the up direction being released.  Setting that boolean to false in the setActiveScreen method of the Level Select screen fixed the problem.


Week 3 Wrap-Up

(The capture format was set to FLV in XSplit (instead of MP4) with the highest recording quality (20), but there is still some initial distortion in the video after it was loaded to YouTube)

Touch Up Work in Audacity

Touched up the sound effects in Audacity, to give them the appropriate lengths to be used in the game.  For the buzzer, I trimmed down the hair clipper sound effect to 0.25 seconds.  Not sure why, but I wasn’t able to find a crop function in Audacity.  Therefore, I just had to select the portion of the clip I want to use, copy, then paste it in a new Audacity window.  Next I started looking for a sound to use for the main menu.  The buzzers and rings were too harsh of a sound, so I loaded up my shaken Pepto Bismol sound effect.  After cropping out everything except for one shake of the bottle, I realized that this makes a great menu selection sound.  It actually sounds like muddy boots on a wooden walkway.  For the wire filling sound, I slimmed down the running water clip.  The original sound is a little harsh, so I raised the pitch by 265.  The ice sounds were a little flat, so I increased the speed by 200.  It now sounded like an old fashioned money changer.  With this new sound, I added 2 seconds of silence at the end, and then applied the echo effect (delay 0.5 seconds, decay 0.5).  The spoons sounded good without any modification except for cropping out the rest of the noise.  I’ll use this as either a menu sound or a rank display sound.  The spoon hitting the glass made a good sound, but there was a lot of background static noise in the sound capture.  I used Audacity’s noise removal tool to fix it, but it seems to have raised the pitch of the sound as well.  It still sounded okay, so I’ll probably use that as the sound when an LED is lit.  The CO meter made a nice beeping sound, but it was really loud so I used the normalize effect.  I’m not sure where I will use this sound, but I’ll go ahead and import it into the project for now.  This gives me a total of eight sound effects, which should be enough to get me started.

  

Apparently, the volume of the MediaPlayer object uses a value between 0 and 1, and I incorrectly assumed that it was 0 to 100.  For some reason, the sound when it is played on the PC is much louder than it is on the XBox.  Maybe the XBox (or my television) has sound normalization so it isn’t loud like on the PC.  Setting the MediaPlayer volume to 0.1 makes it sound about right on the PC, which I believe is one tenth of the volume.  I will have to test it on the XBox later to see if that makes it too low to hear on the console.  If it does, then I may have to write some platform specific code to handle the differences between the PC and console.

Ran into a bit of an issue with playing sound effects.  In order to play a sound effect, the current screen must have a handle to the MediaPlayer object, which is only available in the main ResistorGame class.  I don’t want to have to pass a MediaPlayer object to each function on each screen that may want to play a sound effect.  I think I’ll make the sound effects like the screen transition, where the screen will implement a public method which will report whether or not the screen needs a sound effect played.  Then the Resistor game class will query that method on each update, and then play any sound effect that is requested to be played.  I usually don’t write code this way, but I think it may make things cleaner in the end, especially if I decide to write a media handler class.  I created a method called getRequestedSoundEffect in the Screen class and added a protected instance variable called iSoundEffect.  If the ResistorGame calls that method and it returns a value greater than -1, then it will play the sound effect at that index in the sound effect array.  Thefore, any of the subclassed Screen just have to set the iSoundEffect variable to any of the sound effect constants defined in the ResistorGame class.  Amazingly, this worked perfectly the first time that I tested it.  I also discovered that MediaPlayer is not required for playing SoundEffect objects (Songs objects only), but it was good that I implemented it this way, otherwise I would have the same problem with passing the sound effect array around to all of the screens.  Just calling the Play method on the SoundEffect object itself will play the sound.  One drawback is that only one sound effect can be played for each update call, otherwise the previous sound effect(s) ID assigned to the iSoundEffect variable will be lost.  This may be a good thing, because there shouldn’t be too many sounds playing at the same time.  Once scenario that I can imagine is if two LEDs are lit at exactly the same time.  Just playing the sound effect once should be sufficient.

Using Audacity and a short tutorial from eHow, I was able to record my voice for the title screen which I gave a repeating robotic sound.  First, I used the Repeat Effect on the start of the audio clip.  Then I used the Delay Effect with Decay=10, Delay=0.01, and Echos=20.  I repeated that effect about 6 times.  I also made audio clips for “level complete”, “game over”, “S”, “A”, “B”, “C” and applied the same effects.

  

Level Selection Modification

I may have messed up by making the LevelDefinition instance a member of the GameLevel class instead of the ResistorGame class.  The ResistorGame class needs to pass the maximum number of levels to the LevelSelectScreen class.  The maximum number of levels is defined in the LevelDefinition object, so it has to get a reference of that object from GameLevelScreen which is a little messy.  I may have to rework this later.

Sound Effects Added to Game

After updating the game code, I now have sound effects for menu movement, menu selection, wire begins filling, light filled, and light busted.  I had to add an additional variable to keep track of light filled, since this property was never actually tracked.  I added that check to the game win check, since it was already looping through the lights on the board, so if the number of lit lights is greater than the number of lit lights on the previous check, then the lit sound effect is played.  I was happy with all the sound effects, except for the electricity one (originally water running from the faucet).  It still sounded to static-like, and it started to give me a headache after awhile.  Therefore, I replaced it with the phaser sound that I made (also from the water running) which has a much smoother sound.  I also had the Pepto Bismol sound (now named SE_PLOP in the constants) play on each menu movement and the spoon sound (SE_SPOON) played on the selection.  This didn’t sound right because the SE_PLOP was longer than SE_SPOON, so I just switched out the occurrences of those two sounds, which makes it sound much better.  The lit light and light busted sound effects sound great.  I may need some delay or an animation when a light is busted, because the light busted sound effect plays through the game over screen.

Special Cases

While playing the game, I noticed a special case that may need to be handled.  If a wire is placed next to two (or more) filled wires (or other pieces), I believe it just takes the Elex value of the first one in the if/elseif statement.  I should calculate the highest of all the neighbors, and assign the new wire the highest value of all the adjacent pieces.

Another thing that had been bothering me is that I thought that the time statistic was proportional to the pieces used statistic, which would make it somewhat redundant.  However, through testing I found that it is possible to get a S rank in time and a C rank in pieces by quickly spamming wire pieces.  This is a good thing, which prevents someone from getting the best possible grade by quickly spamming pieces.  The inverse is also true, where someone can get an S rank in pieces but a C rank in time.  Just take a long time laying down the pieces in the shortest path.