termboard

package module
v0.0.0-...-1f7ab8b Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2015 License: BSD-3-Clause Imports: 4 Imported by: 0

README

[[https://drone.io/github.com/wujiang/termboard/latest][https://drone.io/github.com/wujiang/termboard/status.png]]

** termboard

termboard is a library which provides an easy way to create grid based
board games.

*** Install

#+BEGIN_SRC sh
go get -u github.com/wujiang/termboard
#+END_SRC


*** Example

#+BEGIN_SRC go
import (
	"github.com/nsf/termbox-go"
	"github.com/wujiang/termboard"
)

func main() {
	board := termboard.Init(4, 4)
	defer termboard.Close()
	board.Redraw()
}
#+END_SRC

Documentation

Index

Constants

View Source
const (
	Up    string = "up"
	Down  string = "down"
	Left  string = "left"
	Right string = "right"
	End   string = "end"
	Begin string = "begin"
)

Variables

This section is empty.

Functions

func Close

func Close()

Types

type Board

type Board struct {
	TileCountX int
	TileCountY int
	Width      int
	Height     int
	CursorPos  GPosition
	Grid       [][]Tile
	Messages   []Message
}

func Init

func Init(tileCountX, tileCountY int) *Board

Initialize a board.

func (*Board) GetCenter

func (b *Board) GetCenter() GPosition

func (*Board) MoveCursor

func (b *Board) MoveCursor(direction string) error

func (*Board) PinCursor

func (b *Board) PinCursor(t Tile)

func (*Board) PrintLines

func (b *Board) PrintLines(m Message)

func (*Board) Redraw

func (b *Board) Redraw()

func (*Board) SetCursor

func (b *Board) SetCursor(p GPosition)

type GPosition

type GPosition struct {
	X int
	Y int
}

type Message

type Message struct {
	Text        string
	StartPos    GPosition
	AlignCenter bool
	FG          termbox.Attribute
	BG          termbox.Attribute
}

type TPosition

type TPosition struct {
	X int
	Y int
}

type Tile

type Tile struct {
	R  rune
	FG termbox.Attribute
	BG termbox.Attribute
}

Directories

Path Synopsis
Godeps
_workspace/src/github.com/golang/glog
Package glog implements logging analogous to the Google-internal C++ INFO/ERROR/V setup.
Package glog implements logging analogous to the Google-internal C++ INFO/ERROR/V setup.
_workspace/src/github.com/nsf/termbox-go
termbox is a library for creating cross-platform text-based interfaces
termbox is a library for creating cross-platform text-based interfaces
_workspace/src/github.com/stretchr/testify/assert
A set of comprehensive testing tools for use with the normal Go testing system.
A set of comprehensive testing tools for use with the normal Go testing system.

Jump to

Keyboard shortcuts

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