theo-michel commited on
Commit
980cbcd
·
verified ·
1 Parent(s): eae3d7c

Upload 49 files

Browse files
Files changed (2) hide show
  1. src/eleven_labs.js +2 -1
  2. src/game_engine.js +31 -23
src/eleven_labs.js CHANGED
@@ -1,4 +1,4 @@
1
- import { SHYGUY_LABEL, SISTER_LABEL, GIRL_LABEL, BAR_LABEL, DJ_LABEL } from "./constants.js";
2
 
3
  export class ElevenLabsClient {
4
  constructor() {
@@ -12,6 +12,7 @@ export class ElevenLabsClient {
12
  [GIRL_LABEL]: "zQPM9vJjjzGxbs457rQj",
13
  [BAR_LABEL]: "XA2bIQ92TabjGbpO2xRr",
14
  [DJ_LABEL]: "T0pkYhIZ7UMOc26gqqeX",
 
15
  };
16
 
17
  async playAudioForCharacter(character, text) {
 
1
+ import { SHYGUY_LABEL, SISTER_LABEL, GIRL_LABEL, BAR_LABEL, DJ_LABEL, WINGMAN_LABEL } from "./constants.js";
2
 
3
  export class ElevenLabsClient {
4
  constructor() {
 
12
  [GIRL_LABEL]: "zQPM9vJjjzGxbs457rQj",
13
  [BAR_LABEL]: "XA2bIQ92TabjGbpO2xRr",
14
  [DJ_LABEL]: "T0pkYhIZ7UMOc26gqqeX",
15
+ [WINGMAN_LABEL]: "XA2bIQ92TabjGbpO2xRr",
16
  };
17
 
18
  async playAudioForCharacter(character, text) {
src/game_engine.js CHANGED
@@ -2,9 +2,9 @@ import { BAR_LABEL, DJ_LABEL, EXIT_LABEL, GIRL_LABEL, SISTER_LABEL, WINGMAN_LABE
2
  import { nameToLabel } from "./story_engine.js";
3
 
4
  const WINGMAN_SPEED = 5;
5
- const SHYGUY_SPEED = 0.5;
6
 
7
- const IS_DEBUG = true;
8
 
9
  class SpriteEntity {
10
  constructor(x0, y0, imageSrc, speed = 0, width = 24, height = 64, frameRate = 8, frameCount = 1) {
@@ -250,13 +250,13 @@ export class GameEngine {
250
  this.introView = document.getElementById("introView");
251
  this.startGameBtn = document.getElementById("startGameBtn");
252
 
253
- this.backgroundMusic = new Audio('assets/assets/tiny-steps-danijel-zambo-main-version-1433-01-48.mp3');
254
  this.backgroundMusic.loop = true;
255
-
256
- this.gameOverMusic = new Audio('/assets/assets/game-over-8bit-music-danijel-zambo-1-00-16.mp3');
257
  this.gameOverMusic.loop = false;
258
-
259
- this.victoryMusic = new Audio('/assets/assets/moonlit-whispers-theo-gerard-main-version-35960-02-34.mp3');
260
  this.victoryMusic.loop = false;
261
 
262
  // Move character images to class state
@@ -836,6 +836,14 @@ export class GameEngine {
836
  }
837
 
838
  initDebugControls() {
 
 
 
 
 
 
 
 
839
  const targetDoorBtn = document.getElementById("targetDoorBtn");
840
  const targetGirlBtn = document.getElementById("targetGirlBtn");
841
  const targetBarBtn = document.getElementById("targetBarBtn");
@@ -1021,7 +1029,7 @@ export class GameEngine {
1021
 
1022
  setGameOver(fromExit) {
1023
  this.stopBackgroundMusic();
1024
-
1025
  if (this.gameSuccessful) {
1026
  this.gameOverImage.src = "assets/assets/victory.png";
1027
  this.playVictoryMusic();
@@ -1087,7 +1095,7 @@ export class GameEngine {
1087
  }
1088
 
1089
  playBackgroundMusic() {
1090
- this.backgroundMusic.play().catch(error => {
1091
  console.error("Error playing background music:", error);
1092
  });
1093
  }
@@ -1098,13 +1106,13 @@ export class GameEngine {
1098
  }
1099
 
1100
  playGameOverMusic() {
1101
- this.gameOverMusic.play().catch(error => {
1102
  console.error("Error playing game over music:", error);
1103
  });
1104
  }
1105
 
1106
  playVictoryMusic() {
1107
- this.victoryMusic.play().catch(error => {
1108
  console.error("Error playing victory music:", error);
1109
  });
1110
  }
@@ -1120,13 +1128,13 @@ export class GameEngine {
1120
  lowerMusicVolume() {
1121
  // Store original volumes if not already stored
1122
  if (!this.originalVolumes) {
1123
- this.originalVolumes = {
1124
- background: this.backgroundMusic.volume,
1125
- gameOver: this.gameOverMusic.volume,
1126
- victory: this.victoryMusic.volume
1127
- };
1128
  }
1129
-
1130
  // Lower all music volumes to 20% of their original values
1131
  this.backgroundMusic.volume = this.originalVolumes.background * 0.2;
1132
  this.gameOverMusic.volume = this.originalVolumes.gameOver * 0.2;
@@ -1135,13 +1143,13 @@ export class GameEngine {
1135
  lowerMusicVolumeALot() {
1136
  // Store original volumes if not already stored
1137
  if (!this.originalVolumes) {
1138
- this.originalVolumes = {
1139
- background: this.backgroundMusic.volume,
1140
- gameOver: this.gameOverMusic.volume,
1141
- victory: this.victoryMusic.volume
1142
- };
1143
  }
1144
-
1145
  // Lower all music volumes to 20% of their original values
1146
  this.backgroundMusic.volume = this.originalVolumes.background * 0.01;
1147
  this.gameOverMusic.volume = this.originalVolumes.gameOver * 0.01;
 
2
  import { nameToLabel } from "./story_engine.js";
3
 
4
  const WINGMAN_SPEED = 5;
5
+ const SHYGUY_SPEED = 1;
6
 
7
+ const IS_DEBUG = false;
8
 
9
  class SpriteEntity {
10
  constructor(x0, y0, imageSrc, speed = 0, width = 24, height = 64, frameRate = 8, frameCount = 1) {
 
250
  this.introView = document.getElementById("introView");
251
  this.startGameBtn = document.getElementById("startGameBtn");
252
 
253
+ this.backgroundMusic = new Audio("assets/assets/tiny-steps-danijel-zambo-main-version-1433-01-48.mp3");
254
  this.backgroundMusic.loop = true;
255
+
256
+ this.gameOverMusic = new Audio("/assets/assets/game-over-8bit-music-danijel-zambo-1-00-16.mp3");
257
  this.gameOverMusic.loop = false;
258
+
259
+ this.victoryMusic = new Audio("/assets/assets/moonlit-whispers-theo-gerard-main-version-35960-02-34.mp3");
260
  this.victoryMusic.loop = false;
261
 
262
  // Move character images to class state
 
836
  }
837
 
838
  initDebugControls() {
839
+ const debugControls = document.getElementById("debugControls");
840
+ if (!IS_DEBUG) {
841
+ if (debugControls) {
842
+ debugControls.style.display = "none";
843
+ }
844
+ return;
845
+ }
846
+
847
  const targetDoorBtn = document.getElementById("targetDoorBtn");
848
  const targetGirlBtn = document.getElementById("targetGirlBtn");
849
  const targetBarBtn = document.getElementById("targetBarBtn");
 
1029
 
1030
  setGameOver(fromExit) {
1031
  this.stopBackgroundMusic();
1032
+
1033
  if (this.gameSuccessful) {
1034
  this.gameOverImage.src = "assets/assets/victory.png";
1035
  this.playVictoryMusic();
 
1095
  }
1096
 
1097
  playBackgroundMusic() {
1098
+ this.backgroundMusic.play().catch((error) => {
1099
  console.error("Error playing background music:", error);
1100
  });
1101
  }
 
1106
  }
1107
 
1108
  playGameOverMusic() {
1109
+ this.gameOverMusic.play().catch((error) => {
1110
  console.error("Error playing game over music:", error);
1111
  });
1112
  }
1113
 
1114
  playVictoryMusic() {
1115
+ this.victoryMusic.play().catch((error) => {
1116
  console.error("Error playing victory music:", error);
1117
  });
1118
  }
 
1128
  lowerMusicVolume() {
1129
  // Store original volumes if not already stored
1130
  if (!this.originalVolumes) {
1131
+ this.originalVolumes = {
1132
+ background: this.backgroundMusic.volume,
1133
+ gameOver: this.gameOverMusic.volume,
1134
+ victory: this.victoryMusic.volume,
1135
+ };
1136
  }
1137
+
1138
  // Lower all music volumes to 20% of their original values
1139
  this.backgroundMusic.volume = this.originalVolumes.background * 0.2;
1140
  this.gameOverMusic.volume = this.originalVolumes.gameOver * 0.2;
 
1143
  lowerMusicVolumeALot() {
1144
  // Store original volumes if not already stored
1145
  if (!this.originalVolumes) {
1146
+ this.originalVolumes = {
1147
+ background: this.backgroundMusic.volume,
1148
+ gameOver: this.gameOverMusic.volume,
1149
+ victory: this.victoryMusic.volume,
1150
+ };
1151
  }
1152
+
1153
  // Lower all music volumes to 20% of their original values
1154
  this.backgroundMusic.volume = this.originalVolumes.background * 0.01;
1155
  this.gameOverMusic.volume = this.originalVolumes.gameOver * 0.01;