Udemy
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  
Turn what you know into an opportunity and reach millions around the world.
Learn More
Your cart is empty.
Keep shopping
How to Code JavaScript Games: A 2D Shooter with HTML5 Canvas
Rating: 4.8 out of 5(48 ratings)
689 students

How to Code JavaScript Games: A 2D Shooter with HTML5 Canvas

Learn to develop a 2D geometric shooter by combining programming concepts with geometry and physics
Created byChristopher Lis
Last updated 5/2022
English

What you'll learn

  • Project Setup
  • Player Creation
  • Projectile Creation
  • Enemy Creation
  • Collision Detection
  • Garbage Collection
  • Particle Explosion Creation
  • Score Tracking
  • Refactoring and Performance Techniques
  • User Interface Creation
  • User Interface Animation
  • Player Movement
  • Different Types of Enemies (Homing, Spinning, and Homing-Spinning)
  • Power-Ups
  • Interactive Background Particles
  • Sound Effects and Music
  • Mobile Responsive Techniques
  • Mobile Events and Testing
  • Deployment

Course content

2 sections30 lectures6h 32m total length
  • Project Setup9:33
  • Create a Player8:11

    Let's set up a basic player class that we'll use to create and render our game's hero: a small white circle placed in the middle of the screen.

  • Shoot Projectiles20:16

    Here we'll give our hero a semi-automatic cannon which we can shoot whenever we click on the canvas. We'll use some event listeners and a little bit of math to achieve this effect.

  • Create Enemies13:29

    Now we need some baddies. Our enemies are going to be circles of different sizes that come outwards from the edges of the screen and move inwards towards the center in an attempt to destroy our player.

  • Detect Collision on Enemy and Projectile Hit6:18

    Here we'll learn how to detect collision between our enemies and projectiles. We need a way to defend ourselves correctly, so let's implement it.

  • Detect Collision On Enemy and Player Hit3:08

    If an enemy touches us, what happens? Yes that's right, we die. Here we'll learn how to code this effect using the same collision detection method we used for our projectiles.

  • Remove Off Screen Projectiles4:18

    Projectiles that aren't rendered on the screen are pretty worthless, therefore, we need to write some code that removes them. Let's use this lesson to ensure our game is as performant as possible with garbage collection.

  • Colorize Game5:53

    Life is dull without colors, so let's add some. We're going to learn how to apply varying colors to each of our enemy particles as they travel throughout our game.

  • Shrink Enemies on Hit6:50

    Enemies can disappear instantaneously, but it would be even cooler if we could make them shrink into nothingness instead. We'll use a popular animation library called GSAP to achieve this effect.

  • Create Particle Explosion on Hit11:20

    When a projectile hits an enemy, yes the enemy should shrink, but they should also go boom. With a few particle physics techniques, we'll learn how to create an explosion effect that almost resembles a firework whenever a projectile hits an enemy.

  • Add Score11:27

    A shooter game like this would not be complete without a score (it could be, but wow would it be boring). Here we'll utilize HTML to create a score label that updates whenever we shoot off enemies.

  • More Accurate Object Removal14:06

    Currently to remove objects from our game we loop through the front of our array, then call a splice method. Although this'll work when we use in pairing with setTimeout, it will cause issues later on once our game gets more complex and requires more resources. As a result, here we will refactor any forEach loop, that also uses splice, to loop through its contents starting from the back of the array.

  • Add Game Over UI18:23

    With some basic HTML and CSS magic, we can create a really clean interface that displays when our game should begin and when it is over. It doesn't have to be complicated, and we can make this as dependency free as possible by not using any external libraries.

  • Add Restart Button13:35

    We need a way to restart our game, because if we lose, we'd probably like to play again (as long as our game isn't garbage). Let's implement a restart button to finish off the first module of our game.

  • Add Start Game Button6:32

    It would be a bit jarring if we forced our player to play the game as soon as it finished loading. Rather, we want the user to initiate an actual play through so they can begin whenever they feel ready. To achieve this effect, we'll create a simple "Start Game" modal in which a user can click a button to begin.

  • UI Animations12:45

    User Interface (UI) animations are a nice way to bring a bit of professionalism to your game. They also help the user understand how or why something appeared or disappeared as they show the UI element's action over time rather than immediately affecting something.


    This episode will show you how to utilize GSAP to fade out your start game modal when you click the start game button, and how to fade in that same modal when you end up losing the game.

Requirements

  • A basic understanding of JavaScript (know how to create functions, know differences between var, let, and const; etc.)
  • How to push to a GitHub repo (only required for the last lesson on deployment)

Description

PLEASE READ: This is a freemium course—the first 1-2 hours are free (you can watch right here on Udemy [or YouTube] with each video's "Preview" button), while the remaining 4-5 hours require course purchase. I've always been a big advocate of spreading the basics to as many people as possible, as I believe knowledge and personal growth are some of the best ways to better our world as a whole. Enjoy.

Welcome to the JavaScript Games 101 course, where you will learn how to create your very first 2d, geometric, shooter-style JavaScript game.

My name is Christopher Lis, and I'm an award winning Full-Stack Engineer with over ten years of web development experience. I've directly worked with clients like Harvard University, The Basketball Tournament, and premium award winning agencies like Brave People.

The goal of this course is to give you the skillset required to code your own JavaScript games from scratch. Many game dev fundamentals are covered in this course, and much of what you'll learn uses hand-written math functions rather than hidden away abstractions that game dev libraries typically provide.

In this course, you'll learn everything from:


- Project Setup

- Player Creation

- Projectile Creation

- Enemy Creation

- Collision Detection

- Garbage Collection

- Particle Explosion Creation

- Score Tracking

- Refactoring and Performance Techniques

- User Interface Creation

- User Interface Animation

- Player Movement

- Different Types of Enemies (Homing, Spinning, and Homing-Spinning)

- Power-Ups

- Interactive Background Particles

- Sound Effects and Music

- Mobile Responsive Techniques

- Mobile Events and Testing

- Deployment


And so much more.

If you're serious about taking your game dev skills to the next level, then let me guide you through the full production of a 2D game that's ready for production launch.

Who this course is for:

  • This course is for beginner JavaScript developers looking to get into the realm of game development.