Building a 2D Game Engine from Scratch: The GameEngineSeries Journey
Join me as I build a complete 2D game engine from the ground up using modern web technologies. Learn about the BHVR stack, Entity-Component-System architecture, and the philosophy behind building complex systems one step at a time.
The Vision
What does it take to build a game engine from scratch? Not just any engine, but one that's modular, browser-based, and built with modern web technologies? That's exactly what I set out to discover with my GameEngineSeries project.
This isn't your typical "move fast and break things" tutorial. Instead, I'm taking a deliberate, architectural approach—focusing on understanding why we make certain decisions, not just how to implement features quickly.
The BHVR Stack: A Modern Foundation
The foundation of this project is what I call the BHVR stack:
- Bun - Lightning-fast runtime and package manager for rapid workspace management
- Hono - Lightweight HTTP framework perfect for development tooling
- Vite - Modern build tool with hot module reloading for instant feedback
- React - UI framework powering the game editor interface
Plus TypeScript throughout for type safety across all packages. This stack isn't the game engine itself—it's the development conduit that makes building the engine a smooth, enjoyable experience.
Architecture: Clarity Over Optimization
The engine follows a clean, understandable pipeline:
Editor → Core → Engine → RendererEach layer has a specific responsibility:
- Editor: React-based interface for game development
- Core: Game state and logic management
- Engine: Core game loop and systems coordination
- Renderer: Canvas 2D rendering implementation
This modular approach means each piece can be understood, tested, and improved independently.
The Episode Structure
The series is organized hierarchically: Epics → Chapters → Episodes. Each episode is a focused, ~15-minute video tackling one specific architectural question.
So far, we've published three episodes:
- Repository Layout and Scripts (
ep01-ch01-ep01-repo-layout-and-scripts) - Setting up the workspace structure and development tooling - Renderer Foundations (
ep01-ch01-ep-02-foundations-renderer) - Building the Canvas 2D renderer from scratch - Core Loops and State Management (
ep01-ch01-ep03-core-loops-and-state-management) - Implementing the game loop and managing state
Each episode has its own Git branch and worktree, making it easy to follow along or jump to specific topics.
What's Coming Next
The roadmap for upcoming episodes is exciting:
- Episodes 4-7: Entity-Component-System (ECS) implementation
- Systems architecture and behavior
- Editor UI development with React
- Interactive features like selection and live updates
- A complete vertical-slice game to tie it all together
Philosophy: Focus on Structure
The core philosophy of this series is simple: prioritize understanding. Rather than rushing to build features, we take time to:
- Understand architectural decisions
- Write clean, readable code
- Build systems that are extensible and maintainable
- Learn by doing, not by copying
This isn't about creating the fastest or most feature-rich engine—it's about truly understanding how game engines work at a fundamental level.
Getting Started
Want to follow along? The entire project is open source under the MIT license. Here's how to get started:
git clone https://github.com/CodingButter/GameEngineSeries.git
cd GameEngineSeries
bun install
bun run devYou can check out different episode branches to see the progression:
git checkout ep01-ch01-ep01-repo-layout-and-scripts
git checkout ep01-ch01-ep-02-foundations-renderer
git checkout ep01-ch01-ep03-core-loops-and-state-managementJoin the Journey
Building a game engine is a massive undertaking, but breaking it down into digestible episodes makes it accessible to everyone. Whether you're a seasoned game developer or just curious about how engines work, there's something to learn.
The beauty of this approach is that you're not just watching—you're building alongside me, understanding each decision, and gaining the knowledge to make your own architectural choices.
Check out the repository: GameEngineSeries on GitHub
Stay tuned for more episodes, and let's build something amazing together!