What's wrong with this piece of code?????

Started by
4 comments, last by GameDev.net 19 years, 4 months ago
RECT rPortion={0,HEIGHT*currentFrame,WIDTH,HEIGHT}; TransparentBlt(hdcBack,posX,posY,WIDTH,HEIGHT,hdcBitmap,rPortion.left,rPortion.top,rPortion.right,rPortion.bottom,RGB(0,0,0)); the bitmap is cut and the piece of the image that was cut is seen at the top of the bitmap(the feet appear on the caracter's head) Thanks for your help
Advertisement
RECT rPortion = {0, HEIGHT * currentFrame, WIDTH, HEIGHT * currentFrame + HEIGHT};

The four members of a RECT are left, top, right and bottom - the last two are not width and height.
Well i changed the code to this:
void CMonster::DisplayBitmap(){hOldBitmap=(HBITMAP)SelectObject(hdcBitmap,hBitmap);RECT rPortion={0,HEIGHT*currentFrame,WIDTH,HEIGHT*currentFrame+HEIGHT};TransparentBlt(hdcBack,posX,posY,WIDTH,HEIGHT,hdcBitmap,rPortion.left,rPortion.top,rPortion.right-rPortion.left,rPortion.bottom-rPortion.top,RGB(0,0,0));SelectObject(hdcBitmap,hOldBitmap);}



but the problem still exists.....what is that makes this funny thing happen in my sprte animation
Are you sure the value of HEIGHT is set correctly?

How are your sprite graphics laid out?

Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse

Well this is not it because the feet move right but they come up on the players head[lol]
You need to post your code to find the posx and posy values, that is where the problem is. PosX and PosY are the location which you want to draw the sprite at, have you offset these by the height of the body? (PosX might not need to change, but PosY would probably have to increase)

Regards,

Lief Jorgensen

This topic is closed to new replies.

Advertisement