Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: collision on vertex array tile engine  (Read 2302 times)

0 Members and 1 Guest are viewing this topic.

guptarohan

  • Newbie
  • *
  • Posts: 2
    • View Profile
collision on vertex array tile engine
« on: December 10, 2013, 06:39:35 pm »
Hello there,
I am making a simple 2d rpg with SFML,
I was wondering how to implement collision with my tile engine, which is based on the example on this page.
http://www.sfml-dev.org/tutorials/2.0/graphics-vertex-array.php.
How do I do the following:
a)check which tile the sprite (player) is on
b)specify which tiles are crossable
c)stop the player from going on those tiles

Thanks, Rohan

KarmaKilledtheCat

  • Newbie
  • *
  • Posts: 23
    • View Profile
    • Email
Re: collision on vertex array tile engine
« Reply #1 on: December 12, 2013, 02:52:05 am »
a) Divide the player's position by the size of the tiles (do this for the x and y axis). The result(as an integer) is the tile the player is currently on.

b) Have a bool variable for each tile. Have the variable be true if the tile is cross able and false if the tile is not cross able.

c) Implement a collision system using the four vertices of the tile to get the bounding box rather that the predefined getBoundingBox() function.

 

anything