🧩 Free · Ages 10+ · JavaScript · No download

How to make a Maze game in JavaScript

Find the door before the timer runs out — and grab the coins. Play it first, then open it in the Game Studio and change it until it is your own game.

🎮 Controls: arrow keys (or WASD) to move

The numbers that make the game

At the top of the code are the settings — change one, run the game, and feel the difference. This is how game designers balance a game.

let playerSpeed = 180
let timeLimit = 60
let coinPoints = 5

6 ways to change the maze game

Try them in order. The studio ticks each one off when your change works — and shows a hint if it does not.

  1. Give yourself more time.ज़्यादा समय दें।
    let timeLimit = 90
  2. Make the player faster.खिलाड़ी को तेज़ करें।
    let playerSpeed = 260
  3. Add a coin: type $ on an empty space in the maze.भूलभुलैया में खाली जगह पर $ लिखकर सिक्का जोड़ें।
    "#   $ #   # #",
  4. Add a trap: type ^ (spikes) in the maze.भूलभुलैया में ^ (काँटे) लिखकर जाल बनाएँ।
    "#   #  ^#  $#",
  5. Change the winning message.जीत का संदेश बदलें।
    tj.victory("I did it!")
  6. Draw your own maze: change the # walls (keep the outside walls).अपनी भूलभुलैया बनाएँ: # दीवारें बदलें (बाहर की दीवारें रहने दें)।
    move some # around

The Maze code (JavaScript)

45 lines of real JavaScript, made with TalentJR Game Studio's game library. Lines that start with // explain what the next part does.

Show the whole game code
// 🧩 Maze — TalentJR Game Studio
// ✏️ Change these numbers, then press ▶ Run!
let playerSpeed = 180
let timeLimit = 60
let coinPoints = 5

tj.setup({ background: "grass" })
tj.touchControls("arrows")

// The maze — # wall   $ coin   ^ spikes   D door (the way out)   @ start
const level = tj.level([
    "#############",
    "#@  #   $   #",
    "# # # ### # #",
    "# #   #   # #",
    "# ##### ### #",
    "#   $ #   # #",
    "### # # # # #",
    "#   #   #  $#",
    "# ##### ###D#",
    "#############",
])

const player = tj.player({ at: level.start, speed: playerSpeed, mode: "topdown" })
const score = tj.score()
tj.timer(timeLimit)

// Collect coins
player.onCollide("coin", (coin) => {
    destroy(coin)
    score.add(coinPoints)
    tj.sound("coin")
})

// Spikes send you back to the start
player.onCollide("danger", () => {
    tj.sound("hit")
    player.pos = level.start.clone()
})

// Find the door to escape
player.onCollide("goal", () => {
    tj.victory("You escaped! 🎉")
})

How it works on TalentJR

  1. Play the gameFind out what feels too easy or too hard — that is what you will change.
  2. Open it in the studioThe code is on the left, the game on the right. Press ▶ Run after every change.
  3. Change one thing at a timeA number first, then a new rule, then your own art and title.
  4. Save and shareSign in to keep your game, then share a talentjr.in/play/… link on WhatsApp — friends can play it and make their own version.

More games you can make

← All 19 games and the 4 ways to make games