gogame

package module
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2024 License: MIT Imports: 6 Imported by: 0

README

gogame

A simple TUI-Game Library for go

Installation

  1. Run go get github.com/aureumapes/gogame
  2. Start using with ìmport github.com/aureumapes/gogame

Example

For examples see examples folder

Documentation

For docs see Go Docs

Keys can be generated like this (change the seed):
https://go.dev/play/p/NADicgNgpM6

Documentation

Overview

Package gogame is a simple tui game-engine powered by go

It features a variety of functions to manage a 2D matrix, where each character is represented by a cell

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadInput

func ReadInput(text string) rune

ReadInput is a function, which allows you to get a single character input from the user

Types

type Cell

type Cell struct {
	Pos     Vector
	Content rune
}

Cell is a structure, which stores the Position and Content of a Cell inside the Grid

func NewCell

func NewCell(v Vector, content rune) Cell

NewCell generates and returns a new Cell

func (Cell) GetDowner

func (cell Cell) GetDowner() Vector

func (Cell) GetLeft

func (cell Cell) GetLeft() Vector

func (Cell) GetRight

func (cell Cell) GetRight() Vector

func (Cell) GetUpper

func (cell Cell) GetUpper() Vector

GetUpper GetDowner GetLeft and GetRight functions will return the position of neighbor Cell

type Game

type Game struct {
	GameMap map[Vector]Cell
}

Game is a struct containing Level Data

func LoadGame added in v1.1.1

func LoadGame(path string, key []byte) Game

LoadGame returns a Game object, from a save file

func NewGame

func NewGame() Game

NewGame is a function to create a new empty Game

func (Game) AddCell

func (g Game) AddCell(pos Vector, content rune)

AddCell adds a single Cell

func (Game) AddRow

func (g Game) AddRow(row string, y int)

AddRow adds an entire Row to the Game

func (Game) FindCell added in v1.1.1

func (g Game) FindCell(content rune) Vector

FindCell allows you to find out a Cells Vector, using its Content, it will always return the first result

func (Game) GetCell added in v1.1.1

func (g Game) GetCell(y int, x int) string

GetCell let you read the Content of a Cell at a specific location on the grid

func (Game) MoveCell

func (g Game) MoveCell(cell Cell, moveTo Vector) (Game, Cell)

MoveCell allows to move a Cell to another position, replacing its old Content with the Content, of the Cell, it moved to

func (Game) Render

func (g Game) Render()

Render prints the Game‎s grid as an

func (Game) SaveGame added in v1.1.1

func (g Game) SaveGame(path string, key []byte)

SaveGame saves the Game to the specified path

type Vector

type Vector struct {
	X int
	Y int
}

Directories

Path Synopsis
example

Jump to

Keyboard shortcuts

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