Archived

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

Daboy

Game Question

Recommended Posts

Hey, im making a little game that involves a cannon witch u can lower and raise and fire....and i made picture of it at different heights and different stages of fire... I figured out how to make it switch from higher to lower but how can i link several images in a row??? plz respond if u know how...Thanks

Share this post


Link to post
Share on other sites
I''m assuming when u say ''link several images'' u mean to display the cannon with multiple frames.

All u need to do is create a struct like so...
(one way of doing it)

  
typedef CANNON
{
RECT rcFrames[MAX_FRAMES];
WORD nCurrentFrame;
POINT ptScreenPos;
}


Then make an instance of the struct:
CANNON Cannon;

Fill its initial variables:
SetRect(&Cannon.rcFrames[0], 0,0,32,32);
SetRect(&Cannon.rcFrames[1], 32,0,64,32);
SetRect(&Cannon.rcFrames[2], 64,0,96,32);
etc...
Cannon.ptScreenPos.x = 100;
Cannon.ptScreenPos.y = 100;
Cannon.nCurrentFrame = 0;




Update the current frame variable every frame or so:
Cannon.nCurrentFrame++;
if(Cannon.nCurrentFrame >= MAX_FRAMES) Cannon.nCurrentFrame = 0;

Then blit it by parsing the rect to ->Blt()
lpDDSCannon->Blt(.., &Cannon.rcFrames[Cannon.nCurrentFrame], ..)


Hope this helps :)


Downloads, D3DXSprite tutorial, New platform game: .-= The ZeroOne Realm =-.

Share this post


Link to post
Share on other sites
Hey,

Don''t post in more than one forum just to "get more attention." People will read your post if you just post it in ONE forum.

Keep your posts to one forum please.

Thanks!

Share this post


Link to post
Share on other sites
quote:
Original post by Anonymous Poster
Ok bud than tell me what to do when u dont know what forum to put it in?

Ask. Or apologize at the top of the thread:

I really don''t know if this belongs here, but this is what came to mind. The situation is...





I wanna work for Microsoft!

Share this post


Link to post
Share on other sites