Forum rules
IMPORTANT
This Forum is for Flash related questions ONLY! Do not ask questions about spriting, Game Maker, Photoshop, or anything else not related to Flash.
i need a good enemy AI code
Author |
Message |
tj the hedgehog
Joined: Sat Mar 21, 2009 11:04 pm Posts: 3
|
ok i need a good enemy AI code for flash 8..the code i use only can mak 1 enemy that would be this code
onClipEvent (load) { scale = _xscale; gravity = 0.8; yspeed = 7; xspeed = 5; jumping = 1; xDir = random(3)-1; this.stop(); } onClipEvent (enterFrame) { if (_root.enemy) { if (random(10) == 0) { xDir = random(3)-1; } _x += xDir; } } onClipEvent (enterFrame) { yspeed += gravity; while (_root.ground.hitTest(_x, _y+_height/2, true)) { _root.enemy._y--; _root.enemy.yspeed = 0; _root.enemy.jumping = 0; } if ((!_root.ground.hitTest(_x, _y+_height/2+1, true)) or (yspeed<0)) { _root.enemy._y += yspeed; } else { _root.enemy.yspeed = 0; _root.enemy.jumping = 0; } } onClipEvent (enterFrame) { if (_root.enemy.attack.hitTest(_root.player)) { _root.hp.nextFrame(); } } onClipEvent (enterFrame) { if (this.hitTest(_root.player.attacking.kill)) { _root.enemy.gotoAndStop(3); } }
does anyone know a better code for me to make more enemys?
|
Fri Jul 23, 2010 9:01 am |
|
|
Who is online |
Users browsing this forum: No registered users and 1 guest |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum
|