Jump to content
  • Advertisement
  • entries
  • comments
  • views

Spritelibs and timers

Sign in to follow this  


First off, I discovered that SpriteLib has moved here. The author has dropped the weird licensing stuff. You just need to put your free SpriteLib reg # somewhere in your app (like the "about" box). There's now no reason not to have this thing.

I made a long-overdue change to my timer code. In an average game, I would start 2 or 3 timers, using my GameTimer class (basically a wrapper for the Windows Timer stuff). Usually the game had a GameTimer that would drive the sprites. I had a completely separate GameTimer handling updates to eye candy (little short-lived graphical bits that aren't interactive, like explosions, sparkles, etc). Problem was, I was getting some ugly race conditions and had to add some unwanted wait-for-sync routines.

To fix the problem once and for all, there is now a single "master timer". Creating a new GameTimer object simply hooks into it. Whenever the master timer ticks, it calls all hooked objects. When nothing's hooked, the timer is quietly killed. The change seems to have sped things up a bit and has gotten rid of the need for any wait-for-sync nonsense.

I also added a new attribute to the Sprite class, Touchable. Early on, I had plenty of cool routines for collision-detection, returning all sprites that were touching a given one. Unfortunately, things got ugly with the advent of eye-candy. At some points, there can be lots of eye-candy bits on the screen (especially Zap Pod!, which has explosions everywhere). You could no longer pass an array to the routine that returned all touching sprites, as you didn't know how large to make the array. Sifting through tons of useless sprites to find your enemy was also a pain, so I added a Touchable attribute. If it's set to FALSE, the default, the sprite will not report itself as touching a given sprite. This way, stuff can be dancing all about the screen, but the important game sprites (the ships and bullets) will ignore 'em.

Zap Pod! is basically done. I put in the bonus ship/bomb code and the preferences dialog box. If you want a screen shot, go to the Code Zone site.
Sign in to follow this  


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!