Skip to content

Commit

Permalink
chore(tests): Fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
CaedenPH committed Apr 1, 2024
1 parent 70ae791 commit d024c77
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 16 deletions.
38 changes: 23 additions & 15 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,23 @@ import { StartPage } from "./routes/start";
import { Config } from "./types/Config";
import { CogSpeedGraphicsHandler } from "./ui/handler";

const gameWidth = window.innerWidth;
const gameHeight = window.innerHeight;

const app = new Application<HTMLCanvasElement>({
width: gameWidth,
height: gameHeight,
});
function createApp(): Application {
const gameWidth = window.innerWidth;
const gameHeight = window.innerHeight;

const app = new Application<HTMLCanvasElement>({
width: gameWidth,
height: gameHeight,
});

const appDiv = document.querySelector(".App");
if (!appDiv) throw new Error("No app div found");
appDiv.appendChild(app.view);

return app;
}


/**
* Loads the config from the backend
Expand Down Expand Up @@ -39,14 +49,12 @@ async function loadConfig(): Promise<Config> {
* @param startNow Called from restart. Bypasses sleep data
*/
export async function startUp (config: Config | null = null, startNow: boolean = false) {
if (config === null) {
config = await loadConfig();
if (config.error) throw new Error(config.reason);
}

const appDiv = document.querySelector(".App");
if (!appDiv) throw new Error("No app div found");
appDiv.appendChild(app.view);
const app = createApp();

if (config === null) {
config = await loadConfig();
if (config.error) throw new Error(config.reason);
}

// Show GMM Logo while loading all textures
// Temp text instead of logo for now
Expand All @@ -57,7 +65,7 @@ export async function startUp (config: Config | null = null, startNow: boolean =
align: "center",
});
loadingText.anchor.set(0.5);
loadingText.position.set(gameWidth * 0.5, gameHeight * 0.5);
loadingText.position.set(app.screen.width * 0.5, app.screen.height * 0.5);
app.stage.addChild(loadingText);
app.ticker.add((delta) => {
loadingText.text = "Loading" + ".".repeat((Math.floor(app.ticker.lastTime / 1000) % 3) + 1);
Expand Down
2 changes: 1 addition & 1 deletion src/routes/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export class CogSpeedGame {
this.currentRound = 1;
return this.practiceMode();
}
this.currentRoundTimeout = setTimeout(this.displayCorrectAnswer.bind(this), this.config.timeouts.max_initial_no_response * 0.5);
this.currentRoundTimeout = setTimeout(this.displayCorrectAnswer.bind(this), this.config.timeouts.max_initial_no_response);
}

/**
Expand Down

0 comments on commit d024c77

Please sign in to comment.