Coin Grabber

Windows phone market is target I wanted to reach in past several years. As usually it was initially closed for all foreign companies. Several months ago they allowed Bulgaria to sell products there.

Everything has a start!

This time I made really small game… It’s not a real game… It’s just to fill in your free time between tasks you have.

Based on Silverlight and XNA this is a coin collecting “adventure” that you will forget at the moment you close the game and you will be able to concentrate on your work.

How it’s made…

This game is built on top of the Silverlight/XNA application model, leveraging full 3D rendering, Silverlight’s animation engine, and the use of dependency properties to act as the proxy between Silverlight UI and the XNA Framework based rendering system.

I’m only using the sprite engine in this application. So, we are not to go into 3D rendering.

Project Structure

As any other Silverlight\XNA project this one also has three projects: a content library, a shared library and the windows phone application project.

For a simple project like this the shared library will remain unused.

In the content project I added the images for cents and a font for frame per second label.



In the main Silverlight project I created a BasePage class derived from PhoneApplicationPage class.

All Silverlight pages must derivate from this class in order to have the XNA rendered in background.

The layout update event creates a UI element renderer that will be used by XNA to draw Silverlight elements on top of all XNA drawing. This base class is extended with OnUpdate and OnDraw methods.

Renderer class is added in the project for implementing two interfaces for application lifetime. IApplicationService allows us to add it to the ApplicationLifetimeObjects collection and IApplicationLifetimeAware allows the class to be aware of the application’s life span, enabling us to load content once we know the app has started up.

For this simple application I added the sprites here together with the methods for loading their images.

RendererState class is derived from DependencyObject class. All the dependency properties in this class are used for synchronization between XNA and Silverlight.

I’m not going to get into details about all the changes made in standard Silverlight\XNA application in order to have XNA drawing the background of each XAML page because there are posts about this already.

I have to mention only that with this project structure you can add XAML pages when you need to interact with the user; you can add Renderer derived classes when you need to render different XNA; and you can have multiple RendererState classes.

Sprite.

As simple it is I only have one sprite – the coin.

The coin has texture, center, radius and amount. For animation issues I added acceleration, speed and target position.

Three methods are created into coin sprite.

First one, for checking the tap event – is this the coin user tap on?

Second one, for checking whether the coin is free to move.

And third one, for design the coin fly out of the screen.

Expectations.

I did not expect users to love this game.

I did not expect users to pay for this application.

Results.

Above 600 downloads.

 

Leave a Reply

Your email address will not be published. Required fields are marked *