TCG - terminal cell graphics library

Go Reference GitHub Action Coverage Status Go Report Card

TCG - terminal cell graphics

Go Graphics library for use in a text terminal. Only 1bit graphics can be used with two colors. Used unicode block symbols for drawing. 2x3 mode is supported by the latest versions of the Iosevka font.

Features

Install

go get -u github.com/msoap/tcg

Usage

package main

import (
	"log"

	"github.com/gdamore/tcell/v2"
	"github.com/msoap/tcg"
)

func main() {
	tg, err := tcg.New(tcg.Mode2x3) // each terminal symbol contains a 2x3 pixels grid, also you can use 1x1, 1x2, and 2x2 modes
	if err != nil {
		log.Fatalf("create tg: %s", err)
	}

	i := 0
	for {
		pixColor := tg.Buf.At(10, 10)       // get color of pixel
		tg.Buf.Set(11, 11, pixColor)        // draw one pixel with color from 10,10
		tg.Buf.Line(0, 0, 50, i, tcg.Black) // draw a diagonal line
		tg.Show()                           // synchronize buffer with screen

		if ev, ok := tg.TCellScreen.PollEvent().(*tcell.EventKey); ok && ev.Rune() == 'q' {
			break // exit by 'q' key
		}
		i++
	}

	tg.Finish() // finish application and restore screen
}

See more examples in examples folder.

Screenshot

Game of Life example in iTerm2 terminal with Iosevka font:

TCG example screenshot for Game of Life

TODO

  • fonts support
  • sprites, maybe with animation

See also

Unicode symbols:

Supported fonts:

Owner
Similar Resources

Go bindings for raylib, a simple and easy-to-use library to enjoy videogames programming.

Go bindings for raylib, a simple and easy-to-use library to enjoy videogames programming.

raylib-go Golang bindings for raylib, a simple and easy-to-use library to enjoy videogames programming. Requirements Ubuntu X11 apt-get install libgl1

Dec 28, 2022

Helper library to transform TMX tile maps into a simpler format for Ebiten

Ebitmx Ebitmx is a super simple parser to help render TMX maps when using Ebiten for your games. Right now is super limited to XML and CSV data struct

Nov 16, 2022

A simple Go library for 3D ray-tracing rendering, implementing the book Ray Tracing in One Weekend.

A simple Go library for 3D ray-tracing rendering, implementing the book Ray Tracing in One Weekend.

Ray Tracing in Go A Go implementation of the book Ray Tracing in One Weekend. The repository provides a library to describe and render your own scenes

Sep 23, 2022

build and animate objects according to verlet physics. pure golang library

build and animate objects according to verlet physics. pure golang library

verlet build and animate objects according to verlet physics. pure golang library Examples depend on pixel library, see requirements to build them: wo

Dec 22, 2022

Rock-paper-scissors game library

Rock-paper-scissors game library

jankensheep Rock-paper-scissors game library Examples Play with two players:

May 13, 2022

Golang writen 3D render library and some game-relative concepts

Golang writen 3D render library and some game-relative concepts.

Jun 6, 2022

A simple game that I created with Ebiten game library as a way to teach myself Go. Enjoy!

A simple game that I created with Ebiten game library as a way to teach myself Go. Enjoy!

galactic-asteroid-belt Overview A simple game that I created with Ebiten game library as a way to teach myself Go. Enjoy! Run To run, you will need Go

Dec 2, 2021

Golang library for connecting to EOSIO SHIP

go-eosio-ship go-eosio-ship is a golang library built on top of go-eosio for con

Jan 3, 2022

Donburi is just another Entity Component System library for Ebiten inspired by legion.

Donburi is just another Entity Component System library for Ebiten inspired by legion.

Donburi Donburi is just another Entity Component System library for Ebiten inspired by legion. It aims to be a feature rich and high performance ECS L

Dec 15, 2022
Comments
  • Allow user customisation of the the Box Chars

    Allow user customisation of the the Box Chars

    It would be brilliant to allow custom modes where the user can specify the Box Chars. It could allow weird/creative behaviours with minimal change in the final code. I might follow up with a pull request. Stay tuned :D

    (Thanks for the brilliant work, BTW).

  • Added support for custom pixel to rune mapping

    Added support for custom pixel to rune mapping

    I have added the support for the pixel to rune mapping. I should have covered all the cases but, please, have a look if I missed anything and let me know so I will cover it.

  • Faster circle and line algos

    Faster circle and line algos

    I have added Midpoint Circle Algorithm and Bresenham's algorithm to draw circles and lines faster.

    I created some benchmarks and here are the results:\

    BenchmarkBuffer_Line-8 18535812 61.44 ns/op BenchmarkBuffer_LineFast-8 35687457 34.03 ns/op BenchmarkBuffer_Circle-8 1000000 1028 ns/op BenchmarkBuffer_CircleFast-8 20413906 58.19 ns/op

Battleblips - Work in progress multiplayer terminal base battleship game written in Go (with mouse support!) using tcell library
Battleblips - Work in progress multiplayer terminal base battleship game written in Go (with mouse support!) using tcell library

battleblips Work in progress multiplayer terminal base battleship game written in Go (with mouse support!) using tcell library (see https://github.com

Apr 26, 2022
Terminal-based game engine for Go, built on top of Termbox
Terminal-based game engine for Go, built on top of Termbox

Termloop Termloop is a pure Go game engine for the terminal, built on top of the excellent Termbox. It provides a simple render loop for building game

Dec 29, 2022
♛♔ Play chess against UCI engines in your terminal.
♛♔ Play chess against UCI engines in your terminal.

uchess ♛♔ Play chess in your terminal. Introduction uchess is an interactive terminal chess client designed to allow gameplay and move analysis in con

Nov 17, 2022
🕹️ A basic gameboy emulator with terminal "Cloud Gaming" support
🕹️ A basic gameboy emulator with terminal

Gameboy.Live ??️ Gameboy.Live is a Gameboy emulator written in go for learning purposes. You can simply play Gameboy games on your desktop: Or, "Cloud

Jan 1, 2023
Play chess in your terminal
Play chess in your terminal

Gambit Chess board in your terminal. Warning gambit does not have many features at the moment. I plan on adding a chess engine, mouse support, timers,

Dec 21, 2022
A simple terminal game lol

sc a shitty game lol if you want to play it run: git clone https://github.com/pa

Mar 18, 2022
MagicSummon - A Terminal Game about Mixing Stuff to summon a MONSTER. Currently The Biggest Project I have worked on.

MagicSummon A Terminal Game about Mixing Stuff to summon a MONSTER that the warriors ALMOST defeated, but the MONSTER fled. Getting Started Clone the

Jan 6, 2022
A terminal Snake game that supports multiple players to play together online.
A terminal Snake game that supports multiple players to play together online.

GoSnake A Snake game that supports multiple players to play together online. The game is written in go language and does not use other third-party lib

Jun 25, 2022
A dead simple 2D game library for Go
A dead simple 2D game library for Go

Ebiten (v2) A dead simple 2D game library for Go Ebiten is an open source game library for the Go programming language. Ebiten's simple API allows you

Dec 28, 2022
A hand-crafted 2D game library in Go
A hand-crafted 2D game library in Go

Pixel A hand-crafted 2D game library in Go. Take a look into the features to see what it can do. go get github.com/faiface/pixel If you are using Mod

Dec 31, 2022