Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package
- {
- import net.flashpunk.Entity;
- import net.flashpunk.utils.Input;
- import net.flashpunk.utils.Key
- import net.flashpunk.graphics.Image;
- import net.flashpunk.FP;
- /**
- * ...
- * @author fyre
- */
- public class MyEnemy extends Entity
- {
- private var dirChangeDelay:int;
- private var destx:int;
- private var desty:int;
- [Embed(source = 'assets/enemy.png')] private const ENEMY1:Class;
- public function MyEnemy()
- {
- graphic = new Image(ENEMY1);
- setHitbox(8, 8);
- dirChangeDelay = FP.random * 100;
- x = y = 500;
- }
- override public function update():void
- {
- trace(dirChangeDelay);
- if (dirChangeDelay <= 0)
- {
- destx = (FP.random * 792);
- desty = (FP.random * 592);
- dirChangeDelay = FP.random * 100;
- }
- moveTowards(destx, desty, 2);
- dirChangeDelay -= 1;
- }
- }
- }
Add Comment
Please, Sign In to add comment