From 3f657da4cddff267020dd08b0544dc701e41ba00 Mon Sep 17 00:00:00 2001 From: Jordan Orelli Date: Mon, 2 Nov 2020 00:11:24 +0000 Subject: [PATCH] rename bounds to rect --- internal/math/{bounds.go => rect.go} | 10 +++++----- internal/server/sim/player.go | 2 +- internal/server/sim/room.go | 2 +- internal/server/sim/world.go | 6 +++--- internal/wire/room.go | 6 +++--- 5 files changed, 13 insertions(+), 13 deletions(-) rename internal/math/{bounds.go => rect.go} (59%) diff --git a/internal/math/bounds.go b/internal/math/rect.go similarity index 59% rename from internal/math/bounds.go rename to internal/math/rect.go index d76a61b..50c73f6 100644 --- a/internal/math/bounds.go +++ b/internal/math/rect.go @@ -1,22 +1,22 @@ package math -type Bounds struct { +type Rect struct { Origin Vec `json:"origin"` Width int `json:"width"` Height int `json:"height"` } -func CreateBounds(width, height int) Bounds { - return Bounds{ +func CreateRect(width, height int) Rect { + return Rect{ Origin: Vec{0, 0}, Width: width, Height: height, } } -func (b Bounds) Area() int { return b.Width * b.Height } +func (b Rect) Area() int { return b.Width * b.Height } -func (b Bounds) Contains(v Vec) bool { +func (b Rect) Contains(v Vec) bool { return v.X >= b.Origin.X && v.X < b.Origin.X+b.Width && v.Y >= b.Origin.Y && diff --git a/internal/server/sim/player.go b/internal/server/sim/player.go index 95ef8df..b502f6d 100644 --- a/internal/server/sim/player.go +++ b/internal/server/sim/player.go @@ -92,7 +92,7 @@ func (s *SpawnPlayer) exec(r *room, p *player, seq int) result { } welcome.Rooms[r.name] = wire.Room{ Name: r.name, - Bounds: r.Bounds, + Rect: r.Rect, Entities: ents, } for _, p := range r.players { diff --git a/internal/server/sim/room.go b/internal/server/sim/room.go index 2e5b486..a0d4adb 100644 --- a/internal/server/sim/room.go +++ b/internal/server/sim/room.go @@ -11,7 +11,7 @@ import ( type room struct { *blammo.Log name string - math.Bounds + math.Rect tiles []tile players map[string]*player } diff --git a/internal/server/sim/world.go b/internal/server/sim/world.go index 555e8b4..9ca5c47 100644 --- a/internal/server/sim/world.go +++ b/internal/server/sim/world.go @@ -20,11 +20,11 @@ type World struct { } func NewWorld(log *blammo.Log) *World { - bounds := math.CreateBounds(10, 10) + bounds := math.CreateRect(10, 10) foyer := room{ Log: log.Child("foyer"), name: "foyer", - Bounds: math.CreateBounds(10, 10), + Rect: bounds, tiles: make([]tile, bounds.Area()), players: make(map[string]*player), } @@ -34,7 +34,7 @@ func NewWorld(log *blammo.Log) *World { Glyph: 'd', behavior: doNothing{}, } - log.Info("created foyer with bounds: %#v having width: %d height: %d area: %d", foyer.Bounds, foyer.Width, foyer.Height, foyer.Area()) + log.Info("created foyer with bounds: %#v having width: %d height: %d area: %d", foyer.Rect, foyer.Width, foyer.Height, foyer.Area()) return &World{ Log: log, rooms: []room{foyer}, diff --git a/internal/wire/room.go b/internal/wire/room.go index deb1ef3..2eba046 100644 --- a/internal/wire/room.go +++ b/internal/wire/room.go @@ -6,7 +6,7 @@ import ( // Room represents a 2-dimensional coordinate space. type Room struct { - Name string `json:"name"` - math.Bounds `json:"bounds"` - Entities map[int]Entity `json:"entities"` + Name string `json:"name"` + math.Rect `json:"bounds"` + Entities map[int]Entity `json:"entities"` }