12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- package main
- type TileAnimated struct {
- name string
- idx int
- symbols []string
- colors []string
- update []string // when .Next() get's called ("move player", "time 100ms", "move monster")
- }
- func (t *TileAnimated) Name() string {
- return t.name
- }
- func (t *TileAnimated) Type() TileType {
- return AnimatedTile
- }
- func (t *TileAnimated) Symbol() string {
- return t.symbols[t.idx]
- }
- func (t *TileAnimated) Color() string {
- return t.colors[t.idx]
- }
- func (t *TileAnimated) Next() {
- t.idx++
- if t.idx >= len(t.symbols) {
- t.idx = 0
- }
- }
- func (t *TileAnimated) Update() []string {
- return t.update
- }
- func (t *TileAnimated) Len() int {
- return len(t.symbols)
- }
- func (t *TileAnimated) ToMap() map[string]any {
- return map[string]any{
- "name": t.name,
- "symbols": t.symbols,
- "colors": t.colors,
- "update": t.update,
- }
- }
|