the other playes now run away from the player on contact

This commit is contained in:
kharhamel 2020-04-12 19:06:31 +02:00
parent 97a55ab66c
commit 05379c8001
4 changed files with 62 additions and 33 deletions

View file

@ -12,34 +12,6 @@ export class Player extends PlayableCaracter{
this.setSize(32, 32); //edit the hitbox to better match the caracter model
}
move(activeEvents: ActiveEventList){
let speed = activeEvents.get(UserInputEvent.SpeedUp) ? 500 : 100;
let haveMove = false;
let direction = null;
if(activeEvents.get(UserInputEvent.MoveUp)){
this.setVelocity(0, -speed)
} else if(activeEvents.get(UserInputEvent.MoveLeft)){
this.setVelocity(-speed, 0)
} else if(activeEvents.get(UserInputEvent.MoveDown)){
this.setVelocity(0, speed)
} else if(activeEvents.get(UserInputEvent.MoveRight)){
this.setVelocity(speed, 0)
} else {
this.setVelocity(0, 0)
}
if (this.body.velocity.x > 0) { //moving right
this.play("right", true);
} else if (this.body.velocity.x < 0) { //moving left
this.anims.playReverse("left", true);
} else if (this.body.velocity.y < 0) { //moving up
this.play("up", true);
} else if (this.body.velocity.y > 0) { //moving down
this.play("down", true);
}
}
stop() {
this.setVelocity(0, 0)
}