Row of enemies
Posted: Sat Jul 20, 2019 12:59 pm
Hi,
i am begginer at Lua and Love2D and i need help. I would like to display 4 rows of enemies (like Space invaders), but i dont know how to do (simply). Thx for advice
i am begginer at Lua and Love2D and i need help. I would like to display 4 rows of enemies (like Space invaders), but i dont know how to do (simply). Thx for advice
Code: Select all
function love.draw()
for i=1, #colors do
if i <= 3 then
rectangle.x = i*35 + (155 * (i-1))
rectangle.y = 35
elseif i > 3 and i <= 6 then
s = i - 3
rectangle.x = s*35 + (155 * (s-1))
rectangle.y = 225
elseif i > 6 and i <= 9 then
t = i - 6
rectangle.x = t*35 + (155 * (t-1))
rectangle.y = 415
else
f = i - 9
rectangle.x = f*35 + (155 * (f-1))
rectangle.y = 605
end
love.graphics.setColor(colors[i])
love.graphics.rectangle("fill", rectangle.x, rectangle.y, 155, 155)
end
end