Jump to content
  • Advertisement
Sign in to follow this  
  • entries
    292
  • comments
    557
  • views
    154547

Working on Snake

Sign in to follow this  
TANSTAAFL

107 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.
Sign in to follow this  


0 Comments


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!