sdl2-life

Conway's Game of Life with go-sdl2
git clone https://www.brianlane.com/git/sdl2-life
Log | Files | Refs | README

commit 93f8ef6a0726d3491a60a37052cb80b8c30bc5e0
parent 2c35872b4c71b5600305ec65cbca79de44cda465
Author: Brian C. Lane <bcl@brianlane.com>
Date:   Sat, 11 Apr 2020 17:09:41 -0700

Add help output for keys

Diffstat:
Mmain.go | 13+++++++++++++
1 file changed, 13 insertions(+), 0 deletions(-)

diff --git a/main.go b/main.go @@ -282,6 +282,15 @@ func (g *LifeGame) NextFrame() { g.Draw(status) } +// ShowKeysHelp prints the keys that are reconized to control behavior +func ShowKeysHelp() { + fmt.Println("h - Print help") + fmt.Println("<space> - Toggle pause/play") + fmt.Println("q - Quit") + fmt.Println("s - Single step") + fmt.Println("r - Reset the game") +} + // Run executes the main loop of the game // it handles user input and updating the display at the selected update rate func (g *LifeGame) Run() { @@ -299,6 +308,8 @@ func (g *LifeGame) Run() { case *sdl.KeyboardEvent: if t.GetType() == sdl.KEYDOWN { switch t.Keysym.Sym { + case sdl.K_h: + ShowKeysHelp() case sdl.K_q: running = false break @@ -494,5 +505,7 @@ func main() { // Setup the initial state of the world game.InitializeCells() + ShowKeysHelp() + game.Run() }