07. Move Enemies
In _init, update the enemy creation code.
for i=1,10 do
add(enemies,{
sp=17,
m_x=i*16,
m_y=60-i*8,
x=-32,
y=-32,
r=12
})
end
In _update, add code to change the position of the enemies.
function _update()
t=t+1
for e in all(enemies) do
e.x=e.r*sin(t/50)+e.m_x
e.y=e.r*cos(t/50)+e.m_y
end
Hit ctrl-r to run the game. You should see the enemies moving down the screen
in a circular pattern.
The enemies cannot hurt the player and vice versa. Come to think of it, the player doesn't even have any health. Let's explore that next.