Documentation ¶
Overview ¶
Package c80machine provides a type that represents a fantasy virtual machine inspired by arcade game machines, home video game consoles, handheld game consoles, and (other) computers from the 1980s.
Index ¶
- Constants
- type Terminator
- type Type
- func (receiver *Type) At(x, y int) color.Color
- func (receiver *Type) Bounds() image.Rectangle
- func (receiver *Type) ColorIndex(c color.Color) uint8
- func (receiver *Type) ColorModel() color.Model
- func (receiver *Type) Colorize(a ...interface{}) error
- func (receiver *Type) Draw(img image.Image) error
- func (receiver *Type) DrawDye(color color.Color) error
- func (receiver *Type) DrawPixel(x int, y int, color color.Color) error
- func (receiver *Type) Frame() []uint8
- func (receiver *Type) Image() draw.Image
- func (receiver *Type) Map() image.Image
- func (receiver *Type) Memory() []uint8
- func (receiver *Type) Palette() palette2048.Slice
- func (receiver *Type) Rectangle(x, y int, width, height int, index uint8) image.Image
- func (receiver *Type) Reveal()
- func (receiver *Type) Serialize() string
- func (receiver *Type) Set(x, y int, c color.Color)
- func (receiver *Type) SetSprite(kind string, id uint8, img image.Image) error
- func (receiver *Type) Sprite(kind string, id uint8) image.Image
- func (receiver *Type) Terminal() Terminator
Examples ¶
Constants ¶
const ( PTR_PALETTE = 0 LEN_PALETTE = palette2048.ByteSize PTR_FRAME = PTR_PALETTE + LEN_PALETTE LEN_FRAME = frame256x288.ByteSize PTR_TILEMAP = PTR_FRAME + LEN_FRAME LEN_TILEMAP = tilemap8x8x256x256.ByteSize PTR_TILES = PTR_TILEMAP + LEN_TILEMAP LEN_TILES = spritesheet8x8x256.ByteSize PTR_SPRITES8x8 = PTR_TILES + LEN_TILES LEN_SPRITES8x8 = spritesheet8x8x256.ByteSize PTR_SPRITES32x32 = PTR_SPRITES8x8 + LEN_SPRITES8x8 LEN_SPRITES32x32 = spritesheet32x32x256.ByteSize PTR_TEXTMATRIX = PTR_SPRITES32x32 + LEN_SPRITES32x32 LEN_TEXTMATRIX = text32x36.ByteSize )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Terminator ¶
type Type ¶
type Type struct {
// contains filtered or unexported fields
}
Type represents a fantasy virtual machine.
func (*Type) ColorModel ¶
func (*Type) Colorize ¶
Colorize sets the color palette.
Example ¶
Here are some examples of Colorize being used:
err := machine.Colorize("tia")
func (*Type) Palette ¶
func (receiver *Type) Palette() palette2048.Slice
Palette provides access to the machines palette.
Example ¶
var machine c80machine.Type // We set the RGBA values of each of the colors in the palette. // // (“RGBA” = Red, Green, Blue, Alpha.) // // The colors in the palette are indexed from 0 to 15. // // So, here, color №5 is rgba(118,38,113,255). // // And, also here, color №0 is rgba(1,1,1,255). machine.Palette().SetColorRGB(0, 1, 1, 1) machine.Palette().SetColorRGB(1, 222, 56, 43) machine.Palette().SetColorRGB(2, 57, 181, 74) machine.Palette().SetColorRGB(3, 255, 199, 6) machine.Palette().SetColorRGB(4, 0, 111, 184) machine.Palette().SetColorRGB(5, 118, 38, 113) machine.Palette().SetColorRGB(6, 44, 181, 233) machine.Palette().SetColorRGB(7, 204, 204, 204) machine.Palette().SetColorRGB(8, 128, 128, 128) machine.Palette().SetColorRGB(9, 255, 0, 0) machine.Palette().SetColorRGB(10, 0, 255, 0) machine.Palette().SetColorRGB(11, 255, 255, 0) machine.Palette().SetColorRGB(12, 0, 0, 255) machine.Palette().SetColorRGB(13, 255, 0, 255) machine.Palette().SetColorRGB(14, 0, 255, 255) machine.Palette().SetColorRGB(15, 255, 255, 255) fmt.Println(machine.Palette().Color(0)) fmt.Println(machine.Palette().Color(1)) fmt.Println(machine.Palette().Color(2)) fmt.Println(machine.Palette().Color(3)) fmt.Println(machine.Palette().Color(4)) fmt.Println(machine.Palette().Color(5)) fmt.Println(machine.Palette().Color(6)) fmt.Println(machine.Palette().Color(7)) fmt.Println(machine.Palette().Color(8)) fmt.Println(machine.Palette().Color(9)) fmt.Println(machine.Palette().Color(10)) fmt.Println(machine.Palette().Color(11)) fmt.Println(machine.Palette().Color(12)) fmt.Println(machine.Palette().Color(13)) fmt.Println(machine.Palette().Color(14)) fmt.Println(machine.Palette().Color(15))
Output: rgba(1,1,1,255) rgba(222,56,43,255) rgba(57,181,74,255) rgba(255,199,6,255) rgba(0,111,184,255) rgba(118,38,113,255) rgba(44,181,233,255) rgba(204,204,204,255) rgba(128,128,128,255) rgba(255,0,0,255) rgba(0,255,0,255) rgba(255,255,0,255) rgba(0,0,255,255) rgba(255,0,255,255) rgba(0,255,255,255) rgba(255,255,255,255)
func (*Type) SetSprite ¶
SetSprite sets the value of a sprite to the built-in image.Image.
There are 3 kinds of sprites:
• 8x8 • 32x32 • tile
For each fo these, the id runs from 0 to 255.
func (*Type) Sprite ¶
Sprite returns a sprite as a Go built-in image.Image.
There are 3 kinds of sprites:
• 8x8 • 32x32 • tile
For each fo these, the id runs from 0 to 255.
func (*Type) Terminal ¶
func (receiver *Type) Terminal() Terminator