Documentation
¶
Overview ¶
Package sprite provides a framework for creating ASCII and Unicode based animations and games.
Index ¶
- Constants
- Variables
- type Background
- type BaseBackground
- type BaseSprite
- func (s *BaseSprite) AddCostume(costume Costume)
- func (s *BaseSprite) BlockRender(bg *Surface)
- func (s *BaseSprite) HitAtPoint(x, y int) bool
- func (s *BaseSprite) HitAtPointSurface(x, y int) bool
- func (s *BaseSprite) Init()
- func (s *BaseSprite) IsDead() bool
- func (s *BaseSprite) NextCostume()
- func (s *BaseSprite) PrevCostume()
- func (s *BaseSprite) RegisterEvent(name string, fn func())
- func (s *BaseSprite) RemoveEvent(name string) bool
- func (s *BaseSprite) Render()
- func (s *BaseSprite) SetCostume(c int)
- func (s *BaseSprite) TriggerEvent(name string) bool
- func (s *BaseSprite) Update()
- type Block
- type Costume
- func (c *Costume) BottomEdge() int
- func (c *Costume) BottomEdgeByColumn() map[int]int
- func (c *Costume) ChangeCostume(t string, alpha rune)
- func (c *Costume) LeftEdge() int
- func (c *Costume) LeftEdgeByRow() map[int]int
- func (c *Costume) RightEdge() int
- func (c *Costume) RightEdgeByRow() map[int]int
- func (c *Costume) TopEdge() int
- func (c *Costume) TopEdgeByColumn() map[int]int
- type EdgeType
- type Event
- type Font
- type Point
- type Rect
- type Sprite
- type SpriteGroup
- func (sg *SpriteGroup) Init(width, height int, blockMode bool)
- func (sg *SpriteGroup) MoveToTop(s Sprite)
- func (sg *SpriteGroup) Remove(s Sprite)
- func (sg *SpriteGroup) RemoveAll()
- func (sg *SpriteGroup) Render()
- func (sg *SpriteGroup) Resize(width, height int)
- func (sg *SpriteGroup) TriggerEvent(name string)
- func (sg *SpriteGroup) Update()
- type Surface
- func NewSurface(width, height int, alpha bool) Surface
- func NewSurfaceFromImage(img image.Image, alpha bool) Surface
- func NewSurfaceFromPng(fn string, alpha bool) Surface
- func NewSurfaceFromString(s string, alpha bool) Surface
- func NewSurfacesFromPngSheet(fn string, r image.Rectangle, alpha bool) []Surface
- func (s Surface) Blit(t Surface, x, y int) error
- func (s Surface) Circle(xc, yc, r int, ch rune, fill bool) error
- func (s *Surface) Clear()
- func (s Surface) ConvertToColorCostume(bg tm.Attribute) Costume
- func (s Surface) ConvertToCostume() Costume
- func (s *Surface) Fill(ch rune)
- func (s Surface) Line(x0, y0, x1, y1 int, ch rune) error
- func (s Surface) Point(x, y int, ch rune)
- func (s Surface) Rectangle(x0, y0, x1, y1 int, ch rune, fill bool) error
- func (s Surface) Triangle(x0, y0, x1, y1, x2, y2 int, ch rune, fill bool) error
- type TitleArrow
- type TitleEdge
- type TitleScreen
Constants ¶
const Font_0 = `
XX
X X
X X
X X
XX`
const Font_1 = `
X
XX
X
X
XXX`
const Font_2 = `
XX
X
XXX
X
XXX`
const Font_3 = `
XX
X
XX
X
XXX`
const Font_4 = `
X X
X X
XXX
X
X`
const Font_5 = `
XXX
X
XXX
X
XX`
const Font_6 = `
XX
X
XXX
X X
XX`
const Font_7 = `
XXX
X
X
X
X`
const Font_8 = `
XX
X X
XXX
X X
XX`
const Font_9 = `
XX
X X
XXX
X
XXX`
const Font_90s_0 = `
XXX
X X
X X
X X
X X
X X
XXX`
const Font_90s_1 = `
X
XXX
X
X
X
X
X`
const Font_90s_2 = `
XXX
X X
X
XX
X
X
XXXXX`
const Font_90s_3 = `
XXX
X X
X
XX
X
X X
XXX`
const Font_90s_4 = `
X
XX
X X
X X
XXXXX
X
X`
const Font_90s_5 = `
XXXX
X
XXXX
X
X
X X
XXX`
const Font_90s_6 = `
XX
X
X
XXXX
X X
X X
XXX`
const Font_90s_7 = `
XXXXX
X
X
X
X
X
X`
const Font_90s_8 = `
XXX
X X
X X
XXX
X X
X X
XXX`
const Font_90s_9 = `
XXX
X X
X X
XXXX
X
X
XX`
const Font_90s_A = `
X
X X
X X
X X
XXXXX
X X
X X`
const Font_90s_B = `
XXXX
X X
X X
XXXX
X X
X X
XXXX`
const Font_90s_C = `
XXX
X X
X
X
X
X X
XXX`
const Font_90s_D = `
XXXX
X X
X X
X X
X X
X X
XXXX`
const Font_90s_E = `
XXXXX
X
X
XXXX
X
X
XXXXX`
const Font_90s_F = `
XXXXX
X
X
XXXX
X
X
X`
const Font_90s_G = `
XXX
X X
X
X XXX
X X
X X
XXX`
const Font_90s_H = `
X X
X X
X X
XXXXX
X X
X X
X X`
const Font_90s_I = `
XXX
X
X
X
X
X
XXX `
const Font_90s_J = `
XXXXX
X
X
X
X
X X
XX`
const Font_90s_K = `
X X
X X
X X
XX
X X
X X
X X`
const Font_90s_L = `
X
X
X
X
X
X
XXXXX`
const Font_90s_M = `
X X
XX XX
X X X
X X X
X X
X X
X X`
const Font_90s_N = `
X X
X X
XX X
X X X
X XX
X X
X X`
const Font_90s_O = `
XXX
X X
X X
X X
X X
X X
XXX`
const Font_90s_P = `
XXXX
X X
X X
XXXX
X
X
X`
const Font_90s_Q = `
XXX
X X
X X
X X
X X X
X X
XX X`
const Font_90s_R = `
XXXX
X X
X X
XXXX
X X
X X
X X`
const Font_90s_S = `
XXX
X X
X
XXX
X
X X
XXX`
const Font_90s_T = `
XXXXX
X
X
X
X
X
X`
const Font_90s_U = `
X X
X X
X X
X X
X X
X X
XXX`
const Font_90s_V = `
X X
X X
X X
X X
X X
X X
X`
const Font_90s_W = `
X X
X X
X X
X X X
X X X
XX XX
X X`
const Font_90s_X = `
X X
X X
X X
X
X X
X X
X X`
const Font_90s_Y = `
X X
X X
X X
X X
X
X
X`
const Font_90s_Z = `
XXXXX
X
X
X
X
X
XXXXX`
const Font_90s_a = `
XXX
X
XXXX
X X
XXXX`
const Font_90s_apostrophe = `
X
X
`
const Font_90s_b = `
X
X
XXXX
X X
X X
X X
XXXX`
const Font_90s_c = `
XXXX
X
X
X
XXXX`
const Font_90s_colon = `
X
X
`
const Font_90s_comma = `
X
X`
const Font_90s_d = `
X
X
XXXX
X X
X X
X X
XXXX`
const Font_90s_dash = `
XXXXX`
const Font_90s_e = `
XXX
X X
XXXXX
X
XXXX`
const Font_90s_exclamation = `
X
X
X
X
X`
const Font_90s_f = `
XX
X
XXXXX
X
X
X
X`
const Font_90s_g = `
XX X
X X
X X
XXX
X
XXX`
const Font_90s_gt = `
X
X
X
X
X
X
X`
const Font_90s_h = `
X
X
X XX
XX X
X X
X X
X X`
const Font_90s_i = `
XX
XX
X
X
X
XXX`
const Font_90s_j = `
XX
XX
X
X
X X
X`
const Font_90s_k = `
X
X
X X
X X
XX
X X
X X`
const Font_90s_l = `
XX
X
X
X
X
X
XXX`
const Font_90s_l_paren = `
X
X
X
X
X
X
X`
const Font_90s_lt = `
X
X
X
X
X
X
X`
const Font_90s_m = `
XX X
X X X
X X X
X X X
X X X`
const Font_90s_n = `
X XX
XX X
X X
X X
X X`
const Font_90s_o = `
XXX
X X
X X
X X
XXX`
const Font_90s_p = `
XXXX
X X
X X
XXXX
X`
const Font_90s_percent = `
XX X
XX X
X
X
X
X XX
X XX`
const Font_90s_period = `
X
`
const Font_90s_q = `
XX X
X X
X X
XXX
X
XX`
const Font_90s_question = `
XXX
X X
X
X
X
X`
const Font_90s_r = `
X XX
XX
X
X
X`
const Font_90s_r_paren = `
X
X
X
X
X
X
X`
const Font_90s_right_arrow = `
X
XX
XXXXX
XX
X
`
const Font_90s_s = `
XXXX
X
XXX
X
XXXX`
const Font_90s_slash = `
X
X
X
X
X
X
X`
const Font_90s_t = `
X
X
XXXX
X
X
X
XX`
const Font_90s_u = `
X X
X X
X X
X XX
XX X`
const Font_90s_v = `
X X
X X
X X
X X
X`
const Font_90s_w = `
X X
X X X
X X X
XX XX
X X`
const Font_90s_x = `
X X
X X
X
X X
X X`
const Font_90s_y = `
X X
X X
XXXX
X
XXX`
const Font_90s_z = `
XXXXX
X
X
X
XXXXX`
const Font_JR_0 = `
XXX
X X
X X X
X X X
X X X
X X
XXX`
const Font_JR_1 = `
X
XX
X X
X
X
X
XXXXX`
const Font_JR_2 = `
XXXXX
X X
X
X
XXX
XX
XXXXXXX`
const Font_JR_3 = `
XXXXXXX
X X
X
XX
X
X X
XXXXX`
const Font_JR_4 = `
XX
X X
X X
X X
XXXXXXX
X
X`
const Font_JR_5 = `
XXXXXXX
X X
X
XXXXXX
X
X X
XXXXX`
const Font_JR_6 = `
XXXXX
X X
X
XXXXXX
X X
X X
XXXXX`
const Font_JR_7 = `
XXXXXXX
X X
X
X
X
X
X`
const Font_JR_8 = `
XXXXX
X X
X X
XXXXX
X X
X X
XXXXX`
const Font_JR_9 = `
XXXXX
X X
X X
XXXXXX
X
X X
XXXXX`
const Font_JR_A = `
XXXX
X X
X X
XXXXX
X X
X X
XX XX`
const Font_JR_B = `
XXXX
X X
X X
XXXXX
X X
X X
XXXXXX`
const Font_JR_C = `
XXX X
X XX
X
X
X
X X
XXXX`
const Font_JR_D = `
XXXXX
X X
X X
X X
X X
X X
XXXXXX`
const Font_JR_E = `
XXXXXXX
X X
X
XXX
X
X X
XXXXXXX`
const Font_JR_F = `
XXXXXXX
X X
X
XXX
X
X
XXX`
const Font_JR_G = `
XXX X
X XX
X
X
X XXX
X X
XXXXX`
const Font_JR_H = `
XXX XXX
X X
X X
XXXXX
X X
X X
XXX XXX`
const Font_JR_I = `
XXXX
X
X
X
X
X
XXXX`
const Font_JR_J = `
XXXXXXX
X X
X
X
XX X
X X
XXX`
const Font_JR_K = `
XXX XX
X X
X X
XXXX
X X
X X
XXX XX`
const Font_JR_L = `
XXX
X
X
X
X
X X
XXXXXXX`
const Font_JR_M = `
XX XX
XX XX
X X X
X X
X X
X X
XXX XXX`
const Font_JR_N = `
XX XXX
XX X
XX X
X X X
X XX
X XX
XXX XX`
const Font_JR_O = `
XXX
X X
X X
X X
X X
X X
XXX`
const Font_JR_P = `
XXXXX
X X
X X
XXXX
X
X
XXX`
const Font_JR_Q = `
XXX
X X
X X
X X
X X X
X X
XXX X`
const Font_JR_R = `
XXXXX
X X
X X
XXXX
X X
X X
XXX XXX`
const Font_JR_S = `
XXXX X
X XX
X
XXXXX
X
XX X
X XXXX`
const Font_JR_T = `
XXXXXXX
X X X
X
X
X
X
XXX`
const Font_JR_U = `
XXX XXX
X X
X X
X X
X X
X X
XXX`
const Font_JR_V = `
XXX XXX
X X
X X
X X
X X
XX
XX`
const Font_JR_W = `
XX XX
X X
X X
X X
X X X
XX XX
XX XX`
const Font_JR_X = `
XX XX
X X
X X
X
X X
X X
XX XX`
const Font_JR_Y = `
XXX XXX
X X
X X
XXX
X
X
XXX`
const Font_JR_Z = `
XXXXXXX
X X
X
XXX
X
X X
XXXXXXX`
const Font_JR_a = `
XXXX
X
XXXXX
X X
XXXX X`
const Font_JR_amp = `
XX
X X
X X
XXX
X X X
X X
XXXX X`
const Font_JR_at = `
XXX
X X
X XXX X
X X X X
X XXX
X
XXXX`
const Font_JR_b = `
XX
X
XXXXX
X X
X X
X X
XXXXXX`
const Font_JR_b_slash = `
X
X
X
X
X
X`
const Font_JR_c = `
XXXXX
X X
X
X
XXXXX`
const Font_JR_colon = `
XX
XX
XX
XX`
const Font_JR_comma = `
XX
XX
X`
const Font_JR_d = `
XX
X
XXXXX
X X
X X
X X
XXXXXX`
const Font_JR_dollars = `
X
XXXXX
X X
XXXXX
X X
XXXXX
X`
const Font_JR_double_quot = `
XX XX
XX XX
X X`
const Font_JR_down = `
X X
X X
X`
const Font_JR_e = `
XXXXX
X X
XXXXXXX
X
XXXXX`
const Font_JR_equals = `
XXXXX
XXXXX`
const Font_JR_eszett = `
XX
X X
X X
X XX
X X
X X X
X XX
X`
const Font_JR_exclamation = `
XX
XX
X
X
XX
XX`
const Font_JR_f = `
XXX
X X
XXX
X
X
X
XXX`
const Font_JR_g = `
XXXXXX
X X
X X
XXXXXX
X
XXXXXX`
const Font_JR_gt = `
X
X
X
X
X`
const Font_JR_h = `
XX
X
XXXX
X X
X X
X X
XX XX`
const Font_JR_i = `
X
XXX
X
X
X
XXXX`
const Font_JR_j = `
X
XXXX
X X
X
X
X
XXX`
const Font_JR_k = `
XX
X X
X X
XXX
X X
X X
XX XX`
const Font_JR_l = `
XX
X
X
X
X
X
XX`
const Font_JR_l_brace = `
XX
X
X
X
X
X
XX`
const Font_JR_l_bracket = `
XXX
X
X
X
X
X
XXX`
const Font_JR_l_paren = `
X
X
X
X
X
X
X`
const Font_JR_lt = `
X
X
X
X
X`
const Font_JR_m = `
XXX X
X X X
X X X
X X X
XX XX`
const Font_JR_minus = `
XXXXX`
const Font_JR_n = `
XXXXX
X X
X X
X X
XX XX`
const Font_JR_o = `
XXXX
X X
X X
X X
XXXXX`
const Font_JR_p = `
XXXXXX
X X
X X
XXXXX
X
XX`
const Font_JR_percent = `
XX X
XX X
X
X
X XX
X XX`
const Font_JR_period = `
XX
XX`
const Font_JR_pipe = `
X
X
X
X
X
X
X
X`
const Font_JR_plus = `
X
X
XXXXX
X
X`
const Font_JR_q = `
XXXXXX
X X
X X
XXXXX
X
XX`
const Font_JR_question = `
XXXX
X XX
XX
XXX
XX
XX`
const Font_JR_quot = `
XX
XX
X`
const Font_JR_r = `
XX XXX
XX X
X
X
XXX`
const Font_JR_r_brace = `
XX
X
X
X
X
X
XX`
const Font_JR_r_bracket = `
XXX
X
X
X
X
X
XXX`
const Font_JR_r_paren = `
X
X
X
X
X
X
X`
const Font_JR_s = `
XXXXX
X
XXXXX
X
XXXXX`
const Font_JR_semicolon = `
XX
XX
XX
XX
X`
const Font_JR_sharp = `
X X
XXXXXX
X X
XXXXXX
X X`
const Font_JR_slash = `
X
X
X
X
X
X`
const Font_JR_sm_0 = `
XX
X X
X X
X X
X X
XX`
const Font_JR_sm_1 = `
X
X
XX
X
X
XXX`
const Font_JR_sm_2 = `
XX
X X
X
X
X
XXX`
const Font_JR_sm_3 = `
XX
X X
X
X
X
XXX`
const Font_JR_sm_4 = `
X
X X
X X
XXX
X
X`
const Font_JR_sm_5 = `
XXX
X
X
XXX
X
XX`
const Font_JR_sm_6 = `
XX
X X
X
XXX
X X
XX`
const Font_JR_sm_7 = `
XXX
X
X
X
X
X`
const Font_JR_sm_8 = `
XX
X X
X X
X
X X
XX`
const Font_JR_sm_9 = `
XX
X X
X X
XX
X
XX`
const Font_JR_sm_A = `
XX
X X
X X
XXX
X X
X X`
const Font_JR_sm_B = `
XX
X X
X X
XX
X X
XX`
const Font_JR_sm_C = `
XX
X X
X
X
X
XX`
const Font_JR_sm_D = `
XX
X X
X X
X X
X X
XX`
const Font_JR_sm_E = `
XXX
X
X
XX
X
XXX`
const Font_JR_sm_F = `
XXX
X
X
XX
X
X`
const Font_JR_sm_G = `
XX
X X
X
X X
X X
XXX`
const Font_JR_sm_H = `
X X
X X
X X
XXX
X X
X X`
const Font_JR_sm_I = `
XXX
X
X
X
X
XXX`
const Font_JR_sm_J = `
XXX
X
X
X
X
X
XX`
const Font_JR_sm_K = `
X X
X X
X X
XX
X X
X X`
const Font_JR_sm_L = `
X
X
X
X
X
XXX`
const Font_JR_sm_M = `
X X
XXX
XXX
X X
X X
X X`
const Font_JR_sm_N = `
XX
X X
X X
X X
X X
X X`
const Font_JR_sm_O = `
XX
X X
X X
X X
X X
XX`
const Font_JR_sm_P = `
XX
X X
X X
XX
X
X`
const Font_JR_sm_Q = `
XX
X X
X X
X X
X X
XX
X`
const Font_JR_sm_R = `
XX
X X
X X
XX
X X
X X`
const Font_JR_sm_S = `
X
X X
X
XXX
X
XX`
const Font_JR_sm_T = `
XXX
X
X
X
X
X`
const Font_JR_sm_U = `
X X
X X
X X
X X
X X
XX`
const Font_JR_sm_V = `
X X
X X
X X
X X
XX
X`
const Font_JR_sm_W = `
X X
X X
X X
XXX
XXX
X X`
const Font_JR_sm_X = `
X X
X X
X X
X
X X
X X`
const Font_JR_sm_Y = `
X X
X X
X X
X
X
X`
const Font_JR_sm_Z = `
XXX
X
X
X
X
XXX`
const Font_JR_sm_a = `
XX
X
XX
X X
XX`
const Font_JR_sm_amp = `
X
X X
X
X X
X
XX`
const Font_JR_sm_at = `
X
X X
XXX
XXX
X
XX`
const Font_JR_sm_b = `
X
XX
X X
X X
X X
XXX`
const Font_JR_sm_b_slash = `
X
X
X
X
X
X`
const Font_JR_sm_c = `
XX
X X
X
X
XX`
const Font_JR_sm_colon = `
XX
XX
XX
XX`
const Font_JR_sm_comma = `
XX
XX
X`
const Font_JR_sm_d = `
X
XX
X X
X X
X X
XXX`
const Font_JR_sm_dollars = `
X
XXX
XX
X
XXX
X`
const Font_JR_sm_double_quot = `
X X
X X`
const Font_JR_sm_down = `
X X
X`
const Font_JR_sm_e = `
XX
X X
XXX
X
XX`
const Font_JR_sm_equals = `
XXX
XXX`
const Font_JR_sm_eszett = `
X
X X
XX
X X
X X
XXX
X`
const Font_JR_sm_exclamation = `
XX
XX
XX
X
X`
const Font_JR_sm_f = `
X
X
X
XXX
X
X`
const Font_JR_sm_g = `
XX
X X
X X
XX
X
XX`
const Font_JR_sm_gt = `
X
X
X
X
X`
const Font_JR_sm_h = `
X
XX
X X
X X
X X
X X`
const Font_JR_sm_i = `
X
XX
X
X
XXX`
const Font_JR_sm_j = `
X
XXX
X
X
X
XX`
const Font_JR_sm_k = `
X
X X
X X
XX
X X
X X`
const Font_JR_sm_l = `
XX
X
X
X
X
X`
const Font_JR_sm_l_brace = `
XX
X
X
X
X
XX`
const Font_JR_sm_l_bracket = `
XX
X
X
X
X
XX`
const Font_JR_sm_l_paren = `
X
X
X
X
X
X`
const Font_JR_sm_lt = `
X
X
X
X
X`
const Font_JR_sm_m = `
X X
XXX
XXX
X X
X X`
const Font_JR_sm_minus = `
XXX`
const Font_JR_sm_n = `
XX
X X
X X
X X
X X`
const Font_JR_sm_o = `
XX
X X
X X
X X
XX`
const Font_JR_sm_p = `
XX
X X
X X
X X
XX
X`
const Font_JR_sm_percent = `
X X
X
X
X
X
X X`
const Font_JR_sm_period = `
XX
XX`
const Font_JR_sm_pipe = `X
X
X
X
X
X
X
X`
const Font_JR_sm_plus = `
X
X
XXX
X
X`
const Font_JR_sm_q = `
XX
X X
X X
X X
XX
X`
const Font_JR_sm_question = `
XX
X X
X
X
X`
const Font_JR_sm_quot = `
X
X`
const Font_JR_sm_r = `
XX
X X
X
X
X`
const Font_JR_sm_r_brace = `
XX
X
X
X
X
XX`
const Font_JR_sm_r_bracket = `
XX
X
X
X
X
XX`
const Font_JR_sm_r_paren = `
X
X
X
X
X
X`
const Font_JR_sm_s = `
XX
X
XXX
X
XX`
const Font_JR_sm_semicolon = `
XX
XX
XX
XX
X`
const Font_JR_sm_sharp = `
X X
XXX
X X
XXX
X X`
const Font_JR_sm_slash = `
X
X
X
X
X
X`
const Font_JR_sm_star = `
X X
XXX
XXX
X X`
const Font_JR_sm_t = `
X
XXX
X
X
X
X`
const Font_JR_sm_tilde = `
XX
X X`
const Font_JR_sm_times = `
X X
X
XXX
X
X X`
const Font_JR_sm_u = `
X X
X X
X X
X X
XX`
const Font_JR_sm_underscore = `
XXX`
const Font_JR_sm_up = `
X
X X`
const Font_JR_sm_v = `
X X
X X
X X
XX
X`
const Font_JR_sm_w = `
X X
X X
XXX
XXX
X X`
const Font_JR_sm_x = `
X X
X X
X
X X
X X`
const Font_JR_sm_y = `
X X
X X
X X
XX
X
XX`
const Font_JR_sm_z = `
XXX
X
X
X
XXX`
const Font_JR_star = `
X X
XXX
X X
XXX
X X`
const Font_JR_t = `
X
XXXX
X
X
X
XX`
const Font_JR_tilde = `
XXX X
X XXX`
const Font_JR_times = `
X
X X X
XXX
XXX
X X X
X`
const Font_JR_u = `
XX XX
X X
X X
X X
XXX`
const Font_JR_underscore = `
XXXXXXXX`
const Font_JR_up = `
X
X X
X X`
const Font_JR_v = `
XX XX
X X
X X
X X
XX`
const Font_JR_w = `
XX XX
X X X
X X X
X X X
XX X`
const Font_JR_x = `
XX XX
X X
X
X X
XX XX`
const Font_JR_y = `
XX XX
X X
X X
XXXX
X
XXXX`
const Font_JR_z = `
XXXXXXX
X XX
XXX
XX X
XXXXXXX`
const Font_a = `
X
X X
XXX
X X
X X`
const Font_b = `
XX
X X
XX
X X
XX`
const Font_c = `
XX
X
X
X
XX`
const Font_comma = `
X
X`
const Font_d = `
XX
X X
X X
X X
XXX`
const Font_dash = `
XXX`
const Font_e = `
XXX
X
XX
X
XXX`
const Font_exclamation = `
X
X
X
X`
const Font_f = `
XXX
X
XX
X
X`
const Font_g = `
XX
X
X
X X
XXX`
const Font_h = `
X X
X X
XXX
X X
X X`
const Font_i = `
XXX
X
X
X
XXX`
const Font_j = `
XXX
X
X
X
XX`
const Font_k = `
X X
X X
XX
X X
X X`
const Font_l = `
X
X
X
X
XXX`
const Font_m = `
X X
XXX
XXX
X X
X X`
const Font_n = `
XX
X X
X X
X X
X X`
const Font_o = `
XX
X X
X X
X X
XX`
const Font_p = `
XX
X X
XX
X
X`
const Font_percent = `
X X
X
X
X
X X`
const Font_period = `
X`
const Font_q = `
XX
X X
X X
XXX
X`
const Font_r = `
XX
X X
XX
X X
X X`
const Font_s = `
XX
X
XXX
X
XX`
const Font_slash = `
X
X
X
X
X`
const Font_t = `
XXX
X
X
X
X`
const Font_u = `
X X
X X
X X
X X
XX`
const Font_v = `
X X
X X
X X
X X
X`
const Font_w = `
X X
X X
XXX
XXX
X X`
const Font_x = `
X X
X X
X
X X
X X`
const Font_y = `
X X
X X
XXX
X
XXX`
const Font_z = `
XXX
X
X
X
XXX`
Variables ¶
var Blocks = map[int]rune{
0: ' ',
1: '▘',
2: '▝',
3: '▀',
4: '▖',
5: '▌',
6: '▞',
7: '▛',
8: '▗',
9: '▚',
10: '▐',
11: '▜',
12: '▄',
13: '▙',
14: '▟',
15: '█',
}
Blocks provides a map of bits to Unicode block character runes.
var ColorMap = map[rune]tm.Attribute{ 'R': tm.ColorRed, 'b': tm.Attribute(53), 't': tm.Attribute(180), 'Y': tm.ColorYellow, 'N': tm.ColorBlack, 'B': tm.ColorBlue, 'o': tm.Attribute(209), 'O': tm.Attribute(167), 'w': tm.ColorWhite, 'X': tm.ColorWhite, 'g': tm.ColorGreen, 'G': tm.Attribute(35), }
ColorMap provides an interpolation map of characters to termbox colors.
Functions ¶
This section is empty.
Types ¶
type Background ¶
type Background interface { Init() Update() Render() AddBackground(t string) }
A Background interface provides methods for initializing, updating, and rendering sprites.
type BaseBackground ¶
A BaseBackground is a 2D background which sits behind Sprites.
func (*BaseBackground) AddBackground ¶
func (s *BaseBackground) AddBackground(t string)
func (*BaseBackground) Init ¶
func (s *BaseBackground) Init()
Init provides a hook for initializing a background.
func (*BaseBackground) Render ¶
func (s *BaseBackground) Render()
Render draws background to the buffer.
func (*BaseBackground) Update ¶
func (s *BaseBackground) Update()
Update provides a hook for updating a background during the main loop.
type BaseSprite ¶
type BaseSprite struct { X int Y int Height int Width int Costumes []*Costume BlockCostumes []*Surface Alpha rune Visible bool CurrentCostume int Dead bool Events map[string]*Event }
A BaseSprite is a 2D sprite primitive.
func NewBaseSprite ¶
func NewBaseSprite(x, y int, costume Costume) *BaseSprite
NewBaseSprite creates a new BaseSprite from X and Y coordinates and a costume.
func (*BaseSprite) AddCostume ¶
func (s *BaseSprite) AddCostume(costume Costume)
AddCostume adds a costume to a BaseSprite.
func (*BaseSprite) BlockRender ¶
func (s *BaseSprite) BlockRender(bg *Surface)
BlockRender draws the sprite to the background surface
func (*BaseSprite) HitAtPoint ¶
func (s *BaseSprite) HitAtPoint(x, y int) bool
HitAtPoint reports whether a point on the screen intersects with this sprite.
func (*BaseSprite) HitAtPointSurface ¶
func (s *BaseSprite) HitAtPointSurface(x, y int) bool
HitAtPointSurface reports whether a point on the surface intersects with this sprite.
func (*BaseSprite) Init ¶
func (s *BaseSprite) Init()
Init provides a hook for initializing a sprite.
func (*BaseSprite) IsDead ¶ added in v0.1.6
func (s *BaseSprite) IsDead() bool
IsDead returns if the sprite is dead and should be reaped.
func (*BaseSprite) NextCostume ¶
func (s *BaseSprite) NextCostume()
NextCostume changes a sprite's costume to the next costume.
func (*BaseSprite) PrevCostume ¶
func (s *BaseSprite) PrevCostume()
PrevCostume changes a sprite's costume to the previous costume.
func (*BaseSprite) RegisterEvent ¶
func (s *BaseSprite) RegisterEvent(name string, fn func())
RegisterEvent registers a callback function with a name in this sprite.
func (*BaseSprite) RemoveEvent ¶
func (s *BaseSprite) RemoveEvent(name string) bool
RemoveEvent removes an event with a given name from this sprite.
func (*BaseSprite) Render ¶
func (s *BaseSprite) Render()
Render draws the sprite to the screen buffer.
func (*BaseSprite) SetCostume ¶
func (s *BaseSprite) SetCostume(c int)
SetCostume sets the current costume of a BaseSprite.
func (*BaseSprite) TriggerEvent ¶
func (s *BaseSprite) TriggerEvent(name string) bool
TriggerEvent causes a previously registered callback function to be called.
func (*BaseSprite) Update ¶
func (s *BaseSprite) Update()
Update provides a hook for updating a sprite during the main loop.
type Costume ¶
Costume contains a slice of Block pointers.
func ColorConvert ¶
ColorConvert convenience function to create a color Costume from a string
func NewCostume ¶
NewCostume provides a new Costume from a string.
func (*Costume) BottomEdge ¶
BottomEdge returns the Y value of the lowest Block in a Costume.
func (*Costume) BottomEdgeByColumn ¶
BottomEdgeByColumn returns a map of the lowest Y value in each column of a Costume.
func (*Costume) ChangeCostume ¶
ChangeCostume replaces a Costume with a new Costume from a string.
func (*Costume) LeftEdgeByRow ¶
LeftEdgeByRow returns a map of the left most X value in each row of a Costume.
func (*Costume) RightEdgeByRow ¶
RightEdgeByRow returns a map of the right most X value in each row of a Costume.
func (*Costume) TopEdgeByColumn ¶
TopEdgeByColumn returns a map of the heighest Y value in each column of a Costume.
type Font ¶
Font provides monospaced Unicode banner fonts
func New90sFont ¶ added in v0.1.3
func New90sFont() *Font
New90sFont provides a new font from based upon 90s era LCDs
func NewJRSMFont ¶
func NewJRSMFont() *Font
NewJRFont provides a font based upon Jim Reed's RPG Tileset
func NewPakuFont ¶
func NewPakuFont() *Font
NewPakuFont provides a new font from based upon Paku Paku
func (*Font) BuildString ¶
BuildString provides a unicode block string from an ASCII string.
type Sprite ¶
type Sprite interface { Init() Update() Render() BlockRender(*Surface) AddCostume(Costume) SetCostume(int) NextCostume() PrevCostume() TriggerEvent(string) bool IsDead() bool }
A Sprite interface provides methods for initializing, updating, and rendering sprites.
type SpriteGroup ¶
type SpriteGroup struct { Sprites []Sprite Events chan string BlockMode bool Background tm.Attribute // contains filtered or unexported fields }
A SpriteGroup is a convenience method for holding groups of sprites.
func (*SpriteGroup) Init ¶
func (sg *SpriteGroup) Init(width, height int, blockMode bool)
Init initializes the event channel and sets the BlockMode
func (*SpriteGroup) MoveToTop ¶ added in v0.1.3
func (sg *SpriteGroup) MoveToTop(s Sprite)
MoveToTop renders a sprite over all other sprites in the SpriteGroup.
func (*SpriteGroup) Remove ¶
func (sg *SpriteGroup) Remove(s Sprite)
Remove removes a given sprite from the SpriteGroup.
func (*SpriteGroup) RemoveAll ¶
func (sg *SpriteGroup) RemoveAll()
RemoveAll removes all sprites from the SpriteGroup.
func (*SpriteGroup) Render ¶
func (sg *SpriteGroup) Render()
Render draws each sprite in the SpriteGroup to the buffer.
func (*SpriteGroup) Resize ¶
func (sg *SpriteGroup) Resize(width, height int)
Resize changes the size of the drawing buffer in BlockMode
func (*SpriteGroup) TriggerEvent ¶
func (sg *SpriteGroup) TriggerEvent(name string)
TriggerEvent causes all events of this name to be called.
func (*SpriteGroup) Update ¶
func (sg *SpriteGroup) Update()
Update updates each sprite in the SpriteGroup.
type Surface ¶
func NewSurface ¶
NewSurface creates a Surface
func NewSurfaceFromImage ¶ added in v0.1.5
NewSurfaceFromImage returns a Surface from an image.Image
func NewSurfaceFromPng ¶
NewSurfaceFromPng returns a Surface from a PNG file
func NewSurfaceFromString ¶
NewSurfaceFromString creates a Surface which can be converted to a Costume
func NewSurfacesFromPngSheet ¶ added in v0.1.5
func (Surface) ConvertToColorCostume ¶
ConvertToColorCostume converts a Surface into a color Costume usable in a Sprite
func (Surface) ConvertToCostume ¶
ConvertToCostume converts a Surface into a Costume usable in a Sprite
type TitleArrow ¶
type TitleArrow struct { BaseSprite DX float64 DY float64 Angle float64 Type EdgeType }
func NewTitleArrow ¶
func NewTitleArrow(t EdgeType, r Rect) *TitleArrow
NewTitleArrow creates a TitleArrow in the TitleScreen.
func (*TitleArrow) Update ¶
func (s *TitleArrow) Update()
Update moves a TitleArrow in a TitleScreen.
type TitleEdge ¶
type TitleEdge struct {
BaseSprite
}
func NewTitleEdge ¶
NewTitleEdge create an edge marker in the TitleScreen.
type TitleScreen ¶
type TitleScreen struct {
Sprites SpriteGroup
}
func InitTitleScreen ¶
func InitTitleScreen(r Rect) *TitleScreen
InitTitleScreen creates a default TitleScreen.
func (*TitleScreen) Render ¶
func (t *TitleScreen) Render()
Render renders all of the Sprites in a TitleScreen.
func (*TitleScreen) Update ¶
func (t *TitleScreen) Update()
Update updates all of the Sprites in a TitleScreen.