Hi everyone, I'm working on a simple top-down tile based dungeon crawling game (think the original Legend of Zelda). I'm trying to use the bump.lua (https://github.com/kikito/bump.lua) library to handle collision detection, although I encountered this exact same problem using the basic bounding box function (https://love2d.org/wiki/BoundingBox.lua) as well.
Basically, the tile with collision in the world seems to have its collision rectangle extended infinitely above and to the left of it. That is, if I try to move my player above the tile or to the left of it, it will still collide on nothing and prevent me from moving. I really have no idea what might be causing this, but you can see the entire source on GitHub here: https://github.com/darkfire613/undercity
Any wisdom on this would be greatly appreciated!
Collision detection: collision box extends up and left of box
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Prole
- Posts: 2
- Joined: Fri Apr 29, 2016 5:26 pm
Re: Collision detection: collision box extends up and left of box
One thing that immediately stands out to me is this line
What it's doing is setting the width and height of the players collision box to to the width and height of the window. That's what love.graphics.getWidth/Height does. I believe what you wanted to do is get the width and height of player.img.
For that you would do
Code: Select all
world:add(Player, Player.x, Player.y, love.graphics.getWidth(Player.img), love.graphics.getHeight(Player.img))
For that you would do
Code: Select all
world:add(Player, Player.x, Player.y, Player.img:getWidth(), Player.img:getHeight())
-
- Prole
- Posts: 2
- Joined: Fri Apr 29, 2016 5:26 pm
Re: Collision detection: collision box extends up and left of box
Thank you so much, that took care of it!
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 6 guests