Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Use a loop to both move and attack.
- var step = 12;
- var flip = true;
- var bottom_path = 22;
- var top_path = 34;
- loop {
- var enemy = this.findNearestEnemy(),
- item = this.findNearestItem();
- if (enemy) {
- this.moveXY(enemy.pos.x, enemy.pos.y);
- while (enemy.health > 0) this.attack(enemy);
- } else if (item) {
- destination = item.pos;
- this.moveXY(destination.x, destination.y);
- this.moveXY(this.pos.x, bottom_path);
- } else {
- if (flip) {
- this.moveXY(this.pos.x + 12, bottom_path);
- } else {
- this.moveXY(this.pos.x, top_path);
- }
- flip = !flip;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement