I'm having trouble getting my sprite to go from the right side of my screen to the left and then swap images so it appears to be walking back to the right side and then repeat that process. Ive manage to only get the cats to walk to either direction at the same time, never one after the other.
It's a lot of code so I'll grab the important pieces.
Here I create the necessary instances of the sprites
LPDIRECT3DTEXTURE9 caveman_image;
LPDIRECT3DTEXTURE9 cat_image;
LPDIRECT3DTEXTURE9 cat2_image;
SPRITE cat2;
SPRITE cat;
SPRITE caveman;
LPDIRECT3DSURFACE9 back;
LPD3DXSPRITE sprite_handler;
HRESULT result;
//timing variable
long start = GetTickCount();
long start2 = GetTickCount();
long space = GetTickCount();
RECT rect1, rect2, rect3, rect4;
Here I set the sprites to a certain size and attach that to the rect variable
;
cat.movex = 5;
cat.movey = 0;
cat2.x = -100;
cat2.y = 150;
cat2.width = 100;
cat2.height = 96;
cat2.curframe = 0;
cat2.lastframe = 5;
cat2.animdelay = 2;
cat2.animcount = 0;
cat2.movex = 5;
cat2.movey = 0;
rect1.left = cat.x-1;
rect1.right = cat.x+cat.width+1;
rect1.top = cat.y-1;
rect1.bottom = cat.y+cat.height+1;
rect2.left = cat2.x+1;
rect2.right = cat2.x+cat2.width-1;
rect2.top = cat2.y+1;
rect2.bottom = cat2.y+cat2.height-1;
And here is where I can't seem to get the cat to do what I need it to. I left the animation portion out since that isn't important at the moment since once I reintroduce that the animations will respond.
if(GetTickCount() - start2 >= 30)
{
start2 = GetTickCount();
cat.x -= cat.movex;
cat.y -= cat.movey;
if(cat.x == 0 )
{
cat2.x += cat2.movex;
cat2.y += cat2.movey;
}
}