last polishing of code

This commit is contained in:
2026-05-06 13:14:50 +09:00
parent 0952b33a33
commit 81cf7d238e
3 changed files with 13 additions and 16 deletions

View File

@@ -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;
}

View File

@@ -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:

View File

@@ -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;