talak

package module
v0.0.0-...-5c462c6 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2025 License: GPL-3.0 Imports: 6 Imported by: 0

README

talak

game engine for the terminal

Examples

Hello World
package main

import (
	"codeberg.org/jann/talak"
)

type Game struct {
}

func (g Game) Draw(screen *talak.Screen) {
	screen.Print(0, 0, "Hello World")

}

func (g Game) Update() error {
	return nil
}

func (g Game) Layout(consoleSize talak.Vec2di) (gameSize talak.Vec2di) {
	return consoleSize
}

func main() {
	talak.RunGame(Game{}, talak.GameOptions{TPS: 60, FPS: 10})
}
Try the examples

go run codeberg.org/jann/talak/examples/colors@latest

go run codeberg.org/jann/talak/examples/hello_world@latest

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunGame

func RunGame(game Game, options GameOptions)

Types

type Game

type Game interface {
	Draw(screen *Screen)
	Update() error
	Layout(consoleSize Vec2di) (gameSize Vec2di)
}

type GameOptions

type GameOptions struct {
	TPS int
	FPS int
}

type Screen

type Screen struct {
	// contains filtered or unexported fields
}

func (*Screen) Fill

func (s *Screen) Fill(c rune)

func (*Screen) Get

func (s *Screen) Get(x, y int) rune

func (*Screen) GetColor

func (s *Screen) GetColor(x, y int) *color.Color

func (*Screen) GetData

func (s *Screen) GetData() [][]rune

Like a "screenshot"

func (*Screen) GetFPS

func (s *Screen) GetFPS() float64

func (*Screen) GetFrameDelta

func (s *Screen) GetFrameDelta() string

func (*Screen) GetSize

func (s *Screen) GetSize() Vec2di

func (*Screen) LineIsColored

func (s *Screen) LineIsColored(y int, full bool) bool

func (*Screen) Print

func (s *Screen) Print(x, y int, a ...any)

func (*Screen) Printf

func (s *Screen) Printf(x, y int, format string, a ...any)

func (*Screen) Set

func (s *Screen) Set(x, y int, c rune)

func (*Screen) SetColor

func (s *Screen) SetColor(x, y int, color color.Color)

func (*Screen) SetData

func (s *Screen) SetData(data [][]rune)

func (*Screen) SetLineColor

func (s *Screen) SetLineColor(y int, color color.Color)

type Text

type Text struct {
	Options TextOptions
	// contains filtered or unexported fields
}

func NewText

func NewText(s string) Text

func (*Text) Align

func (t *Text) Align(a TextAlignment)

func (*Text) Draw

func (t *Text) Draw(s *Screen, x, y int)

x gets ignored if options.Alignment != 0

func (*Text) GetColor

func (t *Text) GetColor() color.Color

func (*Text) SetColor

func (t *Text) SetColor(c color.Color)

type TextAlignment

type TextAlignment uint8
const (
	TextAlignment_Ignore TextAlignment = iota
	TextAlignment_Left
	TextAlignment_Right
	TextAlignment_Center
)

type TextOptions

type TextOptions struct {
	Spacing   int
	Alignment TextAlignment
}

type Vec2di

type Vec2di struct {
	X int
	Y int
}

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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