game_of_life

command
v0.0.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 20, 2023 License: MIT Imports: 13 Imported by: 0

README

Game Of Life

This is small example of "Game Of Life", see Wikipedia for more information.

Features:

  • predefined maps from image files
  • save map as screenshot to image file, later you can load it
  • edit map with keyboard, by one pixel or with pen mode, can show/hide cursor
  • infinite map (wrap around edges)
  • mouse support (scroll up/down to step forward/backward)
  • different screen modes (1x1, 1x2, 2x2, 2x3, 2x4Braille)
  • allow to configure color, delay, fill, size, etc.

Install

go install github.com/msoap/tcg/examples/game_of_life@latest

Usage

game_of_life [options]
options:
  -color string
    	redefine color, it can be: 'yellow', 'red' or like '#ffaa11'
  -delay duration
    	delay between steps (default 100ms)
  -fill float
    	how much to fill the area initially (default 0.2)
  -in string
    	load map from image file (*.png)
  -mode value
    	screen mode, one of 1x1, 1x2, 2x2, 2x3, 2x4Braille (default 2x3)
  -out string
    	save map as screenshot to file (default "game_of_life.png")
  -size string
    	screen size in chars, in 'width x height' format, example: '80x25'
  -wait
    	wait for start
  -inf
    	infinite map (wrap around edges)

Use predefined map from image file:

game_of_life -in examples/game_of_life/glider.png -inf
game_of_life -in examples/game_of_life/gospers_glider_gun.png
game_of_life -in examples/game_of_life/penta_decathlon.png

Shortcuts

  • esc / q - quit
  • s - save map as screenshot (to file, see -out option)
  • p - pause
  • l - step forward, or mouse scroll up with terminal mouse support
  • h - step to previous state, or mouse scroll down
  • Space - toggle pixel under cursor
  • a - toggle pen mode, when pen mode is on, you can draw with arrows keys
  • w - wipe map
  • c - toggle cursor visibility
  • , , , - move cursor

Screenshots

MacOS iTerm2 (2x3 mode):

TCG library example screenshot for Game of Life

Ubuntu GNOME Terminal (2x4Braille mode):

TCG library example screenshot for Game of Life on Ubuntu

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL