Advertisement

sprites falling through solid tiles

Started by August 12, 2000 09:56 PM
4 comments, last by Lenny 24 years, 4 months ago
I am working on a side scroller, It is going pretty well except for getting my sprites to land on platforms rather than halfway through platforms or all the way through and then keep falling. The problem is I am droping the sprites according to elapsed time and if the amount of pixels to drop is past the tile it never stops falling. How do I deal with this problem?
You''re gonna have to plot a vector from the sprite''s last location to the new location, and check if it intersects with the platform.

I dont know of any better ways.
Advertisement
Yeah the above methods good, but you could also do a couple of other things.

1) similar to the above method, but you check what side of the tile your player is on before he moved, and then what side he is on after the movement, if they are different then its collided with the tile. Obviously if your sprites falling you want to check what side of the TOP of the tile its on, and if the sprite is jumping up then you want to check the BOTTOM of the tile.

2) Not such a good method, but set a maximum speed, so you will still have time based movement, but if its running too slow it won''t move it too big a gap, the best maximum speed would be 1 pixel less than the size of your tiles, because if its moving more pixels than a tile the user either has a crap computer of the tiles are very small

HTH

----------------
Freeride Designs
----------------
----------------
Black Edge Games
----------------
Thanks guys, this has got me thinking in the right direction but
I am using a attribute map like this.
// tiles are 32x32
bool worldAttributes [20] [40]

Then I just set the tile solid w 1 or not w 0.
Do I need a way to know the the x,y coords of the tile ?
and if so how do I implement this?


Well it should be easy to know the coordinates,
WorldAttribute[0][0] would be at 0,0
WorldAttribute[2][0] would be at 64,0
WorldAttribute[0][3] would be at 0,96 etc. etc.

so if your sprite (top left) is at coords, 64,96 then its on tile [2][3].

HTH

----------------
Freeride Designs
----------------
----------------
Black Edge Games
----------------
Ok, I got tiles converted into x/y cordinates, but I still can not allow sprites to move at random pixel amounts. It is making things way to hard for me. I am thinking about locking the frame rate to 50 fps and then moving the sprites a set amount of pixels each frame. I think that as long as a given computer can
run as fast as the set frame rate sprites should move at the intended speed.

Let me know if this sounds right?
Thanks again

This topic is closed to new replies.

Advertisement