stationary bullets
This commit is contained in:
parent
980469d10e
commit
b692e75773
1 changed files with 18 additions and 1 deletions
19
main.lua
19
main.lua
|
|
@ -8,6 +8,18 @@ function love.load()
|
||||||
shipAngle = 0
|
shipAngle = 0
|
||||||
shipSpeedX = 0
|
shipSpeedX = 0
|
||||||
shipSpeedY = 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
|
end
|
||||||
|
|
||||||
function love.update(dt)
|
function love.update(dt)
|
||||||
|
|
@ -36,7 +48,7 @@ function love.draw()
|
||||||
love.graphics.origin()
|
love.graphics.origin()
|
||||||
love.graphics.translate(x * arenaWidth, y * arenaHeight)
|
love.graphics.translate(x * arenaWidth, y * arenaHeight)
|
||||||
love.graphics.setColor(0, 0, 1)
|
love.graphics.setColor(0, 0, 1)
|
||||||
love.graphics.circle('fill', shipX, shipY, 30)
|
love.graphics.circle('fill', shipX, shipY, shipRadius)
|
||||||
local shipCircleDistance = 20
|
local shipCircleDistance = 20
|
||||||
love.graphics.setColor(0, 1, 1)
|
love.graphics.setColor(0, 1, 1)
|
||||||
love.graphics.circle(
|
love.graphics.circle(
|
||||||
|
|
@ -45,6 +57,11 @@ function love.draw()
|
||||||
shipY + math.sin(shipAngle) * shipCircleDistance,
|
shipY + math.sin(shipAngle) * shipCircleDistance,
|
||||||
5
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue