camera.go 445 B

123456789101112131415161718192021222324
  1. package main
  2. type Camera struct {
  3. Size *Vec2
  4. }
  5. func (c *Camera) debugView(at *Vec2, w *World) string {
  6. out := ""
  7. t := at.Clone()
  8. t.X -= c.Size.X / 2
  9. t.Y -= c.Size.Y / 2
  10. for y := range make([]byte, c.Size.Y) {
  11. for x := range make([]byte, c.Size.X) {
  12. id := w.Get(uint64(t.X)+uint64(x), uint64(t.Y)+uint64(y))
  13. if id == 0 {
  14. out += " "
  15. } else {
  16. out += w.TileIndex.Tiles[id].Symbol
  17. }
  18. }
  19. out += "\r\n"
  20. }
  21. return out
  22. }