Author Topic: Best way to do an old "stick on wall and ceiling" algorithm?  (Read 2325 times)

0 Members and 1 Guest are viewing this topic.

Offline relsoft

  • DBF Aficionado
  • ******
  • Posts: 3303
  • Karma: 47
    • View Profile
Here's the vid:

http://www.youtube.com/watch?v=0ABPY43NBwI&feature=related

I wanted to emulate the way the tank moves on tiles(floors, walls and ceiling). Sticking whenever possible.

I was able to do this using a sphere to line system using vector projection to "stick" the center of the tank to walls and ceilings.

My approach was better actually since I can do slopes of any degree. However, I'm not happy with memory usage (doing this in a low-spec platform).

So I really wanted to do this with just the tiles and no vector stuff. Just plain old-skool logic but somehow the logic is eluding me.  I'm pretty sure that with the NES, they'ed have used tile collisions instead of vectors.

Thanks.

Any linkies to tutorials would be swell.
Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17409
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
I think that the game in the video is probably using tile collisions at a very basic level.
If I was coding this then I'd know the tile width+height... Do an integer Division on the player's X by the width of the tile and the Y by the height and then you'll have the player's position as a tile offset.. You can use this to check the surrounding tiles for a collision.. Where there are more than one tiles then the direction with the most velocity wins, this could be combined with the control system so that the player moves a tile size before control is returned to the player.. This would work nice I think as the player could move left across the roof but have up pressed so that it puts the player in the gap in a nice way.

I used a similar method when I wrote a version of pacman a long time ago and you never really noticed that you were not in control most of the time!
Shockwave ^ Codigos
Challenge Trophies Won: