diff --git a/src/App.svelte b/src/App.svelte
index 120a4ac..3a6335e 100644
--- a/src/App.svelte
+++ b/src/App.svelte
@@ -1,22 +1,85 @@
-
+
+ Nubzuki Jump
+
+
+
+
+
\ No newline at end of file
diff --git a/src/game/constants.js b/src/game/constants.js
index 5543dc7..600c5b0 100644
--- a/src/game/constants.js
+++ b/src/game/constants.js
@@ -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;
diff --git a/src/game/game.js b/src/game/game.js
index 12ff3cb..27f4a70 100644
--- a/src/game/game.js
+++ b/src/game/game.js
@@ -7,6 +7,9 @@ let player;
let platforms;
let pendingWorldMove = 0;
+export function getScore() {
+ return (player?.elevation ?? 0);
+}
function createPlayer() {
player = new Sprite();
diff --git a/src/game/platforms.js b/src/game/platforms.js
index 05e5d99..649572d 100644
--- a/src/game/platforms.js
+++ b/src/game/platforms.js
@@ -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;
}