Help with collision!

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
IndieKid
Citizen
Posts: 80
Joined: Sat Dec 22, 2012 7:05 pm
Contact:

Re: Help with collision

Post by IndieKid »

Usually coordinates of player are linked to grid's x and y. But in your game player is linked to pixel grid. Anyway...

In your code there are 2 variables that shows the width and height of a tile. They both are equal to 50. What I reccomend you to do is creating a new variable tileSize or tileSide. It will be more easy to work with it.

So we want to get player's X and Y linked to map grid:

Code: Select all

x = math.floor(playerx/tileSize)
y = math.floor(playery/tileSize)
Here you are. You need to check for collision next.

P.S. Please, quote next time.
Post Reply

Who is online

Users browsing this forum: No registered users and 205 guests