Sign in to follow this  

Writing sprite class and loading sprites?

This topic is 4710 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I'm writing sprite class for the 2D game and I ran into problems how to handle sprite images. I use ID3DSprite interface and I tried to read topics about handling sprites with it from here, but none of them consist about handling sprites themself. Okey, let's say I have bitmap where is 256x256 sized sprites in rows and columns. Let's say that first row has 8 "frames" (columns of sprites) and second row has 4 and third row has 9 "frames". All "frames" is for the same in game object (Let's assume that object is a space shuttle for example). In 1st. row there's 8 frames (as I wrote above). These frames makes shuttle to explode (for example). In 2nd. row I have 4 frames which makes shuttle to animate firing guns (for example). Now the question is. How to load those "frames" to sprite class and how to draw them to use minimum system resources as possible? Here is what I'm thinking right now.... Some graphic cards doesn't support large bitmaps to load in textures, so I should use surface to load bitmap into memory first. Is that correct? After the bitmap is loaded into surface I should make array of tekstures for each "state" (read row) of bitmap. I Mean that, for 1st row I should make one array which has 8 textures and copy each frame of the first row from surface to texture - correct? After that I make 2nd. array of textures for next row and copy frames from surface to these textures - right? Any better suggestions? After when I have all frames in arrays of textures I use variables in sprite class (or inherited class) to keepup which teksture I should use in this current scene for this object (sprite) on use ID3DXSprite->draw to blit right texture in the scene - correct? Another way I'm thinking of is to load big bitmap into surface. Keep that surface in memory and use one correctly sized (in this case 256x256) texture for the sprite. And when sprite is drawn variables points the correct rectangle from surface to draw and then when blitting occurs I copy that rectangle sized data from surface to texture object and blit that texture on the scene. What's you opinion about that? Which way is better or is there better way to do moving and animated sprite loading and blitting? I'm sorry my bad english and I appreciate all answers - thanks.

Share this post


Link to post
Share on other sites
Uhm....can't anyone give me a hint about prob. I have? Should I summarise my question here....

- Scenario is this. I have multiple frames of one sprite in a single bitmap picture.

- I'm using ID3DXSprite interface to draw sprites.

- How to load, store and blit those sprites so, that game is playable even in voodoo machine (which has maximum texture size 256x256).

So, bitmap can't be loaded directly to the texture because the limitation of voodoos texture size.

I now I have to use surfaces, but how? Can anyone point me the right direction?

Share this post


Link to post
Share on other sites

This topic is 4710 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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

Sign in to follow this