Jump to content
  • Advertisement

Archived

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

NoEscom

sprite/ground detection?

This topic is 6666 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

How does one generally implement sprite/ground detection? I can''t get it to work properly The problem is, when my sprite falls of a platform and i let it collide with the platform again during the fall, the sprite is moved back onto the platform. Ofcourse i don''t want this. Some source to clarify the problem: if (sprite->GetSpeedY() > 0) { // if we are not on the ground, we must be falling or jumping tile_y = (sprite->GetYPos() + TILE_SIZE) / TILE_SIZE; if (((m_tile_map[tile_y][sprite->GetXPos() / TILE_SIZE])->GetType() == MAP_GROUND) // ((m_tile_map[tile_y][(sprite->GetXPos() + TILE_SIZE) / TILE_SIZE])->GetType() == MAP_GROUND)) { // if sprite is falling, put it on the ground tile sprite->SetYPos((tile_y * TILE_SIZE) - TILE_SIZE); sprite->SetSpeedY(0); break; } } Anyone has an idea how to improve it?

Share this post


Link to post
Share on other sites
Advertisement
Give the sprite some forward movement. In other words you
know the dimensions of the object you are on now move the
sprite beyond that. Here it is in 2d.

Your sprite box (It''s dimension)


******** <- Your sprite
* *
* *
* *
********
*************
*
*
***************** <- The floor

Now set the min X of your sprite to the max X of the floor
+1 or whatever. Now you have cleared the floor.








Share this post


Link to post
Share on other sites
Oops! The diagram didn''t work it stripped the spaces out. Ok
imagine that @ is a space...


@@**********<-Your sprite
@@*@@@@@@@@*
@@*@@@@@@@@*
@@*@@@@@@@@*
@@**********
**************<-Floor
@@@@@@@@@@@@@*
@@@@@@@@@@@@@*
@@@@@@@@@@@@@***************<-Floor



How the heck do you include spaces!!! This looks so weird


Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!