Creating a 2D game just with JavaScript
Beto, May 30, 2022 · 1,065 views
No frameworks, no build tools, no game engine. Just three files (, , ) and the HTML canvas. Building a game this way is one of the best ways I know to actually understand how the web works, because there's nothing hiding the fundamentals from you. I build the whole foundation on camera, from empty folder to a canvas ready for rendering.
What's inside
- Set up a clean project with just HTML, CSS, and JavaScript
- Link stylesheets and scripts so they load in the right order
- Auto-reload the browser on every save with BrowserSync
- Draw and animate on the HTML canvas element
- Lay the groundwork for keyboard input, physics, and collisions
Resources

CourseReact with TypeScript course
Once you know the fundamentals, level up to building real interactive apps with React and TypeScript.
Had a win? Get featured on Code with Beto.Share your story
Like this article? Get the rest of the library plus weekly React Native tips. Free.