Skip to content

Commit

Permalink
Merge branch 'logan'
Browse files Browse the repository at this point in the history
  • Loading branch information
logan-r committed Jan 28, 2024
2 parents d6c74ab + 89d3e79 commit bdebed6
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 2 deletions.
Binary file added public/audio/Stinger.wav
Binary file not shown.
2 changes: 2 additions & 0 deletions src/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ const SPRITE_PATHS = [
"cactus-burn1.png",
"cactus-burn2.png",
"cactus1.png",
"spider.png",
"cloud.png",
"ground.png",
"gun.png",
Expand Down Expand Up @@ -115,6 +116,7 @@ const loadAssets = async () =>
bang: new ToneAudioBuffer().load("audio/bang.mp3"),
car: new ToneAudioBuffer().load("audio/car.mp3"),
win: new ToneAudioBuffer().load("audio/win.mp3"),
spider: new ToneAudioBuffer().load("audio/Stinger.wav"),
}),
});

Expand Down
2 changes: 1 addition & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ export const SCORE_MULTIPLIER = 0.01; // Modifies rate score increases relative

export const DINO_X_POS = 0;

export const DEBUG = false;
export const DEBUG = true;
39 changes: 39 additions & 0 deletions src/entities/Spider.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { state } from "../state";
import { Entity } from "./Entity";
import { DINO_X_POS, GROUND_LEVEL } from "../constants";
import { sprites } from "../assets";
import { Player } from "tone";
import { playSound } from "../audio";

const SURPRISE_JUMP_VEL = 2000;

const animations = {
default: [sprites["spider.png"]],
};

export class Spider extends Entity {
private sound?: Player;

constructor(x = 0, y = GROUND_LEVEL - 300) {
super(animations, "default");
this.x = x;
this.y = y;
}

update(dt: number) {
this.x -= state.runSpeed * dt;

if (this.x < DINO_X_POS - 100) {
return;
}

if (this.x < DINO_X_POS + 60) {
this.dy = -SURPRISE_JUMP_VEL * dt;
this.y = Math.min(this.y + this.dy, GROUND_LEVEL);
} else if (this.x < DINO_X_POS + 240) {
this.dy = SURPRISE_JUMP_VEL * dt;
this.y = Math.min(this.y + this.dy, GROUND_LEVEL);
this.sound ??= playSound("spider");
}
}
}
3 changes: 2 additions & 1 deletion src/level.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Tornado } from "./entities/Tornado";
import { UFO } from "./entities/UFO";

Check failure on line 7 in src/level.ts

View workflow job for this annotation

GitHub Actions / deploy

'UFO' is declared but its value is never read.
import { Goal } from "./entities/Goal";

Check failure on line 8 in src/level.ts

View workflow job for this annotation

GitHub Actions / deploy

'Goal' is declared but its value is never read.
import { SurpriseCactus } from "./entities/SurpriseCactus";

Check failure on line 9 in src/level.ts

View workflow job for this annotation

GitHub Actions / deploy

'SurpriseCactus' is declared but its value is never read.
import { Spider } from "./entities/Spider";

export const generateLevel = (): Entity[] => {
let x = 0;
Expand All @@ -16,7 +17,7 @@ export const generateLevel = (): Entity[] => {
};

if (DEBUG) {
return [new SurpriseCactus(i(1000))];
return [new Spider(i(1000))];
// return [new SurpriseCactus(i(1000))],
}

Expand Down

0 comments on commit bdebed6

Please sign in to comment.