Path 2

๐Ÿ”จ Builder

You've got your hard hat on โ€” time to build!

Read an existing pattern, copy it, fill in your own values. Something new in the game every time!

Ages 8โ€“9  ยท  5 tasks
1 2 3 4 5
๐Ÿ”จ Builder tip: Every task follows the same idea โ€” find something that already exists in the code, copy its shape (the pattern), and fill it in with new values. You never need to invent from scratch; just adapt what's already there!
1

๐ŸŒฎ Add a new collectible type

Belly can collect donuts, pizza, ice cream and more. Let's add a new treat! You need to make two small changes โ€” one to define the new treat, one to let the game spawn it.

Change 1 of 2 โ€” open this file
js/entities.js
Find the COLLECTIBLE_RADII object (the radius controls how big the treat appears)
// Builder Task 1: add a new kind here!
const COLLECTIBLE_RADII = {
  donut:       16,
  pizza:       16,
  icecream:    18,
  lollipop:    14,
  hotdog:      18,
  cupcake:     15,
  candybar:    16,
  milkshake:   16,
    taco:        17,  โ† add your new treat here!
};
Change 2 of 2 โ€” open this file
js/game.js
Find the spawnCollectible function and add your treat to the kinds array
// Builder Task 1: add your new kind name here!
const kinds = [
  'donut', 'pizza', 'icecream', 'lollipop',
  'hotdog', 'cupcake', 'candybar', 'milkshake',
    'taco',   โ† add this!
];
๐ŸŽฎ
Refresh and play โ€” your new treat will appear as a coloured circle for now. It'll look like all the other collectibles until someone draws a proper sprite for it!
๐Ÿ’ก
You just learned about: Arrays and objects An array is a list of things: ['donut', 'pizza', ...]. An object stores named values: { donut: 16, pizza: 16 }. The game picks a random item from the array each time it spawns a collectible.
2

๐Ÿ’ฅ Add a new Bonkers Mode difficulty tier

The game has Easy, Normal, Hard and Chaos modes. You're going to add a new "Mega" tier that's even more extreme โ€” and make it appear in the difficulty picker on the title screen.

Change 1 of 2 โ€” open this file
js/game.js
Find BONKERS_CONFIGS and add a new tier after 'chaos'. Copy the chaos block and rename it 'mega'
  chaos: {
    candyCaneRequired: 5,
    flashDuration:     2.5,
    shakeDuration:     3.0,
    runDuration:       7.0,
    speedMultiplier:   4.2,
  },
  mega: {               โ† add this new block!
    candyCaneRequired: 6,
    flashDuration:     3.0,
    shakeDuration:     4.0,
    runDuration:       9.0,
    speedMultiplier:   5.0,
  },
Change 2 of 2 โ€” open this file
index.html
Find the difficulty <select> and add a new option
<select id="bonkers-mode-select">
  <option value="easy">Easy</option>
  <option value="normal">Normal</option>
  <option value="hard">Hard</option>
  <option value="chaos">Chaos</option>
    <option value="mega">MEGA ๐Ÿ’ฅ</option>  โ† add this!
</select>
๐ŸŽฎ
Refresh the game โ€” "MEGA ๐Ÿ’ฅ" now appears in the difficulty picker on the title screen!
๐Ÿ’ก
You just learned about: Copy-and-modify The safest way to add something new is to copy something that already works and change only what needs to change. You touched two files but only added code โ€” nothing was broken because you followed the existing pattern exactly.
3

๐ŸŽฏ Make a hitbox more forgiving

A hitbox is the invisible rectangle the game uses to decide if Belly touched an obstacle. Making it smaller means players get more room for error. Let's make the bicycle easier to dodge!

Open this file
js/entities.js
Find the OBSTACLE_HITBOX table at the top of the file and look for the bicycle entry
// Hitbox insets: [leftFrac, topFrac, widthFrac, heightFrac]
// Smaller widthFrac and heightFrac = smaller hitbox = easier to dodge
const OBSTACLE_HITBOX = {
  // ...
  'bicycle': [0.08, 0.20, 0.84, 0.72],
  // ...
};
Change the four numbers to shrink the hitbox
// Original โ€” covers most of the sprite
'bicycle': [0.08, 0.20, 0.84, 0.72],

// Smaller hitbox โ€” more forgiving!
'bicycle': [0.22, 0.30, 0.56, 0.50],
How the four numbers work: [leftFrac, topFrac, widthFrac, heightFrac]
Each is a fraction of the sprite's total size. Bigger left/top fractions push the hitbox inward. Smaller width/height fractions make it narrower and shorter.
๐ŸŽฎ
Refresh and play. Try running right through a bicycle โ€” you should be able to clip the edge without dying!
๐Ÿ’ก
You just learned about: Hitboxes and fractions In almost every game, the invisible collision rectangle is smaller than the visible sprite โ€” this gives players a fair feeling. Fractions (0.0โ€“1.0) keep the hitbox proportional no matter how big or small the sprite is.
4

โœจ Add a new accessory for Belly

Belly can earn accessories by completing perfect runs (no lives lost). Add a brand new accessory to the collection โ€” it will appear in the shop and can be unlocked just like the others!

Open this file
js/game.js
Find the ACCESSORIES array
// Builder Task 4: add a new object to this array!
const ACCESSORIES = [
  { id: 'hat',        emoji: '๐ŸŽฉ', name: 'Magic Hat',      desc: 'Tips with style!' },
  { id: 'boots',      emoji: '๐Ÿ‘ข', name: 'Power Boots',    desc: 'Spring in every step!' },
  { id: 'glasses',    emoji: '๐Ÿ•ถ๏ธ', name: 'Cool Shades',    desc: 'Looking so groovy!' },
  // ... more accessories
    { id: 'umbrella',   emoji: 'โ˜‚๏ธ', name: 'Lucky Umbrella', desc: 'Stays dry, plays hard!' },  โ† add yours!
];
Make it your own! Choose any emoji, give it a fun name and a silly description. Use the same shape as the other items: { id: '...', emoji: '...', name: '...', desc: '...' }
๐ŸŽฎ
Refresh and complete a level without losing a life โ€” your new accessory will appear in the reward screen!
๐Ÿ’ก
You just learned about: Arrays of objects An array of objects is one of the most common patterns in all of programming โ€” a list where each item has several named properties. Adding a new item only requires matching the shape of the existing items exactly.
5

๐Ÿฆ– Move an obstacle to a different level

Each level has its own list of obstacles. The dinosaur normally only appears in level 1, but you can move it โ€” or add it โ€” to any other level. You can also make an obstacle appear more often by adding its name to the list more than once!

Open this file
js/game.js
Find the spawnObstacle function and look for the kindsByLevel object
// Builder Task 5: move names between levels, or add duplicates!
const kindsByLevel = {
  1: ['toy-small', 'toy-large', 'toy-ball', 'rattle',
     'bicycle', 'blocks', 'toy-car', 'dinosaur'],  โ† try moving this!
  2: ['ant', 'worm', 'roman-pot', 'boulder', 'clock'],
  3: ['bird', 'balloon', 'plane', 'hot-air-balloon', 'blimp'],
  // ...
};
Try these experiments
// Add dinosaur to level 2 as well:
2: ['ant', 'worm', 'roman-pot', 'boulder', 'clock', 'dinosaur'],

// Make ants appear twice as often in level 2:
2: ['ant', 'ant', 'worm', 'roman-pot', 'boulder', 'clock'],

// Add a sky obstacle to the underground level (chaos mode!):
2: ['ant', 'worm', 'boulder', 'clock', 'bird'],
๐ŸŽฎ
Play through to the level you edited โ€” your changed obstacles will appear!
๐Ÿ’ก
You just learned about: Random selection from arrays The game picks a random item from the list each time it spawns an obstacle. A longer list gives more variety. Duplicating a name (adding it twice) makes it twice as likely to be chosen โ€” a simple but powerful technique!
โ† Explorer Path โ–ถ Play the Game! โœจ Creator Path โ†’