Koden er:
i = 1;
setInterval(function(){
_root.attachMovie("test", "test", 1);
_root.test._x = _x;
_root.test._y = _y;
_root.test._rotation = Math.atan((_root.test._y-_root.player._y)/(_root.test._x-_root.player._x))*180/Math.PI-90;
if (_root.test._x < _root.player._x) {
_root.test._rotation += 180;
}
while (!_root.level.hitTest(_root.test._x, _root.test._y, 1) && _root.test._x > 0 && _root.test._x < 800 && _root.test._y > 0 && _root.test._y < 600) {
if (_root.player.hitTest(_root.test._x, _root.test._y, 1)) {
_rotation = Math.atan((_y-_root.player._y)/(_x-_root.player._x))*180/Math.PI-90;
if (_x < _root.player._x) {
_rotation += 180;
}
_root.attachMovie("shot", "shot_enemy"+i, i+200);
_root["shot_enemy"+i]._x = _x;
_root["shot_enemy"+i]._y = _y;
_root["shot_enemy"+i]._rotation = _rotation;
i ++;
}
_root.test._x += Math.sin(_root.test._rotation*(Math.PI/180));
_root.test._y += Math.cos(_root.test._rotation*(Math.PI/180))*-1;
}
_root.test.removeMovieClip();
}, 100);
(
http://eksperten.dk/spm/672936)