Hi LÖVElies,
So I've been working on a game for a few weeks and and it has to have grown to the point where bump.lua might be the best collision manager for me. So lately I've been trying to update the code to make use of bump.
I've stripped down my code to help with testing/integrating this, so hopefully it can make sense to you. Right now the player character - the placeholder Crusader sprite - can walk around and bump into rectangles. If you hit the 'spacebar' key, it should generate a homing sprite that I would like to have destroyed on impact with the player character. That is, destroy the projectile, not the player character.
I can destroy the sprite if my crusader walks into the projectile, but if he/she stands still, the two will just slide up to each other, and the projectile will not destroy itself.
I think it would help to change the collision type to touch instead of slide, but I can't seem to figure it out in the bump documentation. Pardon the noobness! Does this make sense? Care to take a look? I've attached the code and it should work.
Using BUMP, need a little help. Should be easy?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Prole
- Posts: 14
- Joined: Sat Apr 25, 2015 7:55 pm
Using BUMP, need a little help. Should be easy?
- Attachments
-
- crusaders_forum_hiccupface.love
- bump test
- (17.43 KiB) Downloaded 99 times
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: Using BUMP, need a little help. Should be easy?
There is some confusion on this code.
The variable lobsters is sometimes used as if it was a list of objects. For example here:
But other times it is used as a single object. For example on its declaration:
You have to remove this confusion. You can't have both a list of items and a single item on the same variable. That's the first thing you have to decide (I recommend using lobsters as a list - that means it would start empty, and you would add a new lobster to it every time space was pressed).
If you end up using lobsters as a "list of items", you will have to do a loop every time you want to use it. For example, if you want to "draw all the lobsters" you have to do a loop over the lobsters variable, drawing one lobster on every iteration.
Also, you can add a list of items (lobsters) to bump and expect i to know that it is a list. bump does not work like that. You have to enter every lobster individually, calling world:add with a loop. Similarly, to update all the lobsters, you will have to call world:move once for each lobster that you have.
The variable lobsters is sometimes used as if it was a list of objects. For example here:
Code: Select all
for i,newlobster in ipairs(lobsters) do
table.remove(lobsters, i)
end
Code: Select all
local lobsters = {
x = 250,
y = 250,
w = 20,
h = 20,
speed = 30,
img = love.graphics.newImage('enemy.png')
}
If you end up using lobsters as a "list of items", you will have to do a loop every time you want to use it. For example, if you want to "draw all the lobsters" you have to do a loop over the lobsters variable, drawing one lobster on every iteration.
Also, you can add a list of items (lobsters) to bump and expect i to know that it is a list. bump does not work like that. You have to enter every lobster individually, calling world:add with a loop. Similarly, to update all the lobsters, you will have to call world:move once for each lobster that you have.
When I write def I mean function.
-
- Prole
- Posts: 14
- Joined: Sat Apr 25, 2015 7:55 pm
Re: Using BUMP, need a little help. Should be easy?
Thank you Kikito. I appreciate the reply!
Sadly, I think my noob brain can't handle this at the moment, haha. My game is mostly complete and trying to integrate bump into my own mess is more of a headache than I can endure.
In my own game I'm using lists as you suggested, but for the life of me can't seem to be able to get it to work with bump. Damn. I will stick with baby steps for now, as I'm incredibly new to not only LÖVE but also Lua.
Sadly, I think my noob brain can't handle this at the moment, haha. My game is mostly complete and trying to integrate bump into my own mess is more of a headache than I can endure.
In my own game I'm using lists as you suggested, but for the life of me can't seem to be able to get it to work with bump. Damn. I will stick with baby steps for now, as I'm incredibly new to not only LÖVE but also Lua.
Who is online
Users browsing this forum: Amazon [Bot], Bing [Bot], Semrush [Bot] and 10 guests