My car is moving on a maze.
The movement of car is through Arrow keys.
**I have to calculate KM. **i.e., the distance travelled.
Current frame rate is 12 and 1km =40px
Please help.
Here is the script
onClipEvent (enterFrame) {
with (_root.car) {
if (Key.isDown(40)) {
_y = _y+3;
}
// end if
if (Key.isDown(38)) {
_y = _y-3;
}
// end if
if (Key.isDown(37)) {
_x = _x-3;
}
// end if
if (Key.isDown(39)) {
_x = _x+3;
}
// end if
// end if
if (walls.hitTest(getBounds(_root).xMax, _y, true)) {
_x = _x-3;
}
// end if
if (walls.hitTest(getBounds(_root).xMin, _y, true)) {
_x = _x+3;
}
// end if
if (walls.hitTest(_x, getBounds(_root).yMax, true)) {
_y = _y-3;
}
// end if
if (walls.hitTest(_x, getBounds(_root).yMin, true)) {
_y = _y+3;
}
// end if
if (_root.goal.hitTest(_x, getBounds(_root).yMax, true)) {
_root.gotoAndStop(3);
}
// end if
}
// End of with
}