shoot every 4 seconds instead of on input

This commit is contained in:
yuki 2025-11-11 20:27:40 -03:00
parent 4d2874c6be
commit d56b42e017

View file

@ -27,6 +27,8 @@ function Player:new(area, x, y, opts)
self.max_v = 100
-- player acceleration
self.a = 100
self.timer:every(4, function() self:shoot() end)
end
function Player:update(dt)
@ -36,7 +38,6 @@ function Player:update(dt)
-- controls
if input:down('left') then self.r = self.r - self.rv*dt end
if input:down('right') then self.r = self.r + self.rv*dt end
if input:pressed('action') then self:shoot() end
-- update velocity
self.v = math.min(self.v + self.a*dt, self.max_v)