Add a blank atlas to the world
This commit is contained in:
parent
77be28f913
commit
141827fa57
2 changed files with 31 additions and 0 deletions
28
pkg/game/tile.go
Normal file
28
pkg/game/tile.go
Normal file
|
@ -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"`
|
||||||
|
}
|
|
@ -14,6 +14,9 @@ type World struct {
|
||||||
// Rovers is a id->data map of all the rovers in the game
|
// Rovers is a id->data map of all the rovers in the game
|
||||||
Rovers map[uuid.UUID]Rover `json:"rovers"`
|
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
|
// Mutex to lock around all world operations
|
||||||
worldMutex sync.RWMutex
|
worldMutex sync.RWMutex
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue