
Explore building 2D games in Go with Ebiten, covering sprites, movement, and advanced collision detection using the resolve library, plus sound, timing, and cross-platform deployment.
Learn how to install Go from the Go.dev downloads page, choose the right package for your system—Windows, Mac with Apple silicon or Intel, or Linux—and verify with go version.
Install Visual Studio Code as your Go development environment, then add the official Go extension and Go template syntax extension, using the command palette to install and update tools.
Prepare Ebiten development environment by installing Go 1.22+, a C compiler (macOS: clang or Xcode) and running the environment check; Windows needs no C compiler.
Learn how to seek help effectively when solving problems in Go game development, by online search, downloading the lecture source code, and sharing your git repository link.
Windows users on WSL must prefix go run with GOOS=windows to run the game in the VS Code terminal; otherwise you’ll see file-not-found errors.
Set up a go ebiten project in vs code, initialize go.mod, fetch ebiten v2, and implement a minimal game with update, draw, and layout to launch an empty window.
Create the player sprite by loading assets/player.png from an embedded assets file system, using must load image to decode PNG for the Everton game engine.
Create a dedicated player object in a new file to manage the player sprite with a new player factory, plus a draw method and an update routine.
Draw the player sprite to the screen by integrating a player field into the game, creating the player with a game reference, and invoking the draw call with the screen.
Rotate the player sprite with left and right arrow keys by updating a rotation state in Ebiten, centering the rotation in the draw step.
Move the player forward by tracking an x and y position as a vector, normalizing movement, and updating velocity with acceleration and rotation, while appearing at the opposite edge.
Implement screen wrap for the player in a Go game by defining screen width and height, adding a keep-on-screen routine, and centering the player at spawn.
Set up a scene manager to transition between title, game, and game over scenes with fade effects, and implement Ebiten's game interface (update, draw, layout) in main.go.
Build a scene manager in Go asteroids with Ebiten to switch between title and game scenes, using a fading transition, update and draw methods, and a stateful input system.
Define a game struct that holds a scene manager and an input stub, implement update, draw, and layout to satisfy the run game interface, and wire input passing to scenes.
Create a game scene with a scene manager and a game scene struct that holds a player, plus a new_game_scene constructor, and implement update, draw, and layout.
Update the player to reference a game scene via a scene manager, adjust main setup and scene transitions, and wire the go asteroids game to launch the new game scene.
Run the updated scene manager with go run . to test rotations and movement. Add a title scene that displays text and learn to switch scenes in the next lecture.
Add a title scene managed by the scene manager, render centered one coin, one play text with a loaded font, and switch to the game scene on spacebar.
Update the game to the stable text v2 package by converting the title scene and assets to use the new text v2 font face source and io.Reader, with centered layout.
Implement a meteor type and draw and update methods to render multiple moving, rotating meteors on the title screen, then integrate them into the game scene using Ebitengine in Go.
Load and organize meteor textures in Go by implementing mustLoadImages to load all meteor images from assets, creating sprite slices for big and small meteors.
Set up meteor objects with center-directed spawns, randomized angles and velocities, and rotation, using sprites from assets; include a factory for big meteors and four small meteors.
Define and implement update and draw methods for meteor objects, updating position and rotation from movement, and add a keep on screen check to keep meteors within the game bounds.
Draw multiple meteors on the title screen by storing them in a map, initializing the meteors in update, and drawing each meteor in the title scene's draw loop.
Add meteors to the game scene by introducing spawn logic, timers, and velocity growth. Draw meteors each frame, spawn based on level limits, and speed them up over time.
Implement simple collision detection in Ebiten using the resolve library, set up a game space, and create collision objects for the player, meteors, lasers, and aliens, managing addition and removal.
Add the resolve package to enable collision detection in the project, pinning to version 0.8 to stabilize the API and update go.mod.
We implement collision detection by building invisible collision objects for meteors and the player with the resolve library. We add tags and data and synchronize collision objects to track hits.
Add collision functionality to the player by creating a collision object (resolve circle), update its position to match the player's coordinates, and maintain on-screen bounds like the meteors.
Define a collision space in the game scene, initialize a resolve space with screen dimensions and 16x16 cells, and add the player and meteors to enable collision detection.
Manage a hidden collision space in the game scene, then determine meteor and player intersections in the update loop and print collision data, including the meteor index.
Implement basic 2d gameplay in Go with Ebitengine by moving the player and meteors, firing bursts of three lasers with cooldown, and enabling collision detection with meteors and the player.
Enable player lasers: press spacebar to fire, load a laser sprite, and implement a laser object that moves with rotation and collides with meteors, updated and drawn each frame.
Implement laser firing from the player, manage shoot and burst cooldowns, and track lasers in the game scene to shoot on spacebar with a 50-pixel spawn offset.
Implement laser firing in bursts of up to three using burst and shoot cooldown timers, spawning lasers from the player's rotated position and adding them to the game space.
Learn to shoot meteors with lasers in a go ebiten game, trigger explosion sprites, split large meteors into smaller ones, and manage score and explosion cleanup.
Explore fixing small meteor spawns and removing explosion sprites in a Go and ebitengine 2D game, using an update loop and a cleanup timer to delete meteors and their collisions.
Implement a player destruction sequence in a Go and Ebitengine game. Trigger explosion animation on meteor collision, manage dying and dead states with a timer, and restart the game.
Load sound assets, build a sound player, and play laser, explosion, and looping background sounds to enhance a 2d go game, while adding explosion sprites and background stars.
Load the thrust Ogg Vorbis sound from assets, decode it to a stream, and prepare it for playback during acceleration in the game.
Implement and manage acceleration sound by loading an audio context, creating a thrust player, and playing or pausing the engine sound with up arrow input in ebiten.
Implement an exhaust sprite behind the player that appears only while the up key is held, loading fire.png and tying the exhaust to the player's position and rotation.
Add backward movement with the down arrow, reverse velocity using rotation, spawn exhaust in front, and manage reverse state and engine sound.
Load three laser sound assets from assets, create audio players in the game scene, and play the correct laser sound when firing in bursts with a switch on shots fired.
Load an explosion.ogg asset and create an explosion audio player, then play the sound when shooting big or small meteors and when the player dies.
Load two ogg sounds, beat one and beat two, and play them alternately with a timer that speeds up from 1600 ms toward 400 ms during gameplay.
Generate a starry background for the title scene by drawing random white circles with varying radii and brightness in Ebiten, using no sprites.
Add stars to the game scene and draw them before meteors, storing them as a slice of pointers and generating them in the game scene, with resets to vary positions.
Add levels, display a level transition and restart the game with increased difficulty, implement a game over scene with lives, score, and persistent high scores via a scene manager.
Create a game over scene with stars, meteors, and a centered game over message; use spacebar to restart and q to quit, with scene manager handling transitions.
Load the life indicator sprite from assets, then render three indicators in the top-left corner using color m options to show remaining lives.
Set a three-life start, and display life indicators as a slice of pointers. Learn to populate, draw, and update lives on death, and reset the game when out of lives.
Display the current score, high score, and level centered on screen using separate fonts, with leading zeros and text draw options; update high score and prepare for persistence across plays.
Persist the high score across sessions by writing to a platform-specific text file in the user's directory, loaded on startup, and updated on game over.
Advance to the next level after clearing all meteors; implement a level start scene with a timer, spawn meteors per level, and manage lives and transitions.
Implement a temporary shield and hyperspace. Add a shield sprite around the player for a short time, granting invincibility, and a hyperspace respawn to a safe random location.
Load the shield sprite, shield indicator, and shield sound. Create a shield with position and rotation, update it to follow the player, and draw it in Ebiten.
Display and update the shield in the game scene, activate with the S key, and manage a six second shield timer, including deactivation and removal when the timer ends.
Load shield indicator assets and define a shield indicator type with draw and update. Store indicators in a shield indicators slice, like life indicators, and render them.
Students learn to implement shielded collision physics by bouncing meteors away from the player: reverse and normalize meteor direction, set velocity, and update movement to avoid death on contact.
Implement hyperspace with a visible hyperspace indicator, safe respawn via collision checks, and a 10-second cooldown, including new collider, indicator, and timer logic in Go.
Implement simple game physics for the player by enabling a 30-second drift after releasing the accelerator, adding friction to gradually slow the player and enhance gameplay.
Implement basic inertia by adding a drift where the player coasts up to 30 seconds after thrust release, maintaining the drift angle while decelerating in the update loop.
In this hands-on course, you will learn how to create a classic 2D space shooter game, Asteroids, using the powerful and lightweight Ebitengine library in Go. Whether you’re a beginner to game development or looking to expand your skills in a new language and framework, this course will guide you through the entire process of building your own version of this iconic arcade game.
Ebitengine's easy to learn and use API allows you to develop 2D games quickly and easily. Games can be deployed across multiple platforms, including Windows, Mac, Linux, FreeBSD, the Web, iOS and Android. You can even deploy your game to Steam!
Go is fast, and so is Ebitengine. While Ebitengine's drawing API is very simple, games developed in it run very quickly with GPU power.
In this course, we'll learn how to:
Introduction to Ebitengine: Get familiar with the basics of how to set up Go and use Ebitengine for 2D game development.
Game Design Fundamentals: Understand core game mechanics like player movement, object collisions, game states, and rendering.
Creating the Game World: Learn how to design the asteroid field, ship controls, and space physics—like rotation, thrust, and inertia.
Rendering and Animation: Master how to draw and animate your ship, asteroids, bullets, and explosions using Ebitengine’s powerful drawing functions.
Game Logic: Implement the game loop, scoring system, levels, and spawn mechanics for asteroids. Learn how to create enemies and manage the player’s health.
Sound and Music: Add sound effects for shooting, explosions, and background music to enhance the player's experience.
Building a Playable Game: Integrate everything to create a fully functional, interactive game that runs in the browser or on desktop platforms.
By the end of this course, you will have developed your own playable Asteroids clone, gaining the knowledge and confidence to create more complex 2D games in Go. Whether you want to add new features or make your own game from scratch, this course will equip you with the foundational skills needed for game development in Go using Ebitengine.
Prerequisites:
A basic knowledge of the Go programming language.
Tools Used:
Go
Ebitengine (a 2D game engine for Go)
Visual Studio Code (or your favourite IDE)
Take your first step into the world of game development with Go!