Pretty much I need to see how collision detection works with DirectX 9. I have a sprite and then I have a platform that I want him to jump up onto. Simple platformer game. If anyone has source code that shows what I'm trying to do that would be great.
This is a game I'm making on my own time. Not homework.
My main guy, "The doctor", is drawn like this:
CSprite sprite; int i = 0; sprite.zeroSpriteValues(); sprite.m_nID = 555; strcpy( sprite.m_chType, "doctor" ); strcpy( sprite.m_chSpriteTextureName, "doctor.jpg" ); sprite.m_nWidth = 50; sprite.m_nHeight = 50; sprite.m_fPosition_x = 0; sprite.m_fPosition_y = 500; //sprite.m_bAutoAnimate = false; // We'll control the animation ourself through incFrame() and decFrame() //sprite.m_nFrameRateModifier = -2; //sprite.m_nCurrentFrame = 14; // Point forward until further notice! sprite.m_nFrameWidth = 50; sprite.m_nFrameHeight = 50; //sprite.m_nFramesAcross = 8; // sprite.m_nWidthScaling = 50; // Shrink the sprite's width // sprite.m_nHeightScaling = 50; // Shrink the sprite's height sprite.m_bModifyCollision = true; sprite.m_nCollisionRight = -5; // Reduce sprite 's collision area on the right side sprite.m_nCollisionLeft = -15; // Reduce sprite 's collision area on the left side sprite.m_nCollisionBottom = -50; // Reduce sprite 's collision area on the bottom sprite.m_nCollisionTop = -20; // Reduce sprite 's collision area on the top sprite.loadAnimationString( 0, "0", CSprite::MAINTAIN_LAST_FRAME ); g_SpriteList.push_back(sprite);
and the platform I want him to land on is drawn like this:
sprite.zeroSpriteValues(); sprite.m_nID = 555; strcpy( sprite.m_chType, "brickWall" ); strcpy( sprite.m_chSpriteTextureName, "brick.jpg" ); sprite.m_nWidth = 500; sprite.m_nHeight = 50; sprite.m_fPosition_x = 300; sprite.m_fPosition_y = 475; sprite.m_nFrameWidth = 500; sprite.m_nFrameHeight = 50; sprite.m_bModifyCollision = true; sprite.m_nCollisionRight = -5; // Reduce sprite 's collision area on the right side sprite.m_nCollisionLeft = -15; // Reduce sprite 's collision area on the left side sprite.m_nCollisionBottom = -50; // Reduce sprite 's collision area on the bottom sprite.m_nCollisionTop = -20; // Reduce sprite 's collision area on the top sprite.loadAnimationString( 0, "0", CSprite::MAINTAIN_LAST_FRAME ); g_SpriteList.push_back(sprite);
Question: How can I detect collision between the doctor and the wall, so the doctor will stop falling through platform when he jumps up there?
This post has been edited by RUAg4mer: 09 October 2011 - 07:56 PM