How to use bump.lua

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.
Bindie
Party member
Posts: 151
Joined: Fri Jan 23, 2015 1:29 pm

Re: How to use bump.lua

Post by Bindie »

I'm trouble-shooting why my player moves where there's supposed to be no rectangles. If I have a world, and my player.x and player.y, is there a smooth way to trouble-shoot exactly which rectangle he is bumping into? Of course there is a way, but how?
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: How to use bump.lua

Post by kikito »

Bindie wrote:I'm trouble-shooting why my player moves where there's supposed to be no rectangles. If I have a world, and my player.x and player.y, is there a smooth way to trouble-shoot exactly which rectangle he is bumping into? Of course there is a way, but how?
All the information about the collisions, including with which rectangle each collision happened, is on the 'cols' variable, returned by world:move and world:check (third returned value).

Code: Select all

local actualX, actualY, cols, len = world:move(...)
You can find a description about each item in cols here: https://github.com/kikito/bump.lua#collision-info
When I write def I mean function.
Bindie
Party member
Posts: 151
Joined: Fri Jan 23, 2015 1:29 pm

Re: How to use bump.lua

Post by Bindie »

Cool. It seems when I try to teleport my player to tele_x and tele_y, because it's walls in the way bump.lua somehow thinks there is walls in the way to teleport the player. The room is in the middle of a big base with lots of colliding tiles around (walls), so there is walls in the way.

Can I bypass this collision checking somehow so I can teleport my player without bumping into colliding tiles?

Basically this is my code:

Code: Select all

if love.keyboard.isDown(" ") then

player.x = tele_x
player.y = tele_y

end

-- Player collision check

if player.Current_station ~= nil then

		for i,v in ipairs(Universe) do

			if v.x == player.Current_Station.x and v.y == player.Current_Station.y then

				local newX, newY, cols, len = v.world:move(player, player.x, player.y)
				player.x, player.y = newX, newY
				print(newX, newY, cols, len)

			end

		end

	end
end
User avatar
Kingdaro
Party member
Posts: 395
Joined: Sun Jul 18, 2010 3:08 am

Re: How to use bump.lua

Post by Kingdaro »

Yeah, you can use world:update().

Code: Select all

-- teleport the player without collision
world:update(player, player.x, player.y)
Bindie
Party member
Posts: 151
Joined: Fri Jan 23, 2015 1:29 pm

Re: How to use bump.lua

Post by Bindie »

Thank you very much.
Bindie
Party member
Posts: 151
Joined: Fri Jan 23, 2015 1:29 pm

Re: How to use bump.lua

Post by Bindie »

Bump.lua, love it!
Bindie
Party member
Posts: 151
Joined: Fri Jan 23, 2015 1:29 pm

Re: How to use bump.lua

Post by Bindie »

Hey, in my little bomberman clone the players are the same tilesize as the map. When I move into a free space, the space is narrow. Is there some precision raising way when trying to get into a "L-free space":

Code: Select all

x.p.x
x.|.x
x.|.x
x.-->
xxxx

-- p = player with medium speed trying to get into a L-"free space".
Right now the player misses when trying to turn into the little space.
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: How to use bump.lua

Post by kikito »

The immediate solution I can think of is make your player slightly smaller: instead of making him 32x32, try 31.99x31.99. The difference should not be noticeable, but it should fix the issue.

Other than that, please upload a .love displaying the problem, so I can give it a look.
When I write def I mean function.
Bindie
Party member
Posts: 151
Joined: Fri Jan 23, 2015 1:29 pm

Re: How to use bump.lua

Post by Bindie »

Sure, it's when you press right key first, then try to move up and down.

Easter egg: Turn the file name inverted horizontal.
Attachments
powp6Lw9u.love
(182.15 KiB) Downloaded 208 times
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: How to use bump.lua

Post by kikito »

I managed to get to the left between to columns (attaching screenshot)
Screen Shot 2015-05-12 at 21.42.32 .png
Screen Shot 2015-05-12 at 21.42.32 .png (9.34 KiB) Viewed 6098 times
Your problem is not bump-specific. You would have had it with any other collision library, even one made by yourself.

The problem here is that your players are so big, they have to be exactly at the right coordinate, or they can't enter a corridor. Imagine that a corridor must be entered at y=164. If the players are at y=163.99, they will not fit through the corridor (their "top" will "hit the corridor wall"). Similarly, if the player is at y=164.01, their bottom will hit the bottom wall.

The other thing is that getting exactly to 164 using a dt-based movement is almost impossible. Try printing out the coords of the player to see what I mean. With dt alone, you almost always have decimals.

There are two ways to solve this: either you make your characters smaller (at least 2/3 of a tile), or you make the movement help the player. There are lots of ways to do this. You could, for example, only allow integer coordinates in your players (so they can be in 163 or 164, but never in 163.819283). You can also try a combination of both.
When I write def I mean function.
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 2 guests