diff --git a/src/game_state.h b/src/game_state.h index edfca31..e9e534f 100644 --- a/src/game_state.h +++ b/src/game_state.h @@ -1,11 +1,13 @@ #pragma once + /* This houses the state of an actual, running game; your player, the - other players, the world map, buildings. TODO: move some stuff to - separate files. */ + other players, the world map, buildings. */ #include #include +#include "world.h" + typedef struct Player { unsigned int id; @@ -18,41 +20,10 @@ typedef struct Player gboolean is_alive : 1, is_human : 1; } Player; -typedef enum TerrainType - { - TERRAIN_WATER, - TERRAIN_FLAT, - TERRAIN_HILL, - TERRAIN_MOUNTAIN - } TerrainType; - -typedef struct MapTile -{ - unsigned int x, y; - unsigned int owner_id; - TerrainType terrain_type; - - gboolean is_defended : 1, is_radiated : 1; -} MapTile; - -typedef struct Building -{ - MapTile *parent_tile; - unsigned int level; -} Building; - -typedef struct World -{ - GArray *tiles; - GArray *buildings; - unsigned int width, height; -} World; - typedef struct GameState { - World world; - - GList *players; + World *world; + GArray *players; Player *me; } GameState; diff --git a/src/world.c b/src/world.c new file mode 100644 index 0000000..fae69fe --- /dev/null +++ b/src/world.c @@ -0,0 +1,2 @@ +#include "world.h" + diff --git a/src/world.h b/src/world.h new file mode 100644 index 0000000..80ee669 --- /dev/null +++ b/src/world.h @@ -0,0 +1,39 @@ +#pragma once + +#include + +typedef enum TerrainType + { + TERRAIN_WATER, + TERRAIN_FLAT, + TERRAIN_HILL, + TERRAIN_MOUNTAIN + } TerrainType; + +typedef struct MapTile +{ + unsigned int x, y; + unsigned int owner_id; + TerrainType terrain_type; + + gboolean is_defended : 1, is_radiated : 1; +} MapTile; + +typedef struct Building +{ + MapTile *parent_tile; + unsigned int level; + + unsigned int (*at_what_cost) (Building *self, World *world); +} Building; + +typedef struct World +{ + unsigned int width, height; + GArray *tiles; + GArray *buildings; +} World; + +World *World_new (unsigned int width, unsigned int height); +void World_tick (World *self); +void World_render (World *self, GfxContext *gfx_context);