From 5c5d66c17d3109822571f6769da71d24551418f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Grzegorz=20Ta=C5=84czyk?= Date: Mon, 26 Aug 2024 00:31:30 +0300 Subject: [PATCH] removing features to meet 13kb limit --- js13k2024/game/src/game-states/intro/intro.ts | 26 ++++---- js13k2024/game/src/main.ts | 62 +++++++++---------- 2 files changed, 42 insertions(+), 46 deletions(-) diff --git a/js13k2024/game/src/game-states/intro/intro.ts b/js13k2024/game/src/game-states/intro/intro.ts index 52780580..ba1d4748 100644 --- a/js13k2024/game/src/game-states/intro/intro.ts +++ b/js13k2024/game/src/game-states/intro/intro.ts @@ -1,13 +1,14 @@ -import { GamePreview } from './game-preview'; +// Game preview is removed for now +// import { GamePreview } from './game-preview'; import { createElement, createDiv, createButton, appendChildren } from '../../utils/dom'; export class Intro { private onStart: () => void; - private onInstructions: () => void; + // private onInstructions: () => void; - constructor(onStart: () => void, onInstructions: () => void) { + constructor(onStart: () => void /*, onInstructions: () => void*/) { this.onStart = onStart; - this.onInstructions = onInstructions; + // this.onInstructions = onInstructions; } render(): HTMLElement { @@ -19,30 +20,31 @@ export class Intro { const introResponsive = createDiv('game-intro-responsive'); - const previewContainer = createDiv('game-preview-container'); - const gamePreview = new GamePreview(); - previewContainer.appendChild(gamePreview.render()); + // const previewContainer = createDiv('game-preview-container'); + // const gamePreview = new GamePreview(); + // previewContainer.appendChild(gamePreview.render()); const introColumn = createDiv('game-intro-column'); const buttonContainer = createDiv('intro-buttons'); const startButton = createButton('Start Game', this.onStart); - const instructionsButton = createButton('Instructions', this.onInstructions); - appendChildren(buttonContainer, [startButton, instructionsButton]); + // const instructionsButton = createButton('Instructions', this.onInstructions); + appendChildren(buttonContainer, [startButton /*, instructionsButton*/]); const tip = createElement('p'); tip.className = 'intro-tip'; tip.textContent = 'Press right arrow to start'; appendChildren(introColumn, [buttonContainer, tip]); - appendChildren(introResponsive, [previewContainer, introColumn]); + appendChildren(introResponsive, [/*previewContainer, */ introColumn]); const authorInfo = createElement('p'); authorInfo.className = 'author-name'; - authorInfo.innerHTML = 'Created by Grzegorz Tańczyk | Source code (GitHub)'; + authorInfo.innerHTML = + 'Created by Grzegorz Tańczyk | Source code (GitHub)'; appendChildren(container, [title, introResponsive, authorInfo]); return container; } -} \ No newline at end of file +} diff --git a/js13k2024/game/src/main.ts b/js13k2024/game/src/main.ts index 90b123d2..eba5d6e0 100644 --- a/js13k2024/game/src/main.ts +++ b/js13k2024/game/src/main.ts @@ -1,5 +1,6 @@ import { Intro } from './game-states/intro/intro'; -import { Instructions } from './game-states/instructions/instructions'; +// Instructions are removed from the UI for now +// import { Instructions } from './game-states/instructions/instructions'; import { Gameplay } from './game-states/gameplay/gameplay'; import { GameOver } from './game-states/game-over/game-over'; import { LevelComplete } from './game-states/level-complete/level-complete'; @@ -10,12 +11,12 @@ import './global-styles.css'; enum GameState { Intro, - Instructions, + // Instructions, LevelStory, Gameplay, GameOver, LevelComplete, - GameComplete + GameComplete, } export class MonsterStepsApp { @@ -59,7 +60,7 @@ export class MonsterStepsApp { } } else if (e.key === 'Escape') { if ( - this.gameState === GameState.Instructions || + // this.gameState === GameState.Instructions || this.gameState === GameState.GameOver || this.gameState === GameState.GameComplete ) { @@ -75,16 +76,13 @@ export class MonsterStepsApp { switch (this.gameState) { case GameState.Intro: - this.currentScreen = new Intro(this.startGame.bind(this), this.showInstructions.bind(this)); - break; - case GameState.Instructions: - this.currentScreen = new Instructions(this.quitGame.bind(this)); + this.currentScreen = new Intro(this.startGame.bind(this) /*, this.showInstructions.bind(this)*/); break; + // case GameState.Instructions: + // this.currentScreen = new Instructions(this.quitGame.bind(this)); + // break; case GameState.LevelStory: - this.currentScreen = new LevelStory( - this.level, - this.startGameplay.bind(this) - ); + this.currentScreen = new LevelStory(this.level, this.startGameplay.bind(this)); break; case GameState.Gameplay: this.currentScreen = new Gameplay( @@ -94,7 +92,7 @@ export class MonsterStepsApp { this.levelComplete.bind(this), this.gameComplete.bind(this), this.updateScore.bind(this), - this.updateSteps.bind(this) + this.updateSteps.bind(this), ); break; case GameState.GameOver: @@ -102,22 +100,18 @@ export class MonsterStepsApp { this.score, this.steps, this.restartLevel.bind(this), - this.quitGame.bind(this) + this.quitGame.bind(this), ); break; case GameState.LevelComplete: - this.currentScreen = new LevelComplete( - this.level, - this.nextLevel.bind(this), - this.quitGame.bind(this) - ); + this.currentScreen = new LevelComplete(this.level, this.nextLevel.bind(this), this.quitGame.bind(this)); break; case GameState.GameComplete: this.currentScreen = new GameComplete( this.score, this.steps, this.restartGame.bind(this), - this.quitGame.bind(this) + this.quitGame.bind(this), ); break; } @@ -136,10 +130,10 @@ export class MonsterStepsApp { this.renderCurrentState(); } - private showInstructions() { - this.gameState = GameState.Instructions; - this.renderCurrentState(); - } + // private showInstructions() { + // this.gameState = GameState.Instructions; + // this.renderCurrentState(); + // } private restartGame() { this.level = 1; @@ -205,43 +199,43 @@ class GameComplete { render(): HTMLElement { const container = createDiv('game-complete intro'); - + const title = document.createElement('h1'); title.className = 'game-title'; title.textContent = 'Monster Steps'; - + const subtitle = document.createElement('h2'); subtitle.className = 'game-complete-subtitle'; subtitle.textContent = 'Congratulations!'; - + const stats = createDiv('game-complete-stats'); stats.innerHTML = `

Final Score: ${this.score}

Total Steps: ${this.steps}

`; - + const buttons = createDiv('intro-buttons'); const playAgainButton = document.createElement('button'); playAgainButton.textContent = 'Play Again'; playAgainButton.onclick = this.onPlayAgain; - + const quitButton = document.createElement('button'); quitButton.textContent = 'Quit'; quitButton.onclick = this.onQuit; - + buttons.appendChild(playAgainButton); buttons.appendChild(quitButton); - + const tip = document.createElement('p'); tip.className = 'intro-tip'; tip.textContent = 'Press right arrow to play again'; - + container.appendChild(title); container.appendChild(subtitle); container.appendChild(stats); container.appendChild(buttons); container.appendChild(tip); - + return container; } -} \ No newline at end of file +}