From 141827fa577be94379d79112397a0ae1d5b745ea Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 7 Jun 2020 13:33:44 +0100 Subject: [PATCH] Add a blank atlas to the world --- pkg/game/tile.go | 28 ++++++++++++++++++++++++++++ pkg/game/world.go | 3 +++ 2 files changed, 31 insertions(+) create mode 100644 pkg/game/tile.go diff --git a/pkg/game/tile.go b/pkg/game/tile.go new file mode 100644 index 0000000..a590076 --- /dev/null +++ b/pkg/game/tile.go @@ -0,0 +1,28 @@ +package game + +// Tile represents a single tile on the map +type Tile struct { + // Kind represends the kind of tile this is + Kind int `json:"kind"` +} + +const ( + ChunkDimensions = 10 +) + +// Chunk represents a fixed square grid of tiles +type Chunk struct { + // Tiles represents the tiles within the chunk + Tiles [ChunkDimensions][ChunkDimensions]Tile `json:"tiles"` +} + +const ( + // Use a fixed map dimension for now + AtlasDimensions = 10 +) + +// Atlas represents a grid of Chunks +// TODO: Make this resizable +type Atlas struct { + Chunks [AtlasDimensions][AtlasDimensions]Chunk `json:"chunks"` +} diff --git a/pkg/game/world.go b/pkg/game/world.go index 5a71db0..09cdf61 100644 --- a/pkg/game/world.go +++ b/pkg/game/world.go @@ -14,6 +14,9 @@ type World struct { // Rovers is a id->data map of all the rovers in the game Rovers map[uuid.UUID]Rover `json:"rovers"` + // Atlas represends the world map of chunks and tiles + Atlas Atlas `json:"atlas"` + // Mutex to lock around all world operations worldMutex sync.RWMutex