
Every 2D game begins with the same core systems: a canvas, a game loop, input handling, asset loading, and menus. Understanding how they work and fit together is what separates copying code from engineering a game.
In this class, you'll build a base for 2D games from scratch in vanilla JavaScript. These are the core systems that sit at the heart of any 2D game engine. There are no frameworks and no libraries. You'll write clean, modular ES6 code that you can extend into your own HTML5 Canvas games.
WHAT YOU'LL BUILD
A working base for 2D games with a clear, modular project structure:
A rendering system built on the HTML5 Canvas, with a fixed game resolution that scales responsively to any screen while keeping a 16:9 ratio
A game loop using requestAnimationFrame and delta time, so movement stays consistent at any frame rate
An image asset manager with promise-based loading, a loading screen, and graceful fallbacks if an image fails to load
A keyboard input system (WASD and arrow keys) that handles edge cases like losing window focus
A game state flow with a main menu, play, pause, and quit-to-menu
An HTML/CSS user interface layered on top of the canvas for menus, pause, and loading screens
A player entity with smooth movement, normalized diagonal speed, screen boundaries, and a speed multiplier ready for upgrades
A modular ES6 architecture (core, entities, managers, systems) that is easy to read and extend
WHY VANILLA JAVASCRIPT, AND WHY FROM SCRATCH?
Frameworks hide the things you most need to understand. When you build these systems yourself, you stop copying code and start engineering. You'll learn why a game loop needs delta time, how canvas scaling works, and how to organize game code so it doesn't turn into a tangle. That understanding carries over to any language or game engine.
Let's build the base for your next 2D game, one clean module at a time.