Help with colision on LOVE2D

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.
Post Reply
JC Carvalho
Prole
Posts: 1
Joined: Sun Jun 24, 2018 8:51 pm

Help with colision on LOVE2D

Post by JC Carvalho » Sun Jun 24, 2018 9:09 pm

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
Attachments
main.lua
(3.97 KiB) Downloaded 16 times

User avatar
Jeeper
Party member
Posts: 543
Joined: Tue Mar 12, 2013 7:11 pm

Re: Help with colision on LOVE2D

Post by Jeeper » Sun Jun 24, 2018 10:26 pm

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

Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests