let's say I create a rock in my rocks table.
Code: Select all
function love.keypressed( key )
if key == " " then
--newRock(x,y,weight)
table.insert(rocks,newRock(math.abs(love.mouse.getX()), -50,1))
end
end
Code: Select all
function update(dt)
for n, b in ipairs(rocks) do
b:update(dt)
end
end
But I start to run into problems when I want to hit multiple rocks. For some reason the following code will return true only on the last index of the rocks table.
Code: Select all
-- xan is the player
-- some is a debug var so we can see if it's working.
for i,v in ipairs(rocks) do
if checkHit(xan,v) then
some = "you're hitting!"
else
some = "not hitting any"
end
end