Skip to main content

Past Blast

Featured Products

Stay in touch using the DEVBUSS RSS feeds.
 

News

Creating Pocket PC Games in eVB Using ASpriteCE

Written by Andy Beaulieu  [author's bio]  [read 54485 times]
Edited by Derek

Download the code

Page 1  Page 2  Page 3 

Let's face it: eVB has a bad rap when it comes to creating fast action games. eVC (and to some extent Assembly) have been the accepted languages for game development on the PocketPC. This is unfortunate, as the intuitive nature of eVB can make any type of application quick to develop and fun to create. The main reason for eVB being an unpopular choice for action games is its speed. Being that eVB is an interpreted language, it can be hundreds of times slower than eVC code at performing comparable operations. And to create that next best-selling Pocket PC game, you can bet fast graphics will be a prerequisite for your tool of choice.

But what if the speed of eVC could be combined with the ease of eVB? Perhaps eVC could be used to handle the intense graphical components of a game such as sprites and sound, and eVB could be used for the overall logic of the game. The eVB application could be notified by the eVC component when certain events have occurred - for example, user input or sprite collisions.

The ASpriteCE Game Control is just that - a component coded in eVC that can be married with eVB to create some pretty fast games. ASpriteCE has methods for creating and managing sprites, sounds, backgrounds, scrolling, and even tiled maps. In this article, I'll give a quick introduction to ASpriteCE by exploring some of it's core methods. We'll create a sample game that demonstrates sprites and getting user input.

To begin, you will need to install a copy of the ASpriteCE Game Control - you don't have to buy it, the trial version will work - downloaded from www.spritehand.com. Be sure to run the install.vbs file which will add registry entries needed to integrate the control into eVB. Then use the Control Manager in eVB (Tools/Remote Tools/Control Manager) to register ASpriteCE.dll to your device. You'll want to pick the appropriate processor build of ASpriteCE from the "bin" folder. If the registration fails, note that ASpriteCE.dll depends on atlce300.dll and gx.dll. If these are not on your PocketPC, don't worry - they're shipped with eVB and eVC in \Windows CE Tools\wce300\MS Pocket PC\. Just register those with Control Manager first.

In the rest of this article, we're going to create a classic Space Invaders style game called "DevBuzzards". In this game, the stoic DevBuzz PDA will destroy the evil DevBuzzards by shooting quality articles at them! We'll explore many of the basic methods and events required to make a cool game with ASpriteCE.


DevBuzzards in action.

Our first task is to create a form, initialize the ASpriteCE control and set the background image. Create an new PocketPC eVB project. Add ASpriteCE to the toolbox by selecting Project/Components and checking the "ASpriteCE Game Library". You will now see the Game Class icon appear in the toolbox. Select it and draw a new Game Window on Form1, making it about the size of the game window in the screenshot above (you don't have to be exact). Now add the following code to the Form_Load event:

Private Sub Form_Load()
' Initialize
Game1.DrawInit Form1.hWnd, 0, 0
' Draw a background
Game1.DrawBackgroundImage App.Path & "\backdrop.jpg", 0, 0
End Sub

Note that the DrawInit method must always be called before any other methods. The last two parameters of DrawInit are only used for scrolling games, so we can pass zeros in for them. The DrawBackgroundImage method is used to draw backdrop.jpg at the upper left corner of the Game Window.

Our next task is to define our sprites from the image files. Take a look at the images below used in DevBuzzards. Of special note is the buzzard sprite which is 180 X 16 and contains 5 frames, each frame being 36 X 16 pixels. ASpriteCE makes it pretty easy to define multi-framed sprites like the buzzard.

Next Page