I finally figured out collisions with bump.lua, but now im having trouble with the resolution of the collisions. I have it so my player item collides with the floor and walls, but i want to make it so if the ceiling collides with the player, the game quits with love.event.quit().
here is the project so far.
Is there a way to check if my player collides with my ceiling and quit the game int hat event, but if it hits the floor or wall it just collides normally? thank you.
Collision resolution with bump.lua
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Collision resolution with bump.lua
- Attachments
-
- donttouchtheceiling.love
- (7.22 KiB) Downloaded 140 times
I'M SORRY, BUT DOES REALLY BOLD TEXT BOTHER YOU
Re: Collision resolution with bump.lua
If the normal vector is {x = 0, y = 1} then the collision came from above the player.
Re: Collision resolution with bump.lua
I had some time to sit down and write the code for what I meant. You could do this at line 43 in your player.lua to see if any of the collisions came from above the player:
The normal vector represents the direction from which the other tile collided with the object you're moving in the bump world.
Code: Select all
local cols
player.x, player.y, cols = world:move(player, player.x + player.dx, player.y + player.dy)
for _, col in ipairs(cols) do
if col.normal.y >= 1 then
love.event.quit()
end
end
Re: Collision resolution with bump.lua
Ah, this helps. Thank you very much!palmettos wrote:I had some time to sit down and write the code for what I meant. You could do this at line 43 in your player.lua to see if any of the collisions came from above the player:
The normal vector represents the direction from which the other tile collided with the object you're moving in the bump world.Code: Select all
local cols player.x, player.y, cols = world:move(player, player.x + player.dx, player.y + player.dy) for _, col in ipairs(cols) do if col.normal.y >= 1 then love.event.quit() end end
I'M SORRY, BUT DOES REALLY BOLD TEXT BOTHER YOU
Who is online
Users browsing this forum: No registered users and 4 guests