I decided to make a 2 player version of this game. So I just copied the files over to another folder and transformed it into a 2 player game. Everything works fine, except the collision. I have the exact same collision as the singleplayer version, but for some reason, the collision doesn't always work. It's glitchy, and sometimes it only counts if they touched the player's right side, or sometimes it's the left side. There's no determining what happens.
Anyway, here's my death checking code. I call it in the main.lua, in love.update().
Code: Select all
death.check=function()
for _,enemy in ipairs(enemy) do
for _,player in ipairs(player) do
if ((enemy.x+enemy.w>player.x and enemy.x+enemy.w<(player.x+player.w)) and
(enemy.y+enemy.h>player.y and enemy.y+enemy.h<(player.y+player.h))) then
death.state=true
end
end
end
end