Skip to content

Commit 96bca21

Browse files
committed
feat: Add game hints, tweak levels
1 parent 7d9b86b commit 96bca21

10 files changed

Lines changed: 56 additions & 21 deletions

File tree

src/Level.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { BounceBoard } from './BounceBoard';
22
import { Brick } from './Brick';
3+
import { initGameHints } from './gameHints';
34
import { Goal } from './Goal';
45
import { Heart } from './Heart';
56
import { Player } from './Player';
@@ -40,6 +41,7 @@ export class Level {
4041
this.createBricks(levelData);
4142
this.createBounceBoards(levelData);
4243
this.isLevelLoaded = true;
44+
initGameHints(this.levelId);
4345
}
4446

4547
loadLevel(levelId) {

src/PlayerControls.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export class PlayerControls {
2828
}
2929

3030
initControls() {
31-
onInput(['c'], () => this.player.rope.cutRope(0));
31+
onInput(['s'], () => this.player.rope.cutRope(0));
3232
onInput(['z'], () => emit(RESTART_LEVEL));
3333
}
3434
}

src/Rope.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ export class Rope {
130130
return;
131131
}
132132

133-
const factor = 0.1;
133+
const factor = 0.3;
134134
const lastLink = this.links[this.links.length - 1];
135135
lastLink.restingDistance -= RESTING_DISTANCE * factor;
136136
if (lastLink.restingDistance <= 0) {

src/gameHints.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
export const initGameHints = (levelId) => {
2+
const hintEl = document.getElementById('hint');
3+
hintEl.textContent = '';
4+
switch (levelId) {
5+
case 1:
6+
hintEl.textContent =
7+
'Reach the goal below.\nUse the arrow keys (⬅️ ➡️) to move.\nCut the rope with "S".';
8+
break;
9+
case 2:
10+
hintEl.textContent = 'Use "Up Arrow" to shorten the rope';
11+
break;
12+
case 3:
13+
hintEl.textContent =
14+
'Use "Space" to give you a boost upwards.\n Cut the rope with "S".';
15+
break;
16+
}
17+
};

src/index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
<button id="nearLevelBtn" disabled>NEAR Levels</button>
2121
<button id="levelBtn">Select Level</button>
2222
<button id="bonusBtn">Bonus Content</button>
23+
<button id="goodiesBtn" disabled>Coil Goodies</button>
2324
</div>
2425
<div id="bonus" class="overlay hide">
2526
<div id="coil-subscriber" class="hide">
@@ -55,6 +56,7 @@
5556
<button id="nextBtn">Play next level</button>
5657
<button id="replayBtn">Replay level</button>
5758
</div>
59+
<div id="hint"></div>
5860
</div>
5961
</body>
6062
</html>

src/level/level2.json

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
11
{
22
"p": { "x": 400, "y": 255 },
33
"r": 30,
4-
"s": [
5-
{ "x": 464, "y": 350 },
6-
{ "x": 304, "y": 350 }
7-
],
4+
"s": [],
85
"b": [
9-
{ "x": 272, "y": 220 },
10-
{ "x": 304, "y": 220 },
11-
{ "x": 336, "y": 220 },
12-
{ "x": 368, "y": 220 },
136
{ "x": 400, "y": 220 },
14-
{ "x": 432, "y": 220 },
15-
{ "x": 464, "y": 220 },
16-
{ "x": 496, "y": 220 }
7+
{ "x": 272, "y": 380 },
8+
{ "x": 304, "y": 380 },
9+
{ "x": 336, "y": 380 },
10+
{ "x": 368, "y": 380 },
11+
{ "x": 432, "y": 380 },
12+
{ "x": 464, "y": 380 },
13+
{ "x": 496, "y": 380 }
1714
],
18-
"g": [{ "x": 368, "y": 700 }],
15+
"g": [{ "x": 368, "y": 250 }],
1916
"h": [{ "x": 550, "y": 290 }]
2017
}

src/level/level3.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@
44
"s": [{ "x": 464, "y": 350, "b": "ew", "d": 100 }],
55
"b": [{ "x": 260, "y": 220 }],
66
"g": [
7-
{ "x": 368, "y": 700 },
8-
{ "x": 600, "y": 700 }
7+
{ "x": 400, "y": 600 },
8+
{ "x": 600, "y": 50 }
99
],
10-
"h": [{ "x": 550, "y": 400 }]
10+
"h": [
11+
{ "x": 260, "y": 50 },
12+
{ "x": 580, "y": 100 }
13+
]
1114
}

src/level/level5.json

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
{
22
"p": { "x": 272, "y": 255, "b": "ew", "d": 100 },
33
"r": 30,
4-
"s": [{ "x": 100, "y": 450, "b": "ew", "d": 100 }],
4+
"s": [
5+
{ "x": 100, "y": 450, "b": "ew", "d": 100 },
6+
{ "x": 400, "y": 200, "b": "ew", "d": -200 }
7+
],
58
"b": [
69
{ "x": 260, "y": 220, "b": "ew", "d": 100 },
7-
{ "x": 460, "y": 320, "b": "ew", "d": 170 },
10+
811
{ "x": 600, "y": 520, "b": "ew", "d": 80 }
912
],
1013
"g": [{ "x": 600, "y": 700 }],
11-
"h": [{ "x": 200, "y": 400 }]
14+
"h": [
15+
{ "x": 200, "y": 400 },
16+
{ "x": 600, "y": 50 }
17+
]
1218
}

src/menu.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
} from './store';
2020
import { IPFS_BASE_PATH } from './near/nearConnection';
2121
import { doesOwnNft, getNearLevel } from './utils';
22+
import { initGameHints } from './gameHints';
2223

2324
const overlayIds = ['main', 'bonus', 'levels', 'level-dialog', 'near-levels'];
2425
const levels = 20;
@@ -188,6 +189,7 @@ const onNearLevelClick = (btn) => {
188189
};
189190

190191
const showOverlay = (id) => {
192+
initGameHints(null);
191193
overlayIds.forEach((o) => {
192194
const overlayEl = document.getElementById(o);
193195
if (!overlayEl.classList.contains('hide')) {

src/styles.css

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@ canvas {
5050
cursor: pointer;
5151
}
5252

53+
#hint {
54+
bottom: 250px;
55+
position: absolute;
56+
white-space: pre-wrap;
57+
text-align: center;
58+
}
59+
5360
#hamburger,
5461
#hamburger::after,
5562
#hamburger::before {
@@ -58,7 +65,6 @@ canvas {
5865
#hamburger:hover {
5966
filter: drop-shadow(0 0 12px var(--acc));
6067
}
61-
6268
button,
6369
.btn {
6470
width: 240px;

0 commit comments

Comments
 (0)