123456789101112131415161718192021222324252627282930313233343536373839404142 |
- package main
- import door "git.red-green.com/RedGreen/doorgo"
- type Camera struct {
- Size *Vec2
- }
- func (c *Camera) debugView(at *Vec2, w *World) string {
- out := ""
- t := at.Clone()
- t.X -= c.Size.X / 2
- t.Y -= c.Size.Y / 2
- for y := range make([]byte, c.Size.Y) {
- for x := range make([]byte, c.Size.X) {
- id := w.Get(uint64(t.X)+uint64(x), uint64(t.Y)+uint64(y))
- if id == 0 {
- out += " "
- } else {
- out += w.TileIndex.Tiles[id].Symbol
- }
- }
- out += "\r\n"
- }
- return out
- }
- func (c *Camera) View(at *Vec2, offset *Vec2, w *World) string {
- out := ""
- t := at.Clone()
- t.X -= c.Size.X / 2
- t.Y -= c.Size.Y / 2
- for y := range make([]byte, c.Size.Y) {
- for x := range make([]byte, c.Size.X) {
- id := w.Get(uint64(t.X)+uint64(x), uint64(t.Y)+uint64(y))
- if id != 0 {
- out += door.GotoS(int(offset.X)+x, int(offset.Y)+y) + door.ColorTextS(w.TileIndex.Tiles[id].Color) + w.TileIndex.Tiles[id].Symbol + door.Reset
- }
- }
- }
- return out
- }
|