Page 1 of 1

Help with colision on LOVE2D

Posted: Sun Jun 24, 2018 9:09 pm
by JC Carvalho
i'm new on Love2d, and i'm doing my first game, is a simple game where a warrior walks rigth and left and attacks, the waarrior are two sprite, one for walk, another for attack, the enemie is a image, and goes from one side of the screem, to another, with no animation.

The problem is, how i make the colision of this two images? i had searched on the internet and try some things, but nothing work

If someane could help, i will be very very grateful.

i'm sending my code to, if helps

and very sorry for the bad english, is not my native language

thanks

Re: Help with colision on LOVE2D

Posted: Sun Jun 24, 2018 10:26 pm
by Jeeper
There are a ton of different ways you could do collision and what the best way to do it for you depends a lot on many different variables.

You could either use a library like BUMP (https://github.com/kikito/bump.lua)

Or you could use the build in Löve physics system (https://love2d.org/wiki/love.physics), this is what I personally prefer, but I feel like I am in the minority though.

Another alternative would be to use something like AABB collision that you code yourself. An example of this would be:

Code: Select all

if ax < bx + bw and ax + aw > bx and ay < by + bh and by < ay + ah then
 --A and B are colliding
end