init
This commit is contained in:
commit
28b026a614
17 changed files with 895 additions and 0 deletions
33
server/entities/enemy.ts
Normal file
33
server/entities/enemy.ts
Normal file
|
@ -0,0 +1,33 @@
|
|||
import { World, WorldEntity } from "../engine.ts";
|
||||
import { v2, Vec2 } from "../../common/utils.ts";
|
||||
import { wait } from "../../common/utils.ts";
|
||||
|
||||
export class Enemy {
|
||||
entity;
|
||||
alive;
|
||||
|
||||
constructor(entity: WorldEntity) {
|
||||
this.entity = entity;
|
||||
this.alive = true;
|
||||
}
|
||||
|
||||
static spawn(world: World, pos: Vec2) {
|
||||
const entity = world.spawn_entity("èé", pos);
|
||||
}
|
||||
|
||||
async spin() {
|
||||
while (this.alive) {
|
||||
await wait(500);
|
||||
const target = this.find_target();
|
||||
}
|
||||
}
|
||||
|
||||
find_target() {
|
||||
const world = this.entity.world;
|
||||
const local_origin = this.entity.position;
|
||||
const found = world.get_entities_in_range(local_origin.sub(v2(3, 3)), local_origin.add(v2(3, 3)));
|
||||
for (const entity of found) {
|
||||
// if (entity.compontents.get())
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue