tile_animated.go 841 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package main
  2. type TileAnimated struct {
  3. name string
  4. idx int
  5. symbols []string
  6. colors []string
  7. update []string // when .Next() get's called ("move player", "time 100ms", "move monster")
  8. }
  9. func (t *TileAnimated) Name() string {
  10. return t.name
  11. }
  12. func (t *TileAnimated) Type() TileType {
  13. return AnimatedTile
  14. }
  15. func (t *TileAnimated) Symbol() string {
  16. return t.symbols[t.idx]
  17. }
  18. func (t *TileAnimated) Color() string {
  19. return t.colors[t.idx]
  20. }
  21. func (t *TileAnimated) Next() {
  22. t.idx++
  23. if t.idx >= len(t.symbols) {
  24. t.idx = 0
  25. }
  26. }
  27. func (t *TileAnimated) Update() []string {
  28. return t.update
  29. }
  30. func (t *TileAnimated) Len() int {
  31. return len(t.symbols)
  32. }
  33. func (t *TileAnimated) ToMap() map[string]any {
  34. return map[string]any{
  35. "name": t.name,
  36. "symbols": t.symbols,
  37. "colors": t.colors,
  38. "update": t.update,
  39. }
  40. }