57 lines
2.1 KiB
JavaScript
57 lines
2.1 KiB
JavaScript
// Сущности: животные + зомби + новые мобы
|
|
|
|
export class Entity {
|
|
constructor(x, y, w, h) {
|
|
this.x = x;
|
|
this.y = y;
|
|
this.z = 0; // третье измерение: глубина мира
|
|
this.w = w;
|
|
this.h = h;
|
|
this.d = w; // размер по Z
|
|
this.vx = 0;
|
|
this.vy = 0;
|
|
this.vz = 0;
|
|
this.hp = 3;
|
|
this.grounded = false;
|
|
this.inWater = false;
|
|
this.aiT = 0;
|
|
this.dir = 1;
|
|
}
|
|
}
|
|
|
|
export class Pig extends Entity {
|
|
constructor(x, y, z) { super(x, y, 34, 24); this.kind = 'pig'; this.z = z || 0; this.hp = 2; }
|
|
}
|
|
|
|
export class Chicken extends Entity {
|
|
constructor(x, y, z) { super(x, y, 26, 22); this.kind = 'chicken'; this.z = z || 0; this.hp = 1; }
|
|
}
|
|
|
|
export class Zombie extends Entity {
|
|
constructor(x, y, z) { super(x, y, 34, 50); this.kind = 'zombie'; this.z = z || 0; this.hp = 4; this.speed = 80 + Math.random() * 40; }
|
|
}
|
|
|
|
export class Creeper extends Entity {
|
|
constructor(x, y, z) { super(x, y, 34, 50); this.kind = 'creeper'; this.z = z || 0; this.hp = 4; this.speed = 60 + Math.random() * 30; this.fuse = 3.2; }
|
|
}
|
|
|
|
export class Skeleton extends Entity {
|
|
constructor(x, y, z) { super(x, y, 34, 50); this.kind = 'skeleton'; this.z = z || 0; this.hp = 4; this.speed = 70 + Math.random() * 30; this.shootCooldown = 0; }
|
|
}
|
|
|
|
export class Scorpion extends Entity {
|
|
constructor(x, y, z) { super(x, y, 26, 26); this.kind = 'scorpion'; this.z = z || 0; this.hp = 3; this.speed = 90; this.fuse = 0; this.shootCooldown = 0; }
|
|
}
|
|
|
|
export class PolarBear extends Entity {
|
|
constructor(x, y, z) { super(x, y, 40, 34); this.kind = 'polar_bear'; this.z = z || 0; this.hp = 8; this.speed = 50; this.fuse = 0; this.shootCooldown = 2; }
|
|
}
|
|
|
|
export class Slime extends Entity {
|
|
constructor(x, y, z) { super(x, y, 24, 24); this.kind = 'slime'; this.z = z || 0; this.hp = 2; this.speed = 30; this.fuse = 0; this.shootCooldown = 2; }
|
|
}
|
|
|
|
export class Eagle extends Entity {
|
|
constructor(x, y, z) { super(x, y, 30, 22); this.kind = 'eagle'; this.z = z || 0; this.hp = 3; this.speed = 120; this.fuse = 0; this.shootCooldown = 0; }
|
|
}
|