Page 4 of 6

Re: How to use bump.lua

Posted: Sat Mar 21, 2015 9:44 pm
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?

Re: How to use bump.lua

Posted: Sun Mar 22, 2015 12:01 am
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

Re: How to use bump.lua

Posted: Sun Mar 22, 2015 6:53 pm
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

Re: How to use bump.lua

Posted: Sun Mar 22, 2015 7:00 pm
by Kingdaro
Yeah, you can use world:update().

Code: Select all

-- teleport the player without collision
world:update(player, player.x, player.y)

Re: How to use bump.lua

Posted: Tue Mar 24, 2015 7:25 pm
by Bindie
Thank you very much.

Re: How to use bump.lua

Posted: Sun Apr 05, 2015 12:32 pm
by Bindie
Bump.lua, love it!

Re: How to use bump.lua

Posted: Tue May 12, 2015 1:25 pm
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.

Re: How to use bump.lua

Posted: Tue May 12, 2015 2:20 pm
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.

Re: How to use bump.lua

Posted: Tue May 12, 2015 6:31 pm
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.

Re: How to use bump.lua

Posted: Tue May 12, 2015 7:52 pm
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 5549 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.