I'm cloning centipede, I'm having a problem with state machine I would like to move left then down the move right, then move down, then move left
private function moveIt(e:TimerEvent):void
{
for (var i:int = 1; i < 5; ++i)
{
if (m_nodes[i].y < 40 && m_nodes[i].x < 40)
{
m_nodes[i].current_dir = Element.DOWN;
}
else if (m_nodes[i].y > 560 && m_nodes[i].x > 40)
{
m_nodes[i].current_dir = Element.DOWN;
}
else if (m_nodes[i].x > 700 - 10)
{
m_nodes[i].current_dir = Element.DOWN;
}
if (m_nodes[i].current_dir == Element.RIGHT)
{
m_nodes[i].vx = 5;
m_nodes[i].vy = 0;
}
else if (m_nodes[i].current_dir == Element.LEFT)
{
m_nodes[i].vx = -5;
m_nodes[i].vy = 0;
}
else if (m_nodes[i].current_dir == Element.DOWN)
{
m_nodes[i].current_dir = Element.RIGHT;
m_nodes[i].vx = 0;
m_nodes[i].vy = 5;
}
m_nodes[i].x += m_nodes[i].vx;
m_nodes[i].y += m_nodes[i].vy;
}
}