package main import ( "time" "github.com/gdamore/tcell/v2" ) type Game struct { Screen tcell.Screen Cells [][]Cell } func (g *Game) Run() Game{ s := g.Screen style := tcell.StyleDefault.Background(tcell.ColorBlack).Foreground(tcell.ColorPurple) s.SetStyle(style) state := g.Cells var newState [][]Cell for r, h := range state { var row []Cell for c, _ := range h { cellState := state[r][c].Update(g) cellX := r cellY := c newCell := Cell{ X: cellX, Y: cellY, State: cellState, } row = append(row, newCell) s.SetContent(state[r][c].X, state[r][c].Y, state[r][c].Display(), nil, style) } newState = append(newState, row) } newGame := Game { Screen: s, Cells: newState, } s.Show() time.Sleep(1*time.Millisecond) s.Clear() return newGame } func (g *Game) Glider() Game{ s := g.Screen h, w := s.Size() var states [][]int for r := 0; r