Moved!

July 3, 2015

Moved!

Please visit my site at http://levidsmith.com


New Resistor Review

June 20, 2013

Be sure to check out the new Resistor review by XBLA & XBLIG Ratings Top 50 Reviewer joebal.

Learning while playing can be fun! 9/10

Also, Resistor has been submitted to the IndieCade International Festival for Independent Games to be held in Los Angeles from October 3 through 6.


What is Resistor for XBLIG?

December 13, 2012

The objective of Resistor is to build connections to carry electrical flow to activate LEDs (light emitting diodes). To avoid damaging these components, the flow level must be reduced using resistors. Each level is graded upon number of pieces used, the luminosity of the LEDs, and the time required to complete the level. This game teaches the basics of resistor color code values.

Each level has a power source with an electric flow level.  Use wires (A button) to connect this power source to all of the LEDs on the level.  Be careful to not connect a wire that has a higher electrical flow value than the number displayed on the LED, otherwise the LED will be destroyed and the game will end.  To lower the electrical flow, use a resistor (X button) to lower the electrical flow of the wire.  The target is to use a resistor that will lower the electrical flow just enough to activate the LED.  Lowering the electrical flow too much will still activate the LED, but the luminosity grade for the stage will be penalized.  After every ten levels, a new higher level resistor will be awarded.  The currently selected resistor can be changed using the bumper buttons (LB and RB).  Complete the levels as quickly as possible with the fewest number of pieces to get the best grade rankings.


Resistor – On Sale Now for XBLIG

September 3, 2012

Buy Resistor from Xbox.com 

Resistor is now on sale in the XBox Live Indie Game Marketplace.  Try the trail version for free, and if you like it all 90 levels can be unlocked for $1 (80 Microsoft Points).

From the XBox dashboard, go to Games > Browse Games > Indie > A-Z > R > Resistor

You can also find Resistor in the Puzzle & Trivia Genre section

Thanks to everyone for following the development of Resistor!

 

 


Submitted for Playtest

June 13, 2012

I haven’t done any development for Resistor since I submitted it to the Dream Build Play competition on May 30th.  Therefore, I went ahead and submitted for Playtest on the AppHub website.  I guess this is what it feels like to send your first child to school.  However, I’m sure that any feedback that I do get will be helpful, which will make the game better.

There must be some tough critics out there, because the Resistor trailer video instantly received a negative vote after it was posted on the DBP website.  Therefore, I went ahead and disabled voting on the video until the competition is over.  On the other hand, the video has been getting a lot of traffic, and it is now over 125 views  just for being posted for a little over a week.  I went ahead and made the video public, because it was previously unlisted where a link was required to view the video.  I also made a YouTube playlist containing the complete series of development videos.

After taking a break from looking at the game, I did play it again for a few minutes and noticed new ways to complete some of the levels.  I probably wouldn’t have noticed this if I had not stepped away from the game for a while.  These new ways allow some of the levels to be completed with fewer pieces, so I may need to tweak the requirement for the S-rank on those levels.

Not that I’m trying to overly promote the game, but I went ahead and made pages on Facebook and Twitter for the game.  I did this more as a precaution to keep someone from taking the “resistorgame” brand name on those social media outlets.

I also created new box art for the game, and got rid of the image that I rendered in Blender.  I didn’t want to give anyone the impression that the game uses 3D graphics.  The background is an interconnected mesh of battery, LED, and resistor objects.  I also used some of the trailer quotes on the box image, but I changed “fun for the entire family” to “fun for all ages”.  The former wording could possibly sound like it is a multiplayer game, which it isn’t.

Hopefully, the playtesting goes well and it will be out on the XBox Marketplace soon.  There are some changes I may want to make before putting out the final version, such as fade-in/fade-out transitions between screens.  I also have to jump through a few other hoops before I can actually sell the software.


Testing on Older Hardware

May 26, 2012

Multiple Controller Testing

So sure enough, the first time I tried running the game with two controllers plugged in (first one signed out, second one signed in as my developer account) I get the Code 4 error from the XBox.  Even turning off the first controller will generate this error, so currently the first controller must be the one with the developer’s account.

The game will play fine with two controllers having the first one signed in as the developer’s account and the second one not signed in.  However, if the first controller signs out from the Guide it will immediately throw a Code 7 error.

  

Old School Television

I also needed to test to ensure that my game will run on older televisions.  It’s a good thing that I paid to have my old Elite XBox fixed about a year ago.  Originally, the only reason why I had it fixed was so I could get my game saves off of it to transfer over to the XBox Slim.  I think I had to buy a special $20 adapter just to do that as well.  Fortunately, now it is going to come in handy, since it is the only working XBox that I have that can read an MU (Memory Unit), which is required for testing the device selector.  I also had an old Sharp CRT television sitting around collecting dust, so I can use it to test the lower resolution and 4:3 screen ratio.

  

  

Save File Problem

After downloading the XNA Game Studio Connect to this XBox and recovering my developer profile, I was able to connect my PC development environment to this system.  Unfortunately, when I tried to deploy the game, it just sat on a black screen.   This completely froze the XBox system, because pressing the Stop button in Visual Studio and pressing the Guide button on the controller had no effect.  I tried changing the resolution constants in my main game class to 1080×720 to see if that would help resolve the issue, but I still got the black screen.  Therefore, I had to manually hold the power button to shut down the XBox.

  

 

Next, I tried just deploying a default project, and I did get the Cornflower blue screen on the television, which at least gave me a starting point for finding the problem.

I removed the MU from the XBox and tried deploying again, and this time I got a runtime error (which is better than the black screen).  It was complaining about my save file not existing.  This file must have gotten created on my other XBox during my testing, but I never added the code to create the file in my final game code.   The OpenFile was crashing if that file didn’t already exist.  To resolve this problem, I just added a check to see if the file exists before it is read.  If it doesn’t exist, then it just creates an empty file, which should prevent the error.

 

After fixing this, I got another error about the file being used by another process.  This is (unfortunately) one of those problems that appears to happen only once.  I tried deploying it again, and the game runs fine.   I believe this was because the CreateFile method opens the file for reading, but it wasn’t closed, so when the OpenFile method tried reading the file, it saw that something already had a handle to that file.  However, the next time the game was run, the file was not created, so nothing had a handle to the file when the OpenFile method was called.  I went ahead and added a Close method immediately after the CreateFile call.  This probably isn’t the optimal solution, but I just want to get it working for now.

It’s a good thing I tested this before submitting my game, otherwise it would have probably crashed the first time someone tried to play it.  Unfortunately, there is no easy way (that I know) to entirely remove the game and the files it creates in the process, to simulate a new person playing the game.  It is possible to set the XBox back to factory settings, but then I would have to install all the updates, download my profile, and download the XBox Studio Connect again.

I went ahead and added a check around the file reading and writing functions, so it doesn’t try to read or save if the Guide is open.  Therefore, it won’t save the player’s data, but the game won’t crash.  Theoretically, this should never happen since I’ve added a check to the game level screen, which will transition to the PAUSEGAME state if the guide is active.  I also noticed that there is an “OpenOrCreate” property on the FileMode object used with OpenFile, so I was able to remove the inefficient Create/Close code I just added.  Using the OpenOrCreate property solved one problem that I’ve noticed, where it wouldn’t always add the achieved  ranks to the level select screen, making it impossible to get back to the last level completed.

After all these changes, my game still didn’t use the device selector, which is a requirement to pass the peer review in the Evil Checklist.  Spent some time (IO always seems to take the longest) to rework all of the file save code.  I quickly realized that the method that I used to save games in an earlier post did the job, but wouldn’t pass the peer review process.  The thing that gave me the biggest headache is the asynchronous method it uses to select a storage device.  While the player is selecting a device, your game is still running in the background.  This made it very difficult to do the load from the level select or game level screens, because  the game would be started (or level select displayed) before the storage device is selected.  Therefore, I created another screen just for selecting the storage device (LoadScreen) which subclasses my default screen class.  This screen will wait (unless the cancel button is pressed) until the storage device is selected and the file is loaded.  The next problem was which state should the load screen transitions to after it is complete, because the load screen can come before either the game loop screen or the level select screen.  I added a variable to the load screen called iFollowingState, which is set before the screen is shown to track the state that follows.  If the user doesn’t select a device, it remains on the load screen displaying a message to the user stating that a storage device must be selected.  If the user presses confirm or start, then it will give the user a chance to select the storage device again.  If the user presses cancel after not selecting a storage device, then the user is sent back to the title screen.  On an XBox with only one storage device, the player should never see this screen at all.

  

After a little more searching, I was able to find where the XBox keeps the save data for the deployed Creator’s Club games.  Under the System menu, select the XNA Game Studio Connect under games, and then there’s another menu under that which contains all of the game data.  This will be very helpful for wiping the save game data, to test the game as a entirely new player.


Title Safe Area

Started reading about the title safe area, which is another requirement on the Evil Checklist.  I think my game should be okay, since I was having a hard time filling up the entire screen anyway.  I may need to go back and double check some things like the “Replay” and “Next” selectors on the GameWinScreen.

So after I got the game running on the CRT television, I immediately noticed that the year value was being cut off on the title screen.  There is also a black letterbox effect around the top and bottom, but I think that is expected in the 4:3 resolution, so I don’t think it would fail peer review for the letterbox effect.  The arrows on the level select screen are slightly cutoff, as well as the word “LEVEL” on the game level screen.  Everything else is looking good.

Discovered that even though this looks okay on my CRT, it may still not technically be in the Title Safe area, which is determined by the Rectangle returned from graphics.GraphicsDevice.Viewport.TitleSafeArea.  I updated the draw method on the main Screen class to take one additional parameter, which is the title safe rectangle.  Therefore, I had to update all the screens that subclass Screen, to accept this new parameter.   However, it will be beneficial in the long run, since all draw methods will now have a reference to the TitleSafe area.

  

 


After adding the new TitleSafe Rectangle as a parameter to the abstract Draw method for screen and implementing it in all the subclasses, I drew a transparent red rectangle cover the title safe area.  This is really helpful in determining if anything is outside of that area.  I added a variable in the main game class, which can be used for turning this red tile safe box on and off.  I updated all of the screens appropriately, so vital information does not display outside of this area.  I left the scrolling arrows on the level select screen and parts of the S-rank circling stars immediately outside of the of the title safe rectangle.  The stars are just for show, and the user doesn’t need the arrows for navigating the level select screen.  As seen in the screenshots below, I had to move the selectable resistor icons slightly down, the “LEVEL X-Y” label to the right, and “Replay” and “Next” buttons up.  I had to move all of the text on the Game Win screen slightly up for everything to fit in the title safe rectangle.

  


Minor Fixes

Updated the Level Select screen, so that if the selector is over a level that can not be played at this time, it will have a darker color.  This was accomplished using the isLevelUnlocked method that I previously created.

Noticed that when pressing right on the D-Pad, the cursor will keep moving after the button is released.  When I checked the main game loop, I was actually calling rightPressed instead of rightReleased on the current screen when right was pressed on the D-Pad.  It’s hard for me to believe I didn’t catch this earlier, but I always play the game with the thumb stick.

Also noticed while testing the multiple device selector, the device selection menu would popup every time the Cancel/B button was pressed.  This was a really old test when I was first implementing the save feature, but I guess I never took that line of code out.  I never realized it was still doing that on my main XBox, because it doesn’t show the device selector when there is only one storage device.  It was really noticeable on the XBox with the MU installed.  Taking the load game call out of the “B” button detection check fixed this problem.




Comes Full Circle

May 24, 2012

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

May 7, 2012

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

April 24, 2012

(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.

 



Amateur Foley Artist

April 22, 2012

Gathering Sound Effects

Now is a good time for me to start gathering sound effects for the game.  I could have went to one of the sites that offer free creative commons sounds effects and downloaded what I needed there, but one has to be careful to read the license for each sound effect to ensure that it is covered by a creative commons license that allows it to be included in a work that is sold for profit.  Right now, I’m just creating this game for the contest, but if the game is popular I would be willing to sell copies of it for money (sorry RMS).  I’m trying to make the development of this game as open as possible without sharing the source code, because I believe I read once that sharing source is not allowed by XBox Indie games.  I also didn’t want to make another credits screen, which would be filled up with URLs with links to sounds effects.

My iPod Touch was used for recording all of the sound effects as voice memos.  The sound quality isn’t the best, but it does the job.  I wouldn’t mind going back later and recapturing the sounds using a high quality recording system.  Using a tip that I found on the Internet, I was able to export all of the sound effects through iTunes directly into WAV (MP3 was also an option) so I can edit the sound effects in Audacity.  To change iTunes to export as WAV (default is AAC which is useless), there is a setting under Import CD that must be changed.

Now is the fun part of capturing sounds.  My clippers and hair trimmers were used to make buzzing sounds.  These can be used for error sounds.

 

Running water at full pressure almost sounds like electricity.  I doubt anyone would notice the difference, unless they read this post.  Futher modifications in Audacity will also give it a more electric sound.  This will probably be a constant sound that plays as wires are filling.   I think Audacity has an option for making an audio file seamless, so it can be looped multiple times without any breaks in the audio.

 

Ice makes a nice chrunching and breaking sound, without all the mess of breaking a real glass.  This will probably be the sound when an LED breaks.  I know it should probably be a burn out for fizzling sound, but I think the breaking sound will be more dramatic.

 

Two spoons were used to make a nice ringing sound.  The spoon hitting the glass makes a longer vibrating ringing sound.  These will probably be used as a confirmation sound effects.

   

A drawer slamming makes a good sound, which can be used for a cancel event.

 

The test on this CO detector makes a nice beeping sound.  I could imagine that sound being used as the ranks at the end of the level are displayed.

 

I’m not sure if this will make the final cut of sound effects in the game, but a shaken Pepto Bismol bottle makes a great liquid type sound.  I’ll probably find some way of working it in the game.

Background Images

While I was at it, I went ahead and used my iPod Touch to take picutres of an old sound card and network card that I had in storage.  After some touching up in Gimp, these should make great background images.

 

Minor Graphics and Input Fixes

Set the default cursor position for the level to 5,5 because it really bugged me that the cursor starts off the board on the first level in the upper left corner.  It also minimizes the distance that the cursor must move from the starting position to any other space.  The position of the game board has also been centered on the screen (SCREENWIDTH – (iTotalCols * CELL_SIZE)) / 2, (SCREENHEIGHT – (iTotalRows * CELL_SIZE)) / 2 = (640 – (10 * 32)) / 2, (480 – (10 *32)) / 2.  This is a very helpful formula that I’ve used for centering objects in many games.  Fortunately, I already defined a board offset variable as a Vector2, so I just needed to add that formula to that offset variable.

By simply adding one line of code, I was able to disable the ability to place a piece on a empty space.  I still allow the player to move the cursor to empty spaces, primarily due to the fact that the starting position of the cursor (5,5) may be in an empty space.  This happens on level 4 (donut level) where there is empty space in the middle of the board.

Fixed the resistor graphics so that it can be superimposed over the default wire images.  Increased the maximum pieces to 10 (1 + 9 resistors).  Now all resistors are selectable.  The currently selected piece has a red background.  Later, I will probably make only certain resistors available on each level.  For example, there’s really no point in having a 9 resistor on a level where the maximum battery and LED value is 2.  The selected piece can now be changed by using the left and right bumpers.

Now displaying the selectable pieces at the top of the screen, but I’ve got to be careful that it isn’t cut off on the television screen.  I think I remember reading that 20% of each side of the screen image is not displayed on the television.  Added right/left bumper pressed/released abstract methods to the Screen class, which made me implement it in all the Screen subclasses.  Added methods to increment and decrement the selected piece, which is called by the action button (X) press and the bumper button presses.

 

Fixed the GamePieceResistor class so that the Elex value can’t be lowered below zero.  LEDs can be activated with a zero value wire, but it won’t add any points to the total luminosity score at the end of the level.

Made minor modification to the level 3 board, so that the last two LEDs are placed further back on the game board.

The Level Select screen now takes the player to the selected level once the confirm button is pressed.

Changed the cancel button to set the selected piece to the wire (index 0).  The Back button now takes the player back to the main menu.  The Back button will probably be disabled, after I create a Pause menu.

Noticed an issue on the XBox 360 that doesn’t happen when running the game through the PC.  If I set the MediaPlayer sound to zero (for mute), then it must be set back to 100 for sound to play through the XBox again.  Just commenting out the line that set the sound volume to zero will still keep the sound muted.

Went through and manually played the five levels that I have so far, and used my score for the S ranks.  I just created values for the A, B, and C ranks, which seemed appropriate.  All these values are stored in arrays in the LevelDefinition class.  I updated the getPieceRank, getLuminosityRank, and getTimeRank methods to return the appropriate values based on the current level.  Forgot that I was passing the time as milliseconds, which took a little while to debug.  Dividing the time value by 1000 before passing it to the getTimeRank method fixed that problem.

Changed the message from “YOU WIN” to “LEVEL COMPLETE” after completing a level.

Removed the fill frame number from currently filling cells.


Level Up

April 19, 2012

Tile Editor Agony

Started using the Tiled tile editor to create levels for the game, because I thought that was the editor I used for Legend of Tux.  I created a simple sprite sheet which contained the tiles on one layer, and the batteries and LEDs on another layer.  I found that I was only able to export my maps in a very limited number of formats.  It’s sad that this tile editor can’t output a simple indexed array of tiles.  I’m really not in the mood to write a parser for any of these formats, so I went back to the Legend of Tux wiki and found that I actually used Mappy last time.  Therefore, I downloaded Mappy and recreated my levels with that tool.

 

Mappyland

Mappy will not load PNG spritesheets unless two DLLs are included, so I had to download those file separately from the Mappy website.  Apparently there is a now bug with the “export all layers” functionality, so each layer has to be exported individually or else you will get an array filled with zeros.  What a pain!  Unfortunately, they don’t provide a binary download for the previous Mappy versions, and it’s not on SourceForge so a previous version isn’t archived for download.  The author even says on the website that 1.4 is a beta, so why can’t the last stable release still be downloaded?

 

Make sure to set the color depth to 16-bit when creating the map, or else the sprite sheet will not load and Mappy will complain.  As shown in the sprite sheet above, batteries start at index 10, and LEDs start at index 20.  I can get the Elex value of the LED or battery by modding (%) by 10, which really isn’t scalable past 10, so this may need to be reworked later.  This sprite sheet is just used for creating the level arrays, so I was sloppy when placing the numbers.  In the actual game, the numbers are programmatically placed on the objects.

I created getter methods in the LevelDefinition class to return the background tile array and object array.  Then I have a method in the GameLevel class which converts the integer arrays to actual objects (GamePieceBattery, GamePieceLight, etc).  Using the Mappy exporter, I was able to acquire the static array data definitions, which I pasted into my LevelDefinition class.  Wrote simple if/else statements to return the correct array for the level, but this could be changed to a switch/case statement (if C Sharp has those… I don’t know, and I didn’t feel like looking it up, since if/else does the job).

Next Level

Added instance variable to the main ResistorGame class to track the current level.  I’ve been trying to keep instance variables out of this class except for the media files.  When the GAMEWIN state is enabled, the current level instance variable is incremented.  If the current level variable is greater than the maximum number of levels (currently hardcoded to 5), then it gets set back to zero.  For the  LevelSelectScreen, the class could return a level index, and the ResistorGame class can use that value to set the current level instance variable.

One problem I’ve noticed is that the cursor defaults to cell 0,0 at the start of each level, which may be off the actual game board, now that the shape of the levels are custom defined.  I may need to add an additional object to the level definition which is the starting position of the cursor.  Additionally, all levels are using the same value thresholds for the ranks, which will need to be fixed later.  The S rank for luminosity should be easy to calculate (the sum of the bust values of all the LEDs).  As for the time and pieces used rank, I’ll probably just play through the levels a few times, and use my best scores for S rank, then use some sort of bell curve function to determine the thresholds for the A, B, and C ranks.

 

Loose Ends (Fix later)

Here’s just a few additional things that need to be fixed.

Currently, there is a display issue if the wires connect to the resistor from the sides.   The wires need to be removed from the resistor sprites, then just simply display a standard wire which will make the proper connections, then display the resistor core on top of it.

I haven’t decided if I should let the player move the cursor off the board cells, and just prevent the user from placing a piece on a non-board space… or should the player only be allowed to move the cursor on game board spaces.  If the player is allowed to move the cursor off of game board spaces,  then the player shouldn’t be allowed to lay pieces on those empty spaces.

I may allow the player to continually lay wires as long as the confirm button is held down, because currently the player has to keep alternating between pressing the direction and the confirm button to lay continuous pieces, which feels jerky.

The LED values can still fall below zero if enough resistors are used.  Need to set the bottom limit to zero for these.