From 81cf7d238e8c2efb8c397e786a9abd7db9e25687 Mon Sep 17 00:00:00 2001 From: Tomas Horsky Date: Wed, 6 May 2026 13:14:50 +0900 Subject: [PATCH] last polishing of code --- src/game/game.js | 24 +++++++++++++----------- src/game/platformTypes.js | 3 --- src/game/player.js | 2 -- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/src/game/game.js b/src/game/game.js index afd1883..ade234e 100644 --- a/src/game/game.js +++ b/src/game/game.js @@ -8,12 +8,9 @@ let platforms; let pendingWorldMove = 0; let gameOver = false; -export function getScore() { - return (player?.elevation ?? 0) / PLATFORMS_GAP * 10; -} - -export function isGameOver() { - return gameOver; +export function initializeGame() { + world.gravity.y = 10; + resetGame(); } export function resetGame() { @@ -24,11 +21,6 @@ export function resetGame() { player = createPlayer(); } -export function initializeGame() { - world.gravity.y = 10; - resetGame(); -} - export function updateGame() { clear(); background(GAME_COLORS.background); @@ -40,6 +32,7 @@ export function updateGame() { pendingWorldMove += movePlayer(player, platforms); player.rotation = player.vel.x * 1.5; + // move if (pendingWorldMove > PLATFORMS_GAP) { const move = Math.min(pendingWorldMove, 5); pendingWorldMove -= move; @@ -57,3 +50,12 @@ export function updateGame() { textAlign(RIGHT); text(getScore(), width - 20, 50); } + + +export function getScore() { + return (player?.elevation ?? 0) / PLATFORMS_GAP * 10; +} + +export function isGameOver() { + return gameOver; +} \ No newline at end of file diff --git a/src/game/platformTypes.js b/src/game/platformTypes.js index 9a40425..30087fd 100644 --- a/src/game/platformTypes.js +++ b/src/game/platformTypes.js @@ -14,7 +14,6 @@ function drawSpringPlatform() { noStroke(); textAlign(CENTER, CENTER); textSize(15); - //textStyle(BOLD); text('⮝ ⮝ ⮝', 0, 2); textStyle(NORMAL); } @@ -51,8 +50,6 @@ function addMovingBehavior(platform) { }; } - - export function addTypeSpecifics(platform, type) { switch (platform.type) { case PLAT_TYPE.MOVING: diff --git a/src/game/player.js b/src/game/player.js index 70f7e72..1283f86 100644 --- a/src/game/player.js +++ b/src/game/player.js @@ -20,7 +20,6 @@ export function createPlayer() { function handleJump(player, platform) { - let elevationGain = 0; if (player.elevation < platform.elevation) { elevationGain = platform.elevation - player.elevation; @@ -52,7 +51,6 @@ export function movePlayer(player, platforms) { player.vel.x = 5; } - // Wrap horizontally if (player.x > width) { player.x = 0;