Guest User

Untitled

a guest
Jan 22nd, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. WHEN CREATING NEW INSTANCE
  2.  
  3.       var enemy = new Enemy();
  4.       enemy.init(this.mapParser.getPathPositions(), this.mapParser.getStartPosition(), 2, 10);
  5.       this.enemies.push(enemy);
  6.       this.enemiesToCome--;
  7.  
  8. AND MY ACTUAL "Enemy" object - move method:
  9.  
  10.   this.update = function () {
  11.     if(this.direction==0) {
  12.       this.position[1]-=this.speed;
  13.     } else if(this.direction==1) {
  14.       this.position[0]+=this.speed;
  15.     } else if(this.direction==2) {
  16.       this.position[1]+=this.speed;
  17.     } else if(this.direction==3) {
  18.       this.position[0]-=this.speed;
  19.     }
  20.   }
  21.  
  22.  
  23. When the "update" method is called it affects all instances.
Add Comment
Please, Sign In to add comment