Add tile grid and atlas concept to game
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
enum TexList
|
||||
{
|
||||
texlist_hero,
|
||||
texlist_terrain,
|
||||
texlist_count,
|
||||
};
|
||||
|
||||
@@ -16,10 +17,24 @@ enum ShaderList
|
||||
shaderlist_count,
|
||||
};
|
||||
|
||||
enum TerrainCoords
|
||||
{
|
||||
terraincoords_ground,
|
||||
terraincoords_count,
|
||||
};
|
||||
|
||||
typedef struct TexAtlas
|
||||
{
|
||||
// TODO(doyle): String hash based lookup
|
||||
v4 texRect[16];
|
||||
|
||||
} TexAtlas;
|
||||
|
||||
// TODO(doyle): Switch to hash based lookup
|
||||
typedef struct AssetManager
|
||||
{
|
||||
Texture textures[256];
|
||||
TexAtlas texAtlas[256];
|
||||
Shader shaders[256];
|
||||
} AssetManager;
|
||||
|
||||
@@ -27,6 +42,7 @@ extern AssetManager assetManager;
|
||||
|
||||
/* Texture */
|
||||
Texture *asset_getTexture(const enum TexList type);
|
||||
TexAtlas *asset_getTextureAtlas(const enum TexList type);
|
||||
const i32 asset_loadTextureImage(const char *const path,
|
||||
const enum TexList type);
|
||||
|
||||
|
||||
@@ -37,7 +37,6 @@ typedef struct Entity
|
||||
SpriteAnim anim[16];
|
||||
i32 freeAnimIndex;
|
||||
i32 currAnimIndex;
|
||||
|
||||
} Entity;
|
||||
|
||||
INTERNAL inline v4 getEntityScreenRect(Entity entity)
|
||||
|
||||
@@ -15,4 +15,7 @@ typedef struct Renderer
|
||||
void renderer_entity(Renderer *renderer, Entity *entity, f32 rotate,
|
||||
v3 color);
|
||||
|
||||
void renderer_object(Renderer *renderer, v2 pos, v2 size, f32 rotate, v3 color,
|
||||
Texture *tex);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -12,9 +12,20 @@ enum State
|
||||
{
|
||||
state_active,
|
||||
state_menu,
|
||||
state_win
|
||||
state_win,
|
||||
};
|
||||
|
||||
typedef struct Tile
|
||||
{
|
||||
v2 pos;
|
||||
} Tile;
|
||||
|
||||
typedef struct World
|
||||
{
|
||||
Tile tiles[2048];
|
||||
enum TexList texType;
|
||||
} World;
|
||||
|
||||
typedef struct GameState
|
||||
{
|
||||
enum State state;
|
||||
@@ -24,6 +35,10 @@ typedef struct GameState
|
||||
Renderer renderer;
|
||||
i32 heroIndex;
|
||||
|
||||
World world[4];
|
||||
i32 currWorldIndex;
|
||||
i32 tileSize;
|
||||
|
||||
// TODO(doyle): Make size of list dynamic
|
||||
Entity entityList[256];
|
||||
i32 freeEntityIndex;
|
||||
|
||||
Reference in New Issue
Block a user