## [Solved]Need a little bump help

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
H0lyT0ast
Prole
Posts: 2
Joined: Sun Feb 03, 2019 5:44 pm

### [Solved]Need a little bump help

Hi Everyone,

Thank you for taking the time to read my issue.

So i dont really understand bump that well and I seem to be at an impass. I've looked over the bump tutorial over and over. I dont seem to be understanding 2 key aspects.

1. adding, non-player, object to the word
2. moving said object

I think my issue exists in these two statements.

adding non player to the world:

Im not sure if im adding the object correctly in this statement. If I change the world:add to something else the game fails

Code: Select all

if love.keyboard.isDown('space') and canshoot then
newBullet = {style = 'line',x=player.x+(player.width/2), y = player.y,width = bullets.width,segments = bullets.segments }
table.insert(bullets,newBullet)
canshoot = false
canshootTimer = canshootTimerMax
bulletCount = bulletCount + 1
end
Moving the bullet: I think im moving correctly, but when I added some collision detection nothing happened.

Code: Select all

	for i, bullet in ipairs(bullets) do
bullet.y = bullet.y - (250 * dt)
world:move(newBullet, 0,newBullet.y - (250*dt))
if bullet.y < 0   then
table.remove(bullets,i)
bulletCount = bulletCount - 1
end
end

If someone could help me out, I would really appriciate it. I really like Love2d but im just new and dont see my issue yet.
Attachments
main.lua
Last edited by H0lyT0ast on Sun Feb 10, 2019 8:18 pm, edited 1 time in total.

pgimeno
Party member
Posts: 1531
Joined: Sun Oct 18, 2015 2:58 pm

### Re: Need a little bump help

Not sure what you expected to happen, but you don't do anything with the return values of world:move(), which are crucial in bump.

Code: Select all

bullet.x, bullet.y, collisions = world:move(bullet, bullet.x, bullet.y)

Now, your bullet spawns right at the player. Making it spawn a bit above the player makes it not hit the player, and you don't need to mess with filters. Otherwise you would need to check what the bullet collided with, and ignore the collision when it's with the player.

Once that's fixed, you can just check if #collisions == 0 and if not, remove the bullet, as that means it hit something.
Thrust II Reloaded - GifLoad for Löve - GSpöt GUI - My NotABug.org repositories - portland (mobile orientation)
The MS-Github repositories I had have been closed after the acquisition announcement and will be removed in the near future.

H0lyT0ast
Prole
Posts: 2
Joined: Sun Feb 03, 2019 5:44 pm

### Re: Need a little bump help

Thank you, I got it working now.

I was under the impression that when calling the world:move() it needed to be the table name i added. so in this case i was erroneously moving newBullet causing a heap of trouble.

Thanks for clarifying.

### Who is online

Users browsing this forum: Google [Bot] and 4 guests