autofire
This commit is contained in:
parent
419f858b1b
commit
5e47a5773c
1 changed files with 13 additions and 9 deletions
10
main.lua
10
main.lua
|
|
@ -11,6 +11,8 @@ function love.load()
|
|||
shipRadius = 30
|
||||
|
||||
bullets = {}
|
||||
bulletTimerLimit = 0.5
|
||||
bulletTimer = bulletTimerLimit
|
||||
end
|
||||
|
||||
function love.update(dt)
|
||||
|
|
@ -43,10 +45,11 @@ function love.update(dt)
|
|||
bullet.y = (bullet.y + math.sin(bullet.angle) * bulletSpeed * dt) % arenaHeight
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function love.keypressed(key)
|
||||
if key == 's' then
|
||||
bulletTimer = bulletTimer + dt
|
||||
if love.keyboard.isDown('s') then
|
||||
if bulletTimer >= bulletTimerLimit then
|
||||
bulletTimer = 0
|
||||
table.insert(bullets, {
|
||||
x = shipX + math.cos(shipAngle) * shipRadius,
|
||||
y = shipY + math.sin(shipAngle) * shipRadius,
|
||||
|
|
@ -55,6 +58,7 @@ function love.keypressed(key)
|
|||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function love.draw()
|
||||
for y = -1, 1 do
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue