Udemy
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  
Turn what you know into an opportunity and reach millions around the world.
Learn More
Your cart is empty.
Keep shopping
Learn Game Development with JavaScript
Rating: 4.5 out of 5(383 ratings)
11,709 students

Learn Game Development with JavaScript

Make your own animated 2D games
Created byFrank Dvorak
Last updated 10/2024
English
English [Auto],

What you'll learn

  • Build 2d games with HTML, CSS & JavaScript, no frameworks and no libraries
  • Explore web animation techniques with HTML canvas element
  • Practice Object Oriented Programming
  • Discover and learn 5 fundamental techniques of 2D game development and use them in a real project

Course content

1 section38 lectures2h 53m total length
  • HTML & CSS setup1:36

    Create a basic web page using HTML, CSS, and JavaScript, include a canvas element, and apply a global reset and border-box to center the canvas for cross-browser consistency.

  • Basic JavaScript setup2:17

    Wire a window load event to start the game script, create a 2D canvas context, and scale a 500 by 500 canvas to fit the browser.

  • Object Oriented Programming with JavaScript2:26

    Explore object oriented programming in JavaScript, a prototype-based language that uses class syntax and encapsulation to organize game logic into dedicated classes, with step-by-step guidance on inter-class communication.

  • Creating Player & Game objects5:53

    Use constructors and the new keyword to create a game object that automatically creates a player, passes the game reference, and updates and draws the player on a canvas context.

  • Animation loop3:17

    Create an animation loop with update and draw methods at 60 fps via requestAnimationFrame, rendering a canvas player controlled by up and down arrows and clearing the canvas every frame.

  • Keyboard inputs9:39

    Demonstrates keyboard input handling in a JavaScript game using an input handler, keydown and keyup listeners, and a game-wide keys array to control player movement.

  • Creating projectiles7:06

    Define a projectile class with constructor(game, x, y), 10x3 size and speed 3, including update and draw; manage marked for deletion beyond 80% width and store projectiles in array.

  • Periodic events5:08

    Learn to implement periodic events in a JavaScript game by using delta time from requestAnimationFrame timestamps to recharge ammo every 500 milliseconds within update loop, with timer and max ammo.

  • Draw game UI2:49

    Visualize ammo recharge by drawing rectangles for each projectile with a UI class and draw method, using the context to show spacing, color, and max ammo of 50 on screen.

  • Base enemy class7:58

    Design a base enemy class with inheritance to create multiple enemy types, enabling right-to-left movement, off-screen deletion, and sprite rendering in the main game loop.

  • Collision detection between rectangles5:17

    Implement a reusable collision detection function for rectangle objects (x, y, width, height) to detect player-enemy and enemy-projectile collisions, updating lives, score, and deletions in the game loop.

  • Drawing game score3:14

    Define a ten-point winning score and end the game when surpassed, while rendering the score on the UI canvas with styled text and canvas shadows scoped by save and restore.

  • Win and lose condition2:02

    Explain win and lose conditions based on score within a time window, display centered messages on canvas, showing you win or you lost with well done and try again text.

  • Counting game time3:14

    Set a 5-second time limit and track game time with delta time, updating an on-screen timer and triggering game over, while preventing score gains after game over.

  • Animated parallax backgrounds10:13

    Create a parallax background in a JavaScript canvas game by layering four images with individual speed modifiers, a background manager, and a drawing order that places the player on top.

  • Sprite animation with JavaScript3:42

    Load the player image from index.html and animate a seahorse sprite sheet with swimming and power up frames. Use the nine-argument drawImage to crop frames and cycle through max frames.

  • Creating a debug mode1:36

    Learn to implement a debug mode in a JavaScript game by toggling hitbox visibility and collision-related visuals with the D key, controlling a debug property in the game class.

  • Animating enemy sprite sheets6:37

    Introduce three anglerfish animation types and a lucky fish power-up, using sprite sheets to randomly assign animations and manage frame x/y in the game loop for varied, dynamic enemies.

  • Night Angler enemy class2:23

    Add a second anglerfish enemy type with two animations and a 50/50 spawn of angler one or angler two, increasing game time to 15 seconds, differing lives and score points.

  • Lucky Fish enemy class1:21

    Lucky fish enemy subclass added with three lives and a 15-point reward; set type to lucky, enable random spawning with anglers, and fix animation by using the correct sprite sheet.

  • Collecting power ups7:48

    Collect lucky fish to trigger a power up mode with a 10-second delta-time timer, dual lasers from mouth and tail, and faster ammo recharge.

  • Drawing projectiles as images1:11

    Learn to render projectiles as images on a canvas by loading an image and drawing it with drawImage at x and y, and explore sprite sheets and particle effects.

  • Custom fonts and game text2:41

    Add a font from Google Fonts (bangers) to the game, apply it to UI text, and adjust size and spacing for win and lose messages in a Victorian steampunk theme.

  • Cleaning up2:08

    Hide the projectile image and reveal hit boxes and lives only in debug mode, clamp vertical movement to game boundaries, and allow half the sprite to extend offscreen.

  • Particle effects and physics12:12

    Create a particle class to generate randomized sprite parts when enemies are hit or destroyed, attach gravity and bounce physics, and render them from a sprite sheet on canvas.

  • Particle rotation3:43

    Rotate particles on canvas by giving each a unique angle, translating to its center, and applying rotation in radians inside a save-restore block for independent, smooth motion.

  • Tweaks and fixes2:59

    Disable debug mode by default, hide indicators on load. Power-ups activate from power-up fish; ammo refills occur below max; adjust bounce and draw order so user interface stays on top.

  • Hive Whale enemy class2:59

    In a power up mode, introduce a hive whale enemy in a JavaScript game that splits into five drones after defeat, adding tactical decisions and extended challenge.

  • Drone enemy class4:43

    Explore the drone enemy class, ambush predators that spawn five drones from destroyed hives, each with random speeds, three lives, and three-point score rewards.

  • Dust effect animation15:06

    Learn to animate dust and fire effects using sprite sheets, with a parent explosion class and two subclasses for smoke and fire, controlled by delta time and frames per second.

  • Fire effect animation1:28

    Learn how to implement a shared explosion system in JavaScript by refactoring fire and smoke sprite sheets into a parent class, enabling dynamic fire or smoke effects with 200x200 frames.

  • Tuning game difficulty3:22

    Tune game difficulty by adjusting time limit, winning score, ammo recharge, lives, and enemy spawn variety; ensure score is not affected after winning or losing, with a 30-second limit.

  • Bulb Whale enemy class1:57
  • Moon Fish enemy type2:40

    Learn to implement Moon Fish as a fast, high-health enemy that triggers a power-up when destroyed from distance, rewarding strategic, high-skill play.

  • Sounds6:41

    Create a JavaScript sound controller to rewind and play audio clips such as power, explosion, shot, hit, shield, and power down, linked via index.html.

  • Animated shield7:34

    Create a shield class that animates a shield sprite sheet over the player on enemy collision, using delta time and FPS control, while the invincible player incurs a point penalty.

  • Animated projectiles4:09

    Learn to implement animated projectiles in canvas using a projectile class, with a seahorse firing a four-frame fireball sprite sheet at 20 fps and anime types Stalker and Razer Finn.

  • What's next?2:01

    Improve game performance in JavaScript by optimizing graphics and animation, including object pooling, multi-canvas drawing, reduced shadows, spawn rate adjustments, and sprite sheet/frame rate tuning for older devices.

Requirements

  • Basic knowledge of HTML, CSS & JavaScript is needed to follow this course
  • Access to code editor and internet browser

Description

Games should be exciting, full of secrets and special features! Let me take you step by step though my creative process and show you how I build unique game worlds for players to have adventures in. I will explain every line of code as we write it. Let's practise object oriented programming and use HTML, CSS and plain vanilla JavaScript to build a game. There will be no frameworks and no libraries, because we want deep understanding of how things work under the hood.


Let's explore an alien planet and it's mechanical life forms in a steampunk themed 2D side scroller. We will learn how to implement:

  • Sprite animation

  • Parallax backgrounds

  • Collision detection

  • Power ups

  • Different enemy types that alter the gameplay

  • and many other features of 2D game development

If you are a beginner front end web developer curious about game development, creative coding & web animation, come join me and learn how to create beautiful visuals for your games, and how to implement unique game features that will make your project stand out. Have fun!


(In this class I am giving away a lot of free game art assets for characters, environments and props. These were created by me or artists I hired, there is no copyright. Feel free to use them for any of your personal projects if you want. )

Who this course is for:

  • Beginner front end web developers curious about animation and 2D games
  • Coding students