Skip to content

Commit 0516f99

Browse files
committed
feat: taller world (3:2), reduce difficulty, add gitignore
1 parent 76e2d77 commit 0516f99

5 files changed

Lines changed: 29 additions & 26 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules/
2+
.DS_Store
3+
*.log

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<div>runner</div>
1717
<div>score: <span id="score">0</span></div>
1818
</div>
19-
<canvas id="canvas" width="600" height="200"></canvas>
19+
<canvas id="canvas" width="600" height="400"></canvas>
2020
<button class="jump-btn">start</button>
2121
<div class="high-score">
2222
high score: <span id="high-score">0</span>

src/config.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export const WORLD = {
22
width: 600,
3-
height: 200,
3+
height: 400,
44
};
55

66
export const COLORS = {
@@ -13,7 +13,7 @@ export const COLORS = {
1313
};
1414

1515
export const HERO = {
16-
size: 24,
16+
size: 26,
1717
startX: 50,
1818
};
1919

@@ -22,28 +22,28 @@ export const TILE = {
2222
};
2323

2424
export const PHYSICS = {
25-
gravity: 900,
26-
jumpImpulse: -340,
27-
holdGravity: 120,
25+
gravity: 980,
26+
jumpImpulse: -400,
27+
holdGravity: 130,
2828
maxJumpHoldMs: 300,
29-
terminalVelocity: 600,
29+
terminalVelocity: 700,
3030
};
3131

3232
export const OBSTACLE = {
33-
width: 24,
34-
minHeight: 24,
35-
maxHeight: 48,
36-
minGap: 90,
37-
maxGap: 200,
33+
width: 26,
34+
minHeight: 30,
35+
maxHeight: 64,
36+
minGap: 130,
37+
maxGap: 280,
3838
spawnX: WORLD.width + 40,
3939
collisionInset: 3,
4040
};
4141

4242
export const PROGRESSION = {
43-
speedUpEvery: 3,
44-
speedStep: 14,
45-
startSpeed: 160,
46-
maxSpeed: 360,
43+
speedUpEvery: 5,
44+
speedStep: 12,
45+
startSpeed: 140,
46+
maxSpeed: 320,
4747
reverseGravityEvery: 20,
4848
};
4949

src/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ canvas.height = WORLD.height;
2525

2626
// Keep canvas aspect ratio on any screen size
2727
function syncCanvasHeight() {
28-
canvas.style.height = `${canvas.offsetWidth / 3}px`;
28+
canvas.style.height = `${canvas.offsetWidth * (WORLD.height / WORLD.width)}px`;
2929
}
3030
syncCanvasHeight();
3131
window.addEventListener('resize', syncCanvasHeight);

src/renderer.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,13 @@ export function drawReverseFlash(ctx, timer) {
8686

8787
export function drawIdleScreen(ctx) {
8888
ctx.fillStyle = '#212121';
89-
ctx.font = '18px "Press Start 2P", monospace';
89+
ctx.font = '20px "Press Start 2P", monospace';
9090
ctx.textAlign = 'center';
91-
ctx.fillText('runner', WORLD.width / 2, WORLD.height / 2 - 12);
91+
ctx.fillText('runner', WORLD.width / 2, WORLD.height / 2 - 16);
9292

93-
ctx.font = '8px "Press Start 2P", monospace';
93+
ctx.font = '9px "Press Start 2P", monospace';
9494
ctx.fillStyle = '#666';
95-
ctx.fillText('press space or tap', WORLD.width / 2, WORLD.height / 2 + 16);
95+
ctx.fillText('press space or tap', WORLD.width / 2, WORLD.height / 2 + 20);
9696
ctx.textAlign = 'left';
9797
}
9898

@@ -101,20 +101,20 @@ export function drawGameOver(ctx, score, highScore) {
101101
ctx.fillRect(0, 0, WORLD.width, WORLD.height);
102102

103103
ctx.fillStyle = '#c0392b';
104-
ctx.font = '14px "Press Start 2P", monospace';
104+
ctx.font = '16px "Press Start 2P", monospace';
105105
ctx.textAlign = 'center';
106-
ctx.fillText('game over', WORLD.width / 2, WORLD.height / 2 - 16);
106+
ctx.fillText('game over', WORLD.width / 2, WORLD.height / 2 - 20);
107107

108108
ctx.fillStyle = '#212121';
109-
ctx.font = '8px "Press Start 2P", monospace';
109+
ctx.font = '9px "Press Start 2P", monospace';
110110
ctx.fillText(`score: ${score}`, WORLD.width / 2, WORLD.height / 2 + 8);
111111

112112
if (score >= highScore && score > 0) {
113113
ctx.fillStyle = '#e67e22';
114-
ctx.fillText('new record!', WORLD.width / 2, WORLD.height / 2 + 24);
114+
ctx.fillText('new record!', WORLD.width / 2, WORLD.height / 2 + 28);
115115
}
116116

117117
ctx.fillStyle = '#666';
118-
ctx.fillText('press space to retry', WORLD.width / 2, WORLD.height / 2 + 44);
118+
ctx.fillText('press space to retry', WORLD.width / 2, WORLD.height / 2 + 52);
119119
ctx.textAlign = 'left';
120120
}

0 commit comments

Comments
 (0)