Skip to content

Commit

Permalink
Different enemies working and animated
Browse files Browse the repository at this point in the history
Signed-off-by: Ole Herman Schumacher Elgesem <[email protected]>
  • Loading branch information
olehermanse committed Feb 23, 2025
1 parent 59075c1 commit f952f35
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 5 deletions.
33 changes: 33 additions & 0 deletions src/frontend/painter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,39 @@ const SPRITESHEET = {
frame(3, 350),
], false),
),
Robe: new SpriteMetadata(
4,
12,
4,
new AnimationData([
frame(0, 350),
frame(1, 350),
frame(2, 350),
frame(3, 350),
], false),
),
Golem: new SpriteMetadata(
4,
8,
4,
new AnimationData([
frame(0, 350),
frame(1, 350),
frame(2, 350),
frame(3, 350),
], false),
),
Monk: new SpriteMetadata(
4,
4,
4,
new AnimationData([
frame(0, 350),
frame(1, 350),
frame(2, 350),
frame(3, 350),
], false),
),
Fog: new SpriteMetadata(5, 0, 5),
Attack: new SpriteMetadata(6, 0, 1),
Heal: new SpriteMetadata(6, 1, 1),
Expand Down
5 changes: 1 addition & 4 deletions src/libtrpg/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -886,10 +886,7 @@ export class Enemy extends Creature {
}

override on_light_up(): void {
if (this.name === "Skeleton") {
console.log("Found skeleton to light up");
this.start_animation();
}
this.start_animation();
}
}

Expand Down
11 changes: 10 additions & 1 deletion src/libtrpg/rooms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,16 @@ function _generic_room(zone: Zone) {
pos = cr(randint(1, zone.columns - 2), randint(2, zone.rows - 3));
}
const level = 1 + Math.max(...[zone.pos.c, zone.pos.r].map(Math.abs));
const entity = new Enemy("Skeleton", level, pos, zone, zone.game);
let entity;
if (level == 2){
entity = new Enemy("Skeleton", level, pos, zone, zone.game);
} else if (level == 3){
entity = new Enemy("Robe", level, pos, zone, zone.game);
} else if (level == 4){
entity = new Enemy("Golem", level, pos, zone, zone.game);
} else {
entity = new Enemy("Monk", level, pos, zone, zone.game);
}
if (entity.cr.c > zone.columns / 2) {
entity.reversed = true;
}
Expand Down

0 comments on commit f952f35

Please sign in to comment.