Create a simple browser game using a JavaScript game engine like Phaser, learning basic coding, sprites, keyboard controls, and simple game logic.

Step-by-step guide to create a simple browser game using a JavaScript game engine
Step 1
Create a new project in your editor and make two files named index.html and game.js so your game has a web page and a script file.
Step 2
Open index.html and paste this script tag inside the head to add Phaser to your page:
Step 3
In index.html add this script tag just before the closing
tag to load your game code:
Step 4
Open game.js and paste this game skeleton to create a Phaser game with empty scene functions: const config = { type: Phaser.AUTO, width: 800, height: 600, physics: { default: 'arcade', arcade: { gravity: { y: 0 } } }, scene: { preload: preload, create: create, update: update } }; let player; let stars; let cursors; let score = 0; let scoreText; new Phaser.Game(config);
Step 5
Inside game.js add this preload code to load your images by filename so Phaser can use them: function preload() { this.load.image('player','player.png'); this.load.image('star','star.png'); }
Step 6
In the create function add the player sprite and give it arcade physics so it can move and collide with world bounds: function create() { player = this.physics.add.sprite(400,300,'player'); player.setCollideWorldBounds(true); }
Step 7
Still in create add a group of collectible stars and make them bounce so they look fun: stars = this.physics.add.group({ key: 'star', repeat: 7, setXY: { x: 50, y: 50, stepX: 90 } }); stars.children.iterate(function(child){ child.setBounceY(Phaser.Math.FloatBetween(0.4,0.8)); });
Step 8
In create add keyboard controls so the player can move using arrow keys: cursors = this.input.keyboard.createCursorKeys();
Step 9
In create add a score text on the screen to show points: scoreText = this.add.text(16,16,'Score: 0',{ fontSize: '20px', fill: '#fff' });
Step 10
Still in create tell Phaser to check when the player overlaps a star and call a collect function: this.physics.add.overlap(player, stars, collectStar, null, this);
Step 11
Add the collectStar function to disable the collected star increase the score and update the score text so collecting works: function collectStar(player, star) { star.disableBody(true,true); score += 10; scoreText.setText('Score: ' + score); }
Step 12
Add the update function to read the arrow keys each frame and set the player's velocity so the sprite moves smoothly: function update() { player.setVelocity(0); if (cursors.left.isDown) { player.setVelocityX(-200); } else if (cursors.right.isDown) { player.setVelocityX(200); } if (cursors.up.isDown) { player.setVelocityY(-200); } else if (cursors.down.isDown) { player.setVelocityY(200); } }
Step 13
Run or preview index.html in your browser to test the game and fix small issues like image file names or sizes until the player moves and stars disappear when touched.
Step 14
Share a screenshot or short description of your finished game and what you learned by posting your project on DIY.org.
Final steps
You're almost there! Complete all the steps, bring your creation to life, post it, and conquer the challenge!

Help!?
What can I use if I can't access the Phaser CDN or don't have player.png and star.png?
Download phaser.min.js into your project and change the head tag to <script src='phaser.min.js'></script>, and either rename local image files to player.png and star.png or create temporary sprites with this.add.rectangle in the create function.
Why does the player sometimes not move or stars not disappear when I touch them?
Check the browser console for 404 or runtime errors, confirm preload lists 'player' and 'star' with the exact filenames you placed in the project, ensure create uses this.physics.add.sprite and this.physics.add.group so physics bodies exist, and verify update reads cursors (cursors = this.input.keyboard.createCursorKeys()) and the overlap uses collectStar.
How can I adapt the activity for younger or older children?
For younger kids, reduce stars (set repeat: 3), use larger player/star images and slower velocities (setVelocityX/Y to ±100), and for older kids add enemies, timers, higher speeds, more stars, or extend collectStar to track combos and levels.
What are simple ways to extend or personalize the finished game?
Add sound by using this.load.audio in preload and this.sound.play in collectStar, create player animations with this.load.spritesheet and this.anims.create, or change collectStar to respawn stars with star.enableBody(true, x, y, true, true) and tweak scoreText formatting.
Watch videos on how to create a simple browser game using a JavaScript game engine
Facts about JavaScript game development for kids
⌨️ Keyboard controls use keydown and keyup events so characters can move smoothly while a key is held down.
⚡ Phaser is an open-source 2D HTML5 game framework first released in 2013 and loved for quick prototyping.
🕹️ JavaScript runs in every modern web browser, so players can play browser games without installing anything.
🧩 Sprites are packed images or frames; sprite sheets can hold dozens of animations in a single file to speed up games.
🎮 With a game engine, simple playable games like platformers or shooters can often be made in just a few hours.
Get 7 days of DIY for FREE!