zigzag enemies
Posted: Sun Dec 30, 2018 6:11 pm
I'm making my first game in löve and having my first try to lua and I did a little topdown shooter based on http://www.osmstudios.com/tutorials/lov ... the-basics.
So far It has been a good experience, but now I'm having issues trying to make the enemies "zigzag" on the screen.
Here's what I tried so far:
Any tips of how can I make the enemies to move?
So far It has been a good experience, but now I'm having issues trying to make the enemies "zigzag" on the screen.
Here's what I tried so far:
Code: Select all
for i, enemy in ipairs(enemies) do
enemy.y = enemy.y + (enemySpeed * dt)
enemy.spin = enemy.spin + (createEnemyTimerMax/100)
enemy.x = enemy.x + ((math.tan(math.rad(enemy.spin))*100) * dt)
if enemy.spin >= 360 then
enemy.spin = 0
end
if enemy.y > 530 then
table.remove(enemies, i)
end
end