diff --git a/main.lua b/main.lua index 50c97cc..f19bb1d 100644 --- a/main.lua +++ b/main.lua @@ -13,6 +13,24 @@ function love.load() bullets = {} bulletTimerLimit = 0.5 bulletTimer = bulletTimerLimit + + asteroids = { + { + x = 100, + y = 100, + }, + { + x = arenaWidth - 100, + y = 100, + }, + { + x = arenaWidth / 2, + y = arenaHeight - 100, + } + } + for asteroidIndex, asteroid in ipairs(asteroids) do + asteroid.angle = love.math.random() * (2 * math.pi) + end end function love.update(dt) @@ -58,6 +76,12 @@ function love.update(dt) }) end end + + for asteroidIndex, asteroid in ipairs(asteroids) do + local asteroidSpeed = 20 + asteroid.x = (asteroid.x + math.cos(asteroid.angle) * asteroidSpeed * dt) % arenaWidth + asteroid.y = (asteroid.y + math.cos(asteroid.angle) * asteroidSpeed * dt) % arenaHeight + end end function love.draw() @@ -80,6 +104,11 @@ function love.draw() love.graphics.setColor(0, 1, 0) love.graphics.circle('fill', bullet.x, bullet.y, 5) end + + for asteroidIndex, asteroid in ipairs(asteroids) do + love.graphics.setColor(1, 1, 0) + love.graphics.circle('fill', asteroid.x, asteroid.y, 80) + end end end