Code: Select all
--bullet.lua
function Bullet:update(dt)
cd=cd-dt*2
if love.keyboard.isDown('space') and cd<=0 then
cd=cd+1
local vx=0
if facingL then
vx=bullet.spd*-1
else
vx=bullet.spd
end
B=world:newCircleCollider(player.x+35,player.y+30,w*1/2)
B:setMass(0)
B:setLinearVelocity(vx,0)
B:setType('kinematic')
B:setCollisionClass('bullet')
Bullet={x=player.x+15,y=player.y+20,vx=vx,B=B}
table.insert(bullets,Bullet)
cd=math.max(cd,0)
local m=B:getMass()
print(m)
end
for i,v in ipairs(bullets) do
v.x=v.x+v.vx*dt
if v.x<0 or v.x>1550 or v.B:enter('ground')then
table.remove(bullets,i)
v.B:destroy()
end
end
end