Ebiten Game Development: First Steps

    Ebiten Game Development Series: Part 1: First Steps | Part 2: Core Concepts → What is Ebiten? Ebiten is a dead-simple 2D game engine for Go. Unlike heavyweight engines with complex editors and asset pipelines, Ebiten gives you a minimalist foundation: a game loop, a way to draw pixels, and input handling. Everything else? You build it yourself. This simplicity is Ebiten’s superpower. You’re not fighting an editor or memorizing a sprawling API. You write Go code that runs 60 times per second and draws rectangles. From those humble beginnings, you can build anything from Pong to procedurally generated roguelikes. ...

    December 15, 2024 · 12 min · Rafiul Alam

    Managing UI Navigation with Pushdown Automata in Ebitengine

    The UI Navigation Problem Game UI often involves stacked screens: you open a pause menu, then settings, then graphics options, then a confirmation dialog. Each screen needs to: Pause the screen beneath it Handle input independently Resume the previous screen when closed Maintain state across transitions Simple state machines fall short here. You need something that can track a stack of states. Enter the pushdown automaton. What is a Pushdown Automaton? A pushdown automaton is a state machine with a stack. Instead of just transitioning between states, you can: ...

    November 3, 2024 · 8 min · Rafiul Alam

    Saving Game State: Implementing the Memento Pattern with encoding/gob

    The Save/Load Problem Every game needs to save player progress. But how do you capture the entire game state without exposing internal implementation details? How do you support undo/redo, time travel debugging, or replay systems? The Memento pattern solves this by capturing and externalizing an object’s internal state without violating encapsulation. Combined with Go’s encoding/gob package, you get powerful, type-safe serialization for game saves, undo systems, and more. The Naive Approach Here’s what not to do: ...

    October 12, 2024 · 9 min · Rafiul Alam

    Goal-Oriented Action Planning (GOAP): Writing Smarter NPCs in Go

    Beyond Scripted AI Most game NPCs follow scripted behaviors or state machines: “If enemy seen, attack. If health low, flee.” While predictable and easy to implement, these approaches lack the intelligence to adapt to changing circumstances. What if your NPC could plan their own actions based on goals? Goal-Oriented Action Planning (GOAP) empowers NPCs to dynamically create plans to achieve their goals. Used in games like F.E.A.R. and The Sims, GOAP creates emergent, intelligent behaviors that feel surprisingly alive. ...

    September 19, 2024 · 9 min · Rafiul Alam

    Data-Oriented Design: Implementing ECS (Entity Component System) with Go Generics

    From Object-Oriented to Data-Oriented Traditional object-oriented programming (OOP) encourages you to model game entities as objects with inheritance hierarchies. While intuitive, this approach leads to poor cache locality, rigid hierarchies, and performance bottlenecks. Data-oriented design, particularly the Entity Component System (ECS) pattern, flips this on its head. With Go 1.18+ generics, we can now build type-safe ECS architectures that deliver both performance and flexibility. Let me show you how. The OOP Problem Here’s the typical OOP approach to game entities: ...

    July 8, 2024 · 9 min · Rafiul Alam

    Building Modular Game AI: Implementing Behavior Trees with Go Interfaces

    Why Behavior Trees for Game AI? If you’ve ever built game AI using finite state machines, you’ve likely hit their limitations: rigid transitions, difficulty composing behaviors, and maintenance nightmares. Behavior trees offer a more flexible, modular approach that’s become the industry standard for game AI. In this post, I’ll show you how to implement behavior trees in Go using interfaces, creating reusable AI components that can power everything from enemy NPCs to complex AI companions. ...

    May 22, 2024 · 10 min · Rafiul Alam