Hi! I write about projects I build and what I learn along the way.

Chrome dinosaur game in the terminal with Go + Bubbletea

Introduction The goal is to build a simplified version of the dinosaur game from Chrome but in the terminal using Go and the Bubbletea CLI library. Here is the repo: https://github.com/ddahon/bubblesaur 1) Getting started Let’s start with the skeleton of our Bubbletea program: package main import ( "log" tea "github.com/charmbracelet/bubbletea" ) type model struct{} func initialModel() model { return model{} } func (m model) Init() tea.Cmd { return nil } func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { switch msg := msg.(type) { case tea.KeyMsg: switch msg.String() { case "q", "ctrl+c": return m, tea.Quit } } return m, nil } func (m model) View() string { return "" } func main() { p := tea.NewProgram(initialModel(), tea.WithAltScreen()) if _, err := p.Run(); err != nil { log.Fatal(err) } } Now we can create our player and add it to the model: ...

April 4, 2025 · 8 min · 1680 words · Doryan Dahon