Skip to content

Commit

Permalink
Add more zombie sprites
Browse files Browse the repository at this point in the history
  • Loading branch information
delasy committed Nov 2, 2024
1 parent 62b0899 commit 17a6942
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 111 deletions.
Binary file added public/entities/zombie-dead.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 0 additions & 44 deletions public/entities/zombie-dead.svg

This file was deleted.

Binary file added public/entities/zombie-idle-frame1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/entities/zombie-idle-frame2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/entities/zombie-idle-frame3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/entities/zombie-idle-frame4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
60 changes: 0 additions & 60 deletions public/entities/zombie-idle.svg

This file was deleted.

27 changes: 21 additions & 6 deletions renderer/Assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ export interface RendererAssets {
landmine: HTMLImageElement | null;
player: HTMLImageElement | null;
rock: HTMLImageElement | null;
zombie: HTMLImageElement | null;
zombieDead: HTMLImageElement | null;
zombieIdleFrame1: HTMLImageElement | null;
zombieIdleFrame2: HTMLImageElement | null;
zombieIdleFrame3: HTMLImageElement | null;
zombieIdleFrame4: HTMLImageElement | null;
zombieWalkingFrame1: HTMLImageElement | null;
zombieWalkingFrame2: HTMLImageElement | null;
zombieWalkingFrame3: HTMLImageElement | null;
Expand All @@ -22,8 +25,11 @@ export const assets: RendererAssets = {
landmine: null,
player: null,
rock: null,
zombie: null,
zombieDead: null,
zombieIdleFrame1: null,
zombieIdleFrame2: null,
zombieIdleFrame3: null,
zombieIdleFrame4: null,
zombieWalkingFrame1: null,
zombieWalkingFrame2: null,
zombieWalkingFrame3: null,
Expand All @@ -43,8 +49,11 @@ export async function loadAssets() {
landmine,
player,
rock,
zombie,
zombieDead,
zombieIdleFrame1,
zombieIdleFrame2,
zombieIdleFrame3,
zombieIdleFrame4,
zombieWalkingFrame1,
zombieWalkingFrame2,
zombieWalkingFrame3,
Expand All @@ -55,8 +64,11 @@ export async function loadAssets() {
loadAssetImage("/entities/landmine.svg"),
loadAssetImage("/entities/player-attacking.svg"),
loadAssetImage("/entities/rock.svg"),
loadAssetImage("/entities/zombie-idle.svg"),
loadAssetImage("/entities/zombie-dead.svg"),
loadAssetImage("/entities/zombie-dead.png"),
loadAssetImage("/entities/zombie-idle-frame1.png"),
loadAssetImage("/entities/zombie-idle-frame2.png"),
loadAssetImage("/entities/zombie-idle-frame3.png"),
loadAssetImage("/entities/zombie-idle-frame4.png"),
loadAssetImage("/entities/zombie-walking-frame1.png"),
loadAssetImage("/entities/zombie-walking-frame2.png"),
loadAssetImage("/entities/zombie-walking-frame3.png"),
Expand All @@ -69,8 +81,11 @@ export async function loadAssets() {
assets.landmine = landmine;
assets.player = player;
assets.rock = rock;
assets.zombie = zombie;
assets.zombieDead = zombieDead;
assets.zombieIdleFrame1 = zombieIdleFrame1;
assets.zombieIdleFrame2 = zombieIdleFrame2;
assets.zombieIdleFrame3 = zombieIdleFrame3;
assets.zombieIdleFrame4 = zombieIdleFrame4;
assets.zombieWalkingFrame1 = zombieWalkingFrame1;
assets.zombieWalkingFrame2 = zombieWalkingFrame2;
assets.zombieWalkingFrame3 = zombieWalkingFrame3;
Expand Down
20 changes: 19 additions & 1 deletion renderer/Renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export class Renderer {
} else if (entity.hasChange(ChangeType.Walking)) {
return assets.zombieWalkingFrame1;
} else {
return assets.zombie;
return assets.zombieIdleFrame1;
}
}
}
Expand Down Expand Up @@ -307,6 +307,24 @@ export class Renderer {
],
});
}
} else if (entity.getType() === EntityType.Zombie && !entity.dead()) {
if (
assets.zombieIdleFrame2 !== null &&
assets.zombieIdleFrame3 !== null &&
assets.zombieIdleFrame4 !== null
) {
rendererItem.addEffect({
type: RendererEffectType.AssetSwap,
duration: REPLAY_SPEED,
every: REPLAY_SPEED / 4,
startedAt: Date.now(),
steps: [
assets.zombieIdleFrame2,
assets.zombieIdleFrame3,
assets.zombieIdleFrame4,
],
});
}
}

this.items.push(rendererItem);
Expand Down

0 comments on commit 17a6942

Please sign in to comment.