
Every browser game starts with an HTML canvas element. In this part we create the project skeleton: one HTML file and one CSS file.
In the HTML file, we add a `<canvas>` as a drawing surface; JavaScript will paint everything onto it later.
We also add a global CSS reset and centre the canvas on a dark background so the game already looks good before a single pixel is drawn.
Now we bring the canvas to life with JavaScript. We grab the canvas element, get its 2D drawing context, set its pixel dimensions, and draw a coloured rectangle — our first "fighter" placeholder
In this part, we add the gravity to the game and detect player rectangle hitting the ground.
In order to make game more fun, we add the ability to jump. We also check the "jump in jump" possibilty.
We listen to keyboard actions from user(s) in order to determine the player(s) movements to left and right.
We listen to keyboard actions from user(s) in order to determine the player(s) movements to left and right.
No game is fun without some cool image and art.
In this part we begin adding art to our game using javascript and it will be the background.
Sprites :
King
https://luizmelo.itch.io/medieval-king-pack-2
Huntress
https://luizmelo.itch.io/huntress
Skeleton
https://monopixelart.itch.io/skeletons-pack
Cave background
https://cubeasset.itch.io/deep-cave-platformer+
Sound effects :
https://pixabay.com
It makes sense to have some animated sprites as well. For decoration, we add a skeleton character to the game in this part.
Sprites :
King
https://luizmelo.itch.io/medieval-king-pack-2
Huntress
https://luizmelo.itch.io/huntress
Skeleton
https://monopixelart.itch.io/skeletons-pack
Cave background
https://cubeasset.itch.io/deep-cave-platformer+
Sound effects :
https://pixabay.com
We continue on placing the skeleton with correct aspect ratio and position.
Sprites :
King
https://luizmelo.itch.io/medieval-king-pack-2
Huntress
https://luizmelo.itch.io/huntress
Skeleton
https://monopixelart.itch.io/skeletons-pack
Cave background
https://cubeasset.itch.io/deep-cave-platformer+
Sound effects :
https://pixabay.com
We introduce the idea of sprite animation in this part making our skeleton more alive.
Sprites :
King
https://luizmelo.itch.io/medieval-king-pack-2
Huntress
https://luizmelo.itch.io/huntress
Skeleton
https://monopixelart.itch.io/skeletons-pack
Cave background
https://cubeasset.itch.io/deep-cave-platformer+
Sound effects :
https://pixabay.com
We introduce the idea of sprite animation in this part making our skeleton more alive.
Sprites :
King
https://luizmelo.itch.io/medieval-king-pack-2
Huntress
https://luizmelo.itch.io/huntress
Skeleton
https://monopixelart.itch.io/skeletons-pack
Cave background
https://cubeasset.itch.io/deep-cave-platformer+
Sound effects :
https://pixabay.com
We add the scaling capability to the sprite in this part.
Sprites :
King
https://luizmelo.itch.io/medieval-king-pack-2
Huntress
https://luizmelo.itch.io/huntress
Skeleton
https://monopixelart.itch.io/skeletons-pack
Cave background
https://cubeasset.itch.io/deep-cave-platformer+
Sound effects :
https://pixabay.com
We define the Fighter class using functions. This class will inherit the Sprite class and behaviours. Later, we will add more methods and properties specific to the class.
The update function in Fighter class is a bit different from the one on the Sprite. We will work on that in this part.
We add the offset property to the Fighter class which will place the character correctly based on its rectangle.
All fighter games need at least one enemy. In this part we add an enemy from the Fighter class.
Sprites :
King
https://luizmelo.itch.io/medieval-king-pack-2
Huntress
https://luizmelo.itch.io/huntress
Skeleton
https://monopixelart.itch.io/skeletons-pack
Cave background
https://cubeasset.itch.io/deep-cave-platformer+
Sound effects :
https://pixabay.com
In this part, we add the game hud. This section will be done in html with divs and cc styles.
Now is the time to add the ability to attack to the fighters. We lay the floor for more sprite actions like jump, run, fall, take hit and death.
Sprites :
King
https://luizmelo.itch.io/medieval-king-pack-2
Huntress
https://luizmelo.itch.io/huntress
Skeleton
https://monopixelart.itch.io/skeletons-pack
Cave background
https://cubeasset.itch.io/deep-cave-platformer+
Sound effects :
https://pixabay.com
We need to have an attack box defined so we can detect a hit or a miss when attack happens. In this part we will work on that.
Continue on adding more sprites, we build the run sprite.
Sprites :
King
https://luizmelo.itch.io/medieval-king-pack-2
Huntress
https://luizmelo.itch.io/huntress
Skeleton
https://monopixelart.itch.io/skeletons-pack
Cave background
https://cubeasset.itch.io/deep-cave-platformer+
Sound effects :
https://pixabay.com
Now that player can run, it will be awesome to add sprites for vertical movement. Jumping and falling will be added in this section.
Sprites :
King
https://luizmelo.itch.io/medieval-king-pack-2
Huntress
https://luizmelo.itch.io/huntress
Skeleton
https://monopixelart.itch.io/skeletons-pack
Cave background
https://cubeasset.itch.io/deep-cave-platformer+
Sound effects :
https://pixabay.com
We tweak the attack sprite based on the attackbox in this section. This will be used in next parts to detect the hit correctly.
Sprites :
King
https://luizmelo.itch.io/medieval-king-pack-2
Huntress
https://luizmelo.itch.io/huntress
Skeleton
https://monopixelart.itch.io/skeletons-pack
Cave background
https://cubeasset.itch.io/deep-cave-platformer+
Sound effects :
https://pixabay.com
We detect the hit in this part and add the hit sprite to the fighter class.
Sprites :
King
https://luizmelo.itch.io/medieval-king-pack-2
Huntress
https://luizmelo.itch.io/huntress
Skeleton
https://monopixelart.itch.io/skeletons-pack
Cave background
https://cubeasset.itch.io/deep-cave-platformer+
Sound effects :
https://pixabay.com
We detect the hit in this part and add the hit sprite to the fighter class.
We add the death sprite and make the game logic compatible by the death condition.
Sprites :
King
https://luizmelo.itch.io/medieval-king-pack-2
Huntress
https://luizmelo.itch.io/huntress
Skeleton
https://monopixelart.itch.io/skeletons-pack
Cave background
https://cubeasset.itch.io/deep-cave-platformer+
Sound effects :
https://pixabay.com
We will work on the counter that we added to the hud long ago.
We define the Game End scenario and add the logic to the game.
We display the fight result in this part.
In this section we add three sounds to the game and use them for attack and also when a player wins.
Sprites :
King
https://luizmelo.itch.io/medieval-king-pack-2
Huntress
https://luizmelo.itch.io/huntress
Skeleton
https://monopixelart.itch.io/skeletons-pack
Cave background
https://cubeasset.itch.io/deep-cave-platformer+
Sound effects :
https://pixabay.com
We lay the floor for the enemy AI by writing the mode selection part.
In that, the user can select to either play a 2 player game or play against computer.
We lay the floor for the enemy AI by writing the mode selection part.
In that, the user can select to either play a 2 player game or play against computer.
We split the enemy control logic to two parts so AI can take over when playing against computer.
We add logic so that the enemy follows the player and keeps a reasonable distance from it.
We add logic so that the enemy can attack the player randomly.
We add logic so that the enemy can do jumps randomly so the game gets more exciting.
This hands-on course teaches you how to build a complete 2-player browser fighting game from the ground up using only HTML, CSS, and vanilla JavaScript. There are no frameworks to learn, no npm installs, and no hidden magic — just you, your editor, and the browser. By the end, you’ll have a polished game featuring animated sprite-sheet characters, responsive two-player controls, attack hit-detection, health bars, a countdown timer, a mode-selection screen, and an AI-controlled opponent.
The course is split into multiple progressive parts, each one building directly on the work from the previous lesson. You’ll start by setting up the canvas and drawing your first shapes, then add gravity, jumping, and movement. From there you’ll load sprite sheets, build a reusable Sprite class, and evolve it into a full Fighter class with physics and animations. Once both fighters are on screen, you’ll wire up keyboard input, design a HUD with health bars and a timer, implement attack and hit-detection logic, and create an animation state machine that smoothly switches between idle, run, jump, attack, hit, and death animations.
Along the way, you’ll learn the core concepts that power virtually every 2D game:
the game loop,
delta-time updates for consistent gameplay across different monitors,
collision detection,
input handling,
sprite animation,
state management.
The final chapters add the polish that separates a prototype from a real game
a mode-selection screen,
countdown intro,
two-player mode,
an AI opponent,
an FPS cap,
and a game-over flow.
This course is ideal for developers who already know the basics of HTML, CSS, and JavaScript and want to break into game development or simply build something fun and impressive. No prior game-dev experience is required. All you need is a code editor (VS Code recommended) and a modern browser. Fire up your editor, open the starter files, and let’s build a game.