console

package
v0.0.0-...-a9759a8 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2019 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PICO8      = "pico8"
	TIC80      = "tic80"
	ZXSPECTRUM = "zxspectrum"
	CBM64      = "cbm64"
)
View Source
const MaxCacheAge = 1 * time.Minute
View Source
const MaxSpriteCache = 1000
View Source
const TOTAL_COLORS = 16

Variables

View Source
var ConsoleTypes = map[ConsoleType]string{
	PICO8:      "PICO8",
	TIC80:      "TIC80",
	ZXSPECTRUM: "ZXSPECTRUM",
	CBM64:      "CBM64",
}

Functions

func HideFPS

func HideFPS()

func Init

func Init(consoleType ConsoleType) error

func Run

func Run(cart Cartridge) error

func ShowFPS

func ShowFPS()

Types

type BaseCartridge

type BaseCartridge struct {
	PixelBuffer // ref to console display
	PicoInputAPI
	// contains filtered or unexported fields
}

func NewBaseCart

func NewBaseCart() *BaseCartridge

NewBaseCart - initialise a struct implementing Cartridge interface

func (*BaseCartridge) Btn

func (bc *BaseCartridge) Btn(id int) bool

func (*BaseCartridge) GetConfig

func (bc *BaseCartridge) GetConfig() Config

GetConfig - return config need for Cart to run

type Cartridge

type Cartridge interface {
	// BaseCartridge methods already implemented
	Configger

	PicoInputAPI
	// User implemented methods below
	Init() error
	Render()
	Update()
	// contains filtered or unexported methods
}

type Clearer

type Clearer interface {
	Cls(colorID ...ColorID) // Clear screen
}

type ColorID

type ColorID uint8
const (
	PICO8_BLACK ColorID = iota
	PICO8_DARK_BLUE
	PICO8_DARK_PURPLE
	PICO8_DARK_GREEN
	PICO8_BROWN
	PICO8_DARK_GRAY
	PICO8_LIGHT_GRAY
	PICO8_WHITE
	PICO8_RED
	PICO8_ORANGE
	PICO8_YELLOW
	PICO8_GREEN
	PICO8_BLUE
	PICO8_INDIGO
	PICO8_PINK
	PICO8_PEACH
)

PICO8 - colors

const (
	TIC80_BLACK ColorID = iota
	TIC80_DARK_RED
	TIC80_DARK_BLUE
	TIC80_DARK_GRAY
	TIC80_BROWN
	TIC80_DARK_GREEN
	TIC80_RED
	TIC80_LIGHT_GRAY
	TIC80_LIGHT_BLUE
	TIC80_ORANGE
	TIC80_BLUE_GRAY
	TIC80_LIGHT_GREEN
	TIC80_PEACH
	TIC80_CYAN
	TIC80_YELLOW
	TIC80_WHITE
)

TIC80 - colors

const (
	ZX_BLACK ColorID = iota
	ZX_BLUE
	ZX_RED
	ZX_MAGENTA
	ZX_GREEN
	ZX_CYAN
	ZX_YELLOW
	ZX_WHITE
	ZX_BRIGHT_BLACK
	ZX_BRIGHT_BLUE
	ZX_BRIGHT_RED
	ZX_BRIGHT_MAGENTA
	ZX_BRIGHT_GREEN
	ZX_BRIGHT_CYAN
	ZX_BRIGHT_YELLOW
	ZX_BRIGHT_WHITE
)

ZX Spectrum - colors

const (
	C64_BLACK ColorID = iota
	C64_WHITE
	C64_RED
	C64_CYAN
	C64_PURPLE
	C64_GREEN
	C64_BLUE
	C64_YELLOW
	C64_ORANGE
	C64_BROWN
	C64_LIGHT_RED
	C64_DARK_GREY
	C64_GREY
	C64_LIGHT_GREEN
	C64_LIGHT_BLUE
	C64_LIGHT_GREY
)

Commodore 64 - colors

type Config

type Config struct {
	BorderWidth     int
	ConsoleWidth    int
	ConsoleHeight   int
	ScreenshotScale int
	GifScale        int
	GifLength       int

	BgColor     ColorID
	FgColor     ColorID
	BorderColor ColorID
	// contains filtered or unexported fields
}

func NewConfig

func NewConfig(consoleType ConsoleType) Config

type Configger

type Configger interface {
	GetConfig() Config
}

type ConsoleType

type ConsoleType string

type Drawer

type Drawer interface {
	SetColor(colorID ColorID) // Set drawing color (colour!!!)
	// drawing primitives
	Circle(x, y, r int, colorID ...ColorID)
	CircleFill(x, y, r int, colorID ...ColorID)
	Line(x0, y0, x1, y1 int, colorID ...ColorID)
	PGet(x, y int) ColorID
	PSet(x, y int, colorID ...ColorID)
	Rect(x0, y0, x1, y1 int, colorID ...ColorID)
	RectFill(x0, y0, x1, y1 int, colorID ...ColorID)
}

type Paletter

type Paletter interface {
	PaletteReset()
	PaletteCopy() Paletter
	GetColorID(rgba rgba) ColorID
	GetColor(colorID ColorID) color.Color
	GetRGBA(color ColorID) (rgba, uint32)
	GetColors() []color.Color
	MapColor(fromColor ColorID, toColor ColorID) error
	SetTransparent(color ColorID, enabled bool) error
}

type Peeker

type Peeker interface {
	Peek(pos int) uint8
	Poke(pos int, value uint8)
}

type PicoGraphicsAPI

type PicoGraphicsAPI interface {
	Clearer
	Drawer
	Paletter
	Peeker
	Printer
	Spriter
}

type PicoInputAPI

type PicoInputAPI interface {
	Btn(id int) bool
}

type PixelBuffer

type PixelBuffer interface {
	Flip() error // Copy graphics buffer to screen
	Destroy()
	GetFrame() *image.Paletted
	PicoGraphicsAPI
	GetWidth() int
	GetHeight() int
}

type Printer

type Printer interface {
	// Text/Printing
	Cursor(x, y int) // Set text cursor
	GetCursor() pos
	Print(str string)                                 // Print a string of characters to the screen at default pos
	PrintAt(str string, x, y int, colorID ...ColorID) // Print a string of characters to the screen at position with color
	ScrollUpLine()
}

type Runtime

type Runtime interface {
	PicoInputAPI
	LoadCart(cart Cartridge) error
}

type Spriter

type Spriter interface {
	Sprite(n, x, y, w, h, dw, dh int)
	SpriteFlipped(n, x, y, w, h, dw, dh int, flipX, flipY bool)
	SpriteRotated(n, x, y, w, h, dw, dh, rot int)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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