Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- WHEN CREATING NEW INSTANCE
- var enemy = new Enemy();
- enemy.init(this.mapParser.getPathPositions(), this.mapParser.getStartPosition(), 2, 10);
- this.enemies.push(enemy);
- this.enemiesToCome--;
- AND MY ACTUAL "Enemy" object - move method:
- this.update = function () {
- if(this.direction==0) {
- this.position[1]-=this.speed;
- } else if(this.direction==1) {
- this.position[0]+=this.speed;
- } else if(this.direction==2) {
- this.position[1]+=this.speed;
- } else if(this.direction==3) {
- this.position[0]-=this.speed;
- }
- }
- When the "update" method is called it affects all instances.
Add Comment
Please, Sign In to add comment