started working on page style

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
2026-04-28 23:14:30 +09:00
parent 7a0bca9938
commit 9939aab976
4 changed files with 98 additions and 31 deletions

View File

@@ -1,12 +1,11 @@
export const GAME_COLORS = {
export const GAME_COLORS = {
background: '#e8e2d6',
basicPlat: '#6c8ae4',
movingPlat: '#4cc9f0',
springPlat: '#80ed99',
basicPlat: '#6c8ae4',
movingPlat: '#4cc9f0',
springPlat: '#80ed99',
oneTimePlat: '#e76f51',
startingPlat: '#f4a261'
};
startingPlat: '#f4a261' };
export const PLATFORMS_GAP = 80;
export const PLATFORM_WIDHT = 70;

View File

@@ -7,6 +7,9 @@ let player;
let platforms;
let pendingWorldMove = 0;
export function getScore() {
return (player?.elevation ?? 0);
}
function createPlayer() {
player = new Sprite();

View File

@@ -42,16 +42,14 @@ function drawOneTimePlatform() {
}
function addMovingBehavior(platform) {
platform.direction = random() < 0.5 ? -1 : 1;
platform.speed = random(1, 2);
platform.move = function () {
this.x += this.direction * this.speed;
if (this.x < this.w / 2 || this.x > width - this.w / 2) {
this.direction *= -1;
}
};
platform.moveDir = random() < 0.5 ? -1 : 1;
platform.moveSpeed = random(1, 2);
platform.update = function () {
this.x += this.moveDir * this.moveSpeed;
if (this.x < PLATFORM_WIDHT / 2 || this.x > width - PLATFORM_WIDHT / 2) {
this.moveDir *= -1;
}
};
}
@@ -88,11 +86,11 @@ function addTypeSpecifics(platform, type) {
function selectPlatformType(elevation) {
const r = random();
switch (true) {
case elevation >= 0 && r < 0.15:
case elevation >= 200 && r < 0.15:
return PLAT_TYPE.ONE_TIME;
case elevation >= 0 && r < 0.30:
case elevation >= 200 && r < 0.30:
return PLAT_TYPE.MOVING;
case elevation >= 0 && r < 0.45:
case elevation >= 200 && r < 0.45:
return PLAT_TYPE.SPRING;
default:
return PLAT_TYPE.BASIC;
@@ -162,11 +160,15 @@ export function moveWorld(platforms, elevation, move) {
export function initPlatforms() {
let platforms = new Group();
const basePlatform = createPlatform(width / 2, height - 10, 0, PLAT_TYPE.BASIC, true);
basePlatform.color = GAME_COLORS.startingPlat;
platforms.add(basePlatform);
const startingPlat = createPlatform(width / 2, height - 10, 0, PLAT_TYPE.BASIC, true);
startingPlat.color = GAME_COLORS.startingPlat;
platforms.add(startingPlat);
let plarform1 = createPlatform(width / 4*3, height - PLATFORMS_GAP, PLATFORMS_GAP, PLAT_TYPE.BASIC);
platforms.add(plarform1);
let plarform2 = createPlatform(width / 4, height - PLATFORMS_GAP*2, PLATFORMS_GAP*2, PLAT_TYPE.BASIC);
platforms.add(plarform2);
generateNewPlatforms(platforms, basePlatform);
generateNewPlatforms(platforms, plarform2);
return platforms;
}