console

package
v0.0.0-...-04eb477 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2017 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	P1_BUTT_RIGHT = 0x4f
	P1_BUTT_LEFT  = 0x50
	P1_BUTT_DOWN  = 0x51
	P1_BUTT_UP    = 0x52
	//Z,X / C,V / N,M
	P1_BUTT_01 = 0x1d // Z
	P1_BUTT_02 = 0x1b // X
	P1_BUTT_03 = 0x6  // C
	P1_BUTT_04 = 0x19 // V
	P1_BUTT_05 = 0x11 // N
	P1_BUTT_06 = 0x10 // M
)
View Source
const (
	PICO8       = "pico8"
	TIC80       = "tic80"
	ZX_SPECTRUM = "zxspectrum"
	CBM64       = "cbm64"
)
View Source
const TOTAL_COLORS = 256

Variables

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

Functions

This section is empty.

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

func (*BaseCartridge) IsRunning

func (bc *BaseCartridge) IsRunning() bool

func (*BaseCartridge) Stop

func (bc *BaseCartridge) Stop()

type Cartridge

type Cartridge interface {
	// BaseCartridge methods already implemented
	Configger

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

type Clearer

type Clearer interface {
	Cls()                       // Clear screen
	ClsWithColor(colorID Color) // Clear screen with color
}

type Color

type Color int
const (
	PICO8_BLACK Color = 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 Color = 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 Color = 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 Color = 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 Command

type Command interface {
	Exec(pb PixelBuffer, statement string) error
}

func NewCDCommand

func NewCDCommand() Command

func NewDirCommand

func NewDirCommand() Command

func NewHelpCommand

func NewHelpCommand() Command

func NewMkDirCommand

func NewMkDirCommand() Command

func NewRunCommand

func NewRunCommand() Command

type Config

type Config struct {
	BorderWidth     int
	ConsoleWidth    int
	ConsoleHeight   int
	WindowWidth     int
	WindowHeight    int
	FPS             int
	Verbose         bool
	ScreenshotScale int
	GifScale        int
	GifLength       int

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

func NewConfig

func NewConfig(consoleType ConsoleType) Config

type Configger

type Configger interface {
	GetConfig() Config
}

type Console

type Console interface {
	LoadCart(cart Cartridge) error
	Run() error
	Destroy()
	GetWindow() *sdl.Window
	SetMode(newMode ModeType)
	Inputter
}

func NewConsole

func NewConsole(consoleType ConsoleType) (Console, error)

type ConsoleState

type ConsoleState struct {
	X int
	Y int
	W int
	H int
}

type ConsoleType

type ConsoleType string

type Drawer

type Drawer interface {
	Color(colorID Color) // Set drawing color (colour!!!)
	// drawing primatives
	Circle(x, y, r int)
	CircleWithColor(x, y, r int, colorID Color)
	CircleFill(x, y, r int)
	CircleFillWithColor(x, y, r int, colorID Color)
	Line(x0, y0, x1, y1 int)
	LineWithColor(x0, y0, x1, y1 int, colorID Color)
	PGet(x, y int) Color
	PSet(x, y int)
	PSetWithColor(x, y int, colorID Color)
	Rect(x0, y0, x1, y1 int)
	RectWithColor(x0, y0, x1, y1 int, colorID Color)
	RectFill(x0, y0, x1, y1 int)
	RectFillWithColor(x0, y0, x1, y1 int, colorID Color)
}

type Inputter

type Inputter interface {
	PicoInputAPI
	// contains filtered or unexported methods
}

func NewInputter

func NewInputter() Inputter

type Mode

type Mode interface {
	Init() error
	Render() error
	Update() error
	HandleEvent(event sdl.Event) error
	PixelBuffer
}

type ModeType

type ModeType int
const (
	CLI ModeType = iota
	CODE_EDITOR
	SPRITE_EDITOR
	MAP_EDITOR
	SFX_EDITOR
	MUSIC_EDITOR
	RUNTIME
)

type Paletter

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

type Persister

type Persister interface {
	SaveState(console Console) error
	LoadState() (*ConsoleState, error)
}

func NewStateManager

func NewStateManager() (Persister, error)

type PicoGraphicsAPI

type PicoGraphicsAPI interface {
	Clearer
	Drawer
	Paletter
	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() *sdl.Surface
	PicoGraphicsAPI
	// contains filtered or unexported methods
}

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)                         // Print a string of characters to the screen at position
	PrintAtWithColor(str string, x, y int, colorID Color) // Print a string of characters to the screen at position with color
	ScrollUpLine()
}

type Recorder

type Recorder interface {
	AddFrame(surface *sdl.Surface, palette Paletter)
	SaveVideo(filename string, scale int) error
	SaveScreenshot(filename string, scale int) error
}

func NewRecorder

func NewRecorder(fps, secondsToRecord int) Recorder

type Runtime

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

type Spriter

type Spriter interface {
	// TODO lots of params!! needs a bit of overloading love
	Sprite(n, x, y, w, h, dw, dh int, rot float64, flipX, flipY bool)
	// contains filtered or unexported methods
}

Jump to

Keyboard shortcuts

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