grechka-game/src/entities/mobs.js

37 lines
1.0 KiB
JavaScript

// Сущности: животные + зомби
export class Entity {
constructor(x, y, w, h) {
this.x = x;
this.y = y;
this.w = w;
this.h = h;
this.vx = 0;
this.vy = 0;
this.hp = 3;
this.grounded = false;
this.inWater = false;
this.aiT = 0;
this.dir = 1;
}
}
export class Pig extends Entity {
constructor(x, y) { super(x, y, 34, 24); this.kind = 'pig'; this.hp = 2; }
}
export class Chicken extends Entity {
constructor(x, y) { super(x, y, 26, 22); this.kind = 'chicken'; this.hp = 1; }
}
export class Zombie extends Entity {
constructor(x, y) { super(x, y, 34, 50); this.kind = 'zombie'; this.hp = 4; this.speed = 80 + Math.random() * 40; }
}
export class Creeper extends Entity {
constructor(x, y) { super(x, y, 34, 50); this.kind = 'creeper'; this.hp = 4; this.speed = 60 + Math.random() * 30; this.fuse = 3.2; }
}
export class Skeleton extends Entity {
constructor(x, y) { super(x, y, 34, 50); this.kind = 'skeleton'; this.hp = 4; this.speed = 70 + Math.random() * 30; this.shootCooldown = 0; }
}