sprite/ground detection?

Started by
4 comments, last by NoEscom 23 years, 10 months ago
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?
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.








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


You use @nbsp; and replace the @ with a &.

Visit our web site:
Asylum Entertainment
My Geekcode: "GCS d s: a14 C++$ P+(++) L+ E-- W+++$ K- w++(+++) O---- M-- Y-- PGP- t XR- tv+ b++ DI+(+++) D- G e* h!"Decode my geekcode!Geekcode.com
Visit our web site:Asylum Entertainment
Thanks!

hello world!

My first hello world in HTML
It''s not really HTML because you didn''t use tags

This topic is closed to new replies.

Advertisement