function love.update(dt)
joysticks = love.joystick.getNumJoysticks( ) -- Anzahl der Joysticks zählen
i = 1
while i <= joysticks do
left_x = love.joystick.getAxis(i, 1 )*3 -- X Werte des Linken Joysticks errechnen
left_y = love.joystick.getAxis(i, 2 )*3 -- Y Werte des Linken Joysticks errechnen
spieler[i].pos_x = spieler[i].pos_x+left_x
spieler[i].pos_y = spieler[i].pos_y+left_y
for c=1, (coll_count) do
if spieler[i].pos_x < (tile[c].x+tile_w) and tile[c].x > (spieler[i].pos_x+spieler_width) and spieler[i].pos_y < (tile[c].y+tile_h) and tile[c].y > (spieler[i].pos_y+spieler_height) then -- Collision Feststellen
coll = "Fuck Yeah, Collision!!!"
else coll = "Damn... No Collision." end
end
i = i + 1
end
end
It is difficult to say, what going wrong, because the code you posted is so short. Can you please pack your game into a .love and upload it? Also please state more precisely what is going wrong. Does the game detect a collision even though it should not? Or the other way round?
One thing I noticed is that you have the collision check in a for loop (over c). Within each loop the last value of "coll" is overwritten, so in fact you only get the collision result with the very last tile: tile[coll_count]
Hey JHB, I fixed up the love for you, the collision should run smoothly now. I'd go into detail about what I fixed, but I'm in a bit of a hurry, sorry!
I hope this helps!
(Oh, I changed/added a few variables in there while I was working, I hope you don't mind)