From 093b9a7ece818ad91e82c287a88f0bb01608624a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juhani=20Krekel=C3=A4?= Date: Sat, 3 Jun 2023 22:30:03 +0300 Subject: [PATCH] Render enemies as pentagons --- bundle/main.lua | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/bundle/main.lua b/bundle/main.lua index 27e59ff..2f4ce66 100644 --- a/bundle/main.lua +++ b/bundle/main.lua @@ -154,6 +154,7 @@ function spawnEnemy(x, y) x = x, y = y, until_shoot = enemy_min_shoot + math.random() * (enemy_max_shoot - enemy_min_shoot), + angle = math.random() * 2 * math.pi, alive = true }) end @@ -449,9 +450,18 @@ end function drawEnemies() for _, enemy in ipairs(enemies) do love.graphics.setColor(0.7, 0.5, 1) - local x, y = toScreenCoordinates(enemy.x, enemy.y) - local radius = toScreenSize(enemy_radius) - love.graphics.circle('fill', x, y, radius) + + local fifth = 2 * math.pi / 5 + local points = {} + for i = 0, 4 do + local x = enemy.x + math.cos(i * fifth + enemy.angle) * enemy_radius + local y = enemy.y + math.sin(i * fifth + enemy.angle) * enemy_radius + local x, y = toScreenCoordinates(x, y) + table.insert(points, x) + table.insert(points, y) + end + + love.graphics.polygon('fill', points) end end