This commit is contained in:
2025-09-09 08:19:58 +02:00
parent 44a072b0b5
commit 167bc496db
3 changed files with 47 additions and 35 deletions
+6 -35
View File
@@ -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 <glib-2.0/glib.h>
#include <SDL3/SDL.h>
#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;
+2
View File
@@ -0,0 +1,2 @@
#include "world.h"
+39
View File
@@ -0,0 +1,39 @@
#pragma once
#include <glib-2.0/glib.h>
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);