January 27th, 2011
Bitbreaker for the Windows Phone 7All Silverlight Examples, Silverlight News, Silverllight Games, Windows Phone, Working with Silverlight, by Gavin Wignall.
My first Windows Phone 7 App has just gone live on the Marketplace. It costs only 79p / $0.99 in the UK/US so please go buy it and give me some nice feedback .
As this was my first attempt at producing a Mobile app, I knew I was in for some interesting learning curves. Because of this I decided that my first app should be based on the well established bat and ball style game.
The launch version consists of the following features:
- 1 free trial level
- 36 additional levels in the full game
- 5 power-up blocks that effect game play
- 6 types of blocks to hit varying in strength
- 1 bat that deflects the ball lower at the edges
- An exponential multiplier point system requiring skill to master
- 3 tier achievement system for each level
- Fast level restart system for people trying to hit those top achievements
The level designs range from quirky retro designs honoring the game industries history to complex and tough mazes. The user is required to complete a level before unlocking the next one to play.
Multiplier bonus system
I wanted to encourage players to try and trap the ball in mazes instead of just bashing away brick by brick. To help this I implemented a multiplier point system. Each time the player destroys a block they get an additional multiplier point that multiplies the score you get for destroying the next block. When the ball hits the bat then the multiplier bonus resets back to zero. This means in order to score high points the player needs to trap the ball so that it destroys several blocks before hitting the bat again. Some later complex levels allow the user to score massive points if played correctly
During my progress I had several obstacles present themselves that I had to work around.
The first one, that presented itself early on, was having to code for a mobile processor. Having created Silverlight experiences for desktop PCs over the last 4 years has somewhat spoiled me over the years, meaning I have not had to be too careful about how many times I check values within the XAML. I found with the Windows Phone platform that taking my usual approach to creating a game left me with an unimpressive framerate when testing on the device. I soon learnt my lesson and started storing data in arrays and variables, this meant my app only had to trawl the XAML tree when it absolutely needed to.
The second obstacle was getting my app to load quickly on the test device. I found that my initial approach, running a for loop to create 81 block controls, took nearly 40 seconds to load. Two of the rules set out by Microsoft in order to have your app approved are:
Your app must load within 20 seconds
Upon restarting your app from a tombstone state it must take under 5 seconds to load
I found that asking the app to create and then draw so many controls upfront was a big task. To get around this I placed the controls into the XAML and set their visibility to collapsed so that the app did not have to redraw them until I asked it to later on.
The last problem was associated with the type of game I was creating. As I wanted to include blocks that were solid (could not be destroyed) I had the possibility that the ball could get stuck in an indefinite loop. To get around this I implemented a piece of code that checks to see if the ball has been trapped for a prolonged set of time and then adjust the balls trajectory slightly. This process is then repeated until the ball registers a hit with the bat.
I have several plans for updates to Bitbreaker. They include some of the following:
- Plenty of more stages and levels
- Invisible blocks
- Moving blocks
- New bat types to unlock each holding different characteristics
- New Ball types to unlock each holding different characteristics
- A time trial mode that selects random levels