Jump to content
  • entries
    1212
  • comments
    1738
  • views
    1145007

Spritelibs and timers

Sign in to follow this  
johnhattan

282 views

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  


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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!