[game] Collision detection
This commit is contained in:
parent
2388acaa94
commit
38f5f95827
6 changed files with 511 additions and 242 deletions
20
game/main.ts
20
game/main.ts
|
|
@ -36,16 +36,14 @@ function load_assets() {
|
|||
|
||||
// TODO: SPAWN ACTORS BASED ON LEVEL.
|
||||
actors.length = 0;
|
||||
for (const entity_layer of level.entity_layers) {
|
||||
for (const entity of entity_layer.entities) {
|
||||
if (is_actor_type(entity.type)) {
|
||||
const [x, y] = entity.px;
|
||||
const [w, h] = entity.bounds;
|
||||
const props = new_actor_props(entity.id, new_v2(x, y), new_v2(w, h));
|
||||
actors.push(spawn_actor(entity.type, props));
|
||||
} else {
|
||||
print("WARNING: Ignoring entity of type", entity.type);
|
||||
}
|
||||
for (const entity of level.entities) {
|
||||
if (is_actor_type(entity.type)) {
|
||||
const [x, y] = entity.px;
|
||||
const [w, _] = entity.bounds;
|
||||
const props = new_actor_props(entity.id, new_v2(x, y), w);
|
||||
actors.push(spawn_actor(entity.type, props));
|
||||
} else {
|
||||
print("WARNING: Ignoring entity of type", entity.type);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -91,7 +89,7 @@ export function update() {
|
|||
}
|
||||
|
||||
for (const actor of actors) {
|
||||
actor.update_physics();
|
||||
actor.update_physics(level);
|
||||
}
|
||||
|
||||
// TODO: Bonks
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue