Game Development Reference
In-Depth Information
For each step, the class maintains an array to keep track of each frog. This array
m_track is two dimensional. For example, m_track[3][2] points to the frog on the
fourth step and third from the bottom.
When a frog moves to another spot, we simply move the frog to a different position
array and we also move the frogs on top of it. The position of the frogs after they
move to the new spot may change depending on whether there are any frogs in the
new spot.
When a frog is initially added to the map, it is always added to the spot (step) 0. The
position of each frog is determined in the order they are added. This order of adding
each frog is random.
public function addFrog(frog:Frog):void {
(m_track[0] as Array).push(frog);
frog.step = 0;
frog.pos = ((m_track[0] as Array).length - 1);
m_frogs.push(frog);
addChild(frog);
}
 
Search WWH ::




Custom Search