diff --git a/main.lua b/main.lua index ecb4975..4687779 100644 --- a/main.lua +++ b/main.lua @@ -8,6 +8,18 @@ function love.load() shipAngle = 0 shipSpeedX = 0 shipSpeedY = 0 + shipRadius = 30 + + bullets = {} +end + +function love.keypressed(key) + if key == 's' then + table.insert(bullets, { + x = shipX + math.cos(shipAngle) * shipRadius, + y = shipY + math.sin(shipAngle) * shipRadius, + }) + end end function love.update(dt) @@ -36,7 +48,7 @@ function love.draw() love.graphics.origin() love.graphics.translate(x * arenaWidth, y * arenaHeight) love.graphics.setColor(0, 0, 1) - love.graphics.circle('fill', shipX, shipY, 30) + love.graphics.circle('fill', shipX, shipY, shipRadius) local shipCircleDistance = 20 love.graphics.setColor(0, 1, 1) love.graphics.circle( @@ -45,6 +57,11 @@ function love.draw() shipY + math.sin(shipAngle) * shipCircleDistance, 5 ) + + for bulletIndex, bullet in ipairs(bullets) do + love.graphics.setColor(0, 1, 0) + love.graphics.circle('fill', bullet.x, bullet.y, 5) + end end end