## [Bump Physics] How to use this?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
ilovelove2019
Citizen
Posts: 78
Joined: Wed Sep 11, 2019 10:38 am

### [Bump Physics] How to use this?

Hello everyone! I'm making a game and I am using Bump library. When reading the tutorial, I think it is suitable for me. But I get this small problem, and I think it's easy with pro like you.
This is some code in tutorial:

Code: Select all

function movePlayer(player, dt)
local goalX, goalY = player.vx * dt, player.vy * dt
local actualX, actualY, cols, len = world:move(player, goalX, goalY, playerFilter)
player.x, player.y = actualX, actualY
for i=1,len do
local other = cols[i].other
if other.isCoin then
takeCoin(other)
elseif other.isExit then
changeLevel()
elseif other.isSpring then
highJump()
end
end
end
I don't know how to use this: other.isCoin, other.isExit, other.isSpring. How to identify it? We need to make that function? Or we needn't?
Or it have some method to know it is coin or exit,... in the tutorial but I miss it? Let you check it out: https://github.com/kikito/bump.lua . Help me please! Thank you so much. Hope you will help me soon soon! I am so excited to make a game with bump as soon as possible. Sorry because my English is not good. My bad. My bad.

raidho36
Party member
Posts: 2055
Joined: Mon Jun 17, 2013 12:00 pm

### Re: [Bump Physics] How to use this?

The "other.isCoin" etc. is simply a flag defined in the table, set to true or false. The "other" is set to whichever other table (object) is in collision with current object.

So you have some object that's a coin, and it has "self.isCoin = true" in it. Same for an object that's an exit and an object that's a spring.

The "cols" table comes from elsewhere and I assume it contains list of collisions between player object and everything else.

joedono
Prole
Posts: 40
Joined: Mon Mar 04, 2013 6:58 pm

### Re: [Bump Physics] How to use this?

The "other" object is whatever object/table you added to bump when you created the objects in the world. You can assume it'll be whatever you added.

My approach is that any object I add to Bump has a "type" that's a simple string. I'm really consistent about this, so I know that anything I can collide with has this "type" property. I check that instead of "isCoin" or "isExit" and act on the collisions based on that instead.

ilovelove2019
Citizen
Posts: 78
Joined: Wed Sep 11, 2019 10:38 am

### Re: [Bump Physics] How to use this?

raidho36 wrote:
Thu Sep 19, 2019 1:40 pm
The "other.isCoin" etc. is simply a flag defined in the table, set to true or false. The "other" is set to whichever other table (object) is in collision with current object.

So you have some object that's a coin, and it has "self.isCoin = true" in it. Same for an object that's an exit and an object that's a spring.

The "cols" table comes from elsewhere and I assume it contains list of collisions between player object and everything else.
Oh! I understand it now! Thanks you so much. It is a smart way. "self.isCoin"! Thank you so much!

ilovelove2019
Citizen
Posts: 78
Joined: Wed Sep 11, 2019 10:38 am

### Re: [Bump Physics] How to use this?

joedono wrote:
Thu Sep 19, 2019 2:03 pm
The "other" object is whatever object/table you added to bump when you created the objects in the world. You can assume it'll be whatever you added.

My approach is that any object I add to Bump has a "type" that's a simple string. I'm really consistent about this, so I know that anything I can collide with has this "type" property. I check that instead of "isCoin" or "isExit" and act on the collisions based on that instead.
Thank for your advice. It is a good way too. But I think it not suitable for a noob like me LOL. Thank you so much.

ilovelove2019
Citizen
Posts: 78
Joined: Wed Sep 11, 2019 10:38 am

Problem Solved.

### Who is online

Users browsing this forum: zorg and 10 guests