Archived

This topic is now archived and is closed to further replies.

blueEbola

sprites, how?

Recommended Posts

Hi, I'm making a bomberman clone and I've recently run into some trouble. The way I designed my sprite class wasn't really that efficient, and it didn't work for the most part (it was quickly thrown together, bad on my part). I'm going to redesign it, but before I do that, I was hoping I could get a couple of pointers. This question is for those who have made 2D games in opengl before .. How'd you manage your sprites in game? Thanks in advance! [edited by - blueEbola on August 15, 2002 6:28:42 PM]

Share this post


Link to post
Share on other sites
I use glBitmap for writing (see Red GL book Chapter 8 I think).
Another method is to use transparent textures with an alpha channel (see NeHe TGA loading tutorials) or Masking (NeHe too).

Masking has the disadvantage that you have to draw the picture and the mask for every animation frame.

I got an texture array, with the sprites.
and an animation file like this:

TEXTURES
models\bomb1.tga
models\bomb2.tga
...

EXPLODE
0
1
2
3
4
5
6
...

The Textures are loaded and the EXPLODE animation is followed by the texture numbers and the timeinterval to wait before changing to next frame.

This is how I''ve done it.
I hope I hav''nt missed your question
StryX

Share this post


Link to post
Share on other sites
I''ve gone the other route and avoided external files altogether, except for the graphics.

I made a base sprite class, with virtual functions, notably a spawn function, a frame function, and a draw function. I inherit all sprites from this.
In my games main class I have the texture resource manager, wich the sprites spawn function uses to get it''s texture binding numbers. The main class also has a spawn entity function which uses a string to choose which sprite class to create, then casts the pointer to the base class, and sticks it in an std::vector called, surprisingly, sprites.

Share this post


Link to post
Share on other sites