Complete Game Lab
Here you see the whole project: HTML + CSS + JavaScript + the live result.
1. Treasure Rush
NEW: Treasure + danger + win ruleTOOLS: touching, randomPosition, changeNumber, setText2. Two-Player Treasure Battle
NEW: Shared target + two scoresTOOLS: moveWithKeys, touching, randomPosition, changeNumber3. Platform Escape
NEW: Gravity + jump + platformsTOOLS: trackKeys, keyDown, applyGravity, standingOnAny, landOnPlatforms4. BONUS · Laser Treasure Rush
NEW: Random danger every few secondsTOOLS: createSprite, setTimeout, move, touchingGame Challenges
Start with the question. Open hints only when you need them.
Challenge 1 · Gold Key Door
Make a player collect a key, hide the key, then open a door only if the key was collected.
Which functions might help? Try to name them before opening the hint.
Hint 1 · functions
moveWithKeys(), touching(), hide(), setText().
Hint 2 · one variable
let hasKey = false;
Challenge 2 · Mystery Trader
Collect 3 crystals. When you meet the trader, exchange them for a gold key.
What new idea do you need? An inventory array, then count/remove items.
Hint
Start with let inventory = [];. Use countItem() and removeItems().
Challenge 3 · Maze + Treasure
Build at least 4 walls. Put treasure inside. The player must collect it before reaching the exit.
Hint
Use a walls array and moveIfClear(). Then reuse touching().
Challenge 4 · Invent a Two-Player Game
Player 1 uses WASD. Player 2 uses arrows. Decide the win rule yourself: race, treasure, tag, battle or something new.
Hint
Call moveWithKeys() twice with different keys.