|
1 | | -const FLEE_DISTANCE = 300; |
| 1 | +const FLEE_DISTANCE = 300 |
2 | 2 |
|
3 | 3 | export class Puppy { |
4 | 4 | constructor(k, WALL_THICKNESS, player, playerSpeed) { |
@@ -37,23 +37,23 @@ export class Puppy { |
37 | 37 |
|
38 | 38 | respawn(position) { |
39 | 39 | if (position) { |
40 | | - this.gameObject.pos = position; |
| 40 | + this.gameObject.pos = position |
41 | 41 | } else { |
42 | | - // Fallback to random position if no specific one is given |
43 | | - this.gameObject.pos = this.k.rand( |
44 | | - this.k.vec2(this.WALL_THICKNESS, this.WALL_THICKNESS), |
45 | | - this.k.vec2( |
46 | | - this.k.width() - this.WALL_THICKNESS - this.gameObject.width, |
47 | | - this.k.height() - this.WALL_THICKNESS - this.gameObject.height |
48 | | - ) |
| 42 | + // Fallback to random position if no specific one is given |
| 43 | + this.gameObject.pos = this.k.rand( |
| 44 | + this.k.vec2(this.WALL_THICKNESS, this.WALL_THICKNESS), |
| 45 | + this.k.vec2( |
| 46 | + this.k.width() - this.WALL_THICKNESS - this.gameObject.width, |
| 47 | + this.k.height() - this.WALL_THICKNESS - this.gameObject.height |
49 | 48 | ) |
| 49 | + ) |
50 | 50 | } |
51 | 51 | } |
52 | 52 |
|
53 | 53 | update() { |
54 | 54 | const dirToPlayer = this.player.pos.sub(this.gameObject.pos) |
55 | 55 | const dist = dirToPlayer.len() |
56 | | - let currentSpeed = this.wanderSpeed; |
| 56 | + let currentSpeed = this.wanderSpeed |
57 | 57 |
|
58 | 58 | if (dist < FLEE_DISTANCE) { |
59 | 59 | this.direction = dirToPlayer.scale(-1).unit() |
|
0 commit comments