• entries
292
557
• views
154101

# Working on Snake

85 views

So, I got some time today to work on "Snake" and see what I can do to help bring it up to production quality.

My first task is to switch from the way I'm currently loading resources (which is one at a time) to the PopCap way, which is to make use of their nifty resource manager class, and show a progress bar of how far along the loading is.

First step... create the resource manifest, which is easy enough. It is a simple XML file describing the various images and sounds in my game.

It looks like:
"1.0"?>	"Common">		"images" idprefix="IMAGE_"/>		"SCORE" path="score"/>		"BACKGROUND" path="background"/>		"PORTIONS" path="portions"/>		"CONTINUE" path="continue"/>		"Loader">		"images" idprefix="IMAGE_"/>		"TITLE" path="title"/>		"STATUSBAR_TRACK" path="statusbar_track"/>		"STATUSBAR_LINE" path="statusbar_line"/>		"Game">				"images" idprefix="IMAGE_"/>		"GAMEOVER" path="gameover"/>		"NEWGAME" path="newgame"/>		"PAUSE" path="pause"/>		"PELLET" path="pellet"/>		"SNAKE" path="snake"/>		"SNAKEHEAD" path="snakehead"/>		"PLAYAREA" path="playarea"/>		"sounds" idprefix="SOUND_"/>		"EAT" path="eat"/>		"GAMEOVER" path="gameover"/>		"MOVE" path="move"/>

During the process of creating this file, I also made certain that I had all of the graphics I could think of that I would need, and this caused me to add a few images, so this process took a while.

Next, I made my resource class. The PC demos don't actually make this a "class" per se, but all of the declarations for resources are in the same source file (Res.cpp), and named things like IMAGE_*.

I didn't like a few things about the way PC demos handle this. One, the code supports finding up a loaded resource by string, an id number, or just with the variable. Two, they mix together all of the types of resource, rather than splitting them up into an array of images, an array of fonts, and an array of sounds.

So, I fixed it. Each type of resource gets loaded into its own array. Each type of resources is indexed by an appropiate enum. The resources aren't just in the namespace, but rather inside the Res class as static members.

All in all, I'm much happier with this scheme, and it still basically does stuff the PC way.

There are no comments to display.

## Create an account

Register a new account