Switch entity anims to use references to assets
This commit is contained in:
@@ -13,21 +13,22 @@ typedef struct AssetManager
|
||||
Texture textures[32];
|
||||
TexAtlas texAtlas[32];
|
||||
Shader shaders[32];
|
||||
Animation anims[32];
|
||||
Font font;
|
||||
} AssetManager;
|
||||
|
||||
GLOBAL_VAR AssetManager assetManager;
|
||||
|
||||
/* Texture */
|
||||
Texture *asset_getTexture(AssetManager *assetManager, const enum TexList type);
|
||||
Shader *asset_getShader(AssetManager *assetManager, const enum ShaderList type);
|
||||
TexAtlas *asset_getTextureAtlas(AssetManager *assetManager,
|
||||
const enum TexList type);
|
||||
Animation *asset_getAnim(AssetManager *assetManager, i32 type);
|
||||
|
||||
const i32 asset_loadTextureImage(AssetManager *assetManager,
|
||||
const char *const path,
|
||||
const enum TexList type);
|
||||
|
||||
/* Shaders */
|
||||
Shader *asset_getShader(AssetManager *assetManager, const enum ShaderList type);
|
||||
const i32 asset_loadShaderFiles(AssetManager *assetManager,
|
||||
const char *const vertexPath,
|
||||
const char *const fragmentPath,
|
||||
@@ -42,4 +43,8 @@ inline i32 asset_getVFontSpacing(FontMetrics metrics)
|
||||
return result;
|
||||
}
|
||||
|
||||
void asset_addAnimation(AssetManager *assetManager, i32 texId,
|
||||
i32 animId, i32 *atlasIndexes, i32 numFrames,
|
||||
f32 frameDuration);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -19,10 +19,10 @@ enum ShaderList
|
||||
shaderlist_count,
|
||||
};
|
||||
|
||||
enum TerrainCoords
|
||||
enum TerrainRects
|
||||
{
|
||||
terraincoords_ground,
|
||||
terraincoords_count,
|
||||
terrainrects_ground,
|
||||
terrainrects_count,
|
||||
};
|
||||
|
||||
enum HeroRects
|
||||
@@ -40,12 +40,33 @@ enum HeroRects
|
||||
herorects_count,
|
||||
};
|
||||
|
||||
enum AnimList
|
||||
{
|
||||
animlist_hero_idle,
|
||||
animlist_hero_walk,
|
||||
animlist_hero_wave,
|
||||
animlist_hero_battlePose,
|
||||
animlist_hero_tackle,
|
||||
animlist_terrain,
|
||||
animlist_count,
|
||||
animlist_invalid,
|
||||
};
|
||||
|
||||
typedef struct TexAtlas
|
||||
{
|
||||
// TODO(doyle): String hash based lookup
|
||||
v4 texRect[128];
|
||||
} TexAtlas;
|
||||
|
||||
typedef struct Animation
|
||||
{
|
||||
Texture *tex;
|
||||
TexAtlas *atlas;
|
||||
i32 *atlasIndexes;
|
||||
i32 numFrames;
|
||||
f32 frameDuration;
|
||||
} Animation;
|
||||
|
||||
// TODO(doyle): We only use the offset and advance metric at the moment, remove?
|
||||
typedef struct FontMetrics
|
||||
{
|
||||
|
||||
@@ -25,17 +25,6 @@ enum EntityType
|
||||
entitytype_count,
|
||||
};
|
||||
|
||||
enum EntityAnimId
|
||||
{
|
||||
entityanimid_idle,
|
||||
entityanimid_walk,
|
||||
entityanimid_wave,
|
||||
entityanimid_battlePose,
|
||||
entityanimid_tackle,
|
||||
entityanimid_count,
|
||||
entityanimid_invalid,
|
||||
};
|
||||
|
||||
enum EntityState
|
||||
{
|
||||
entitystate_idle,
|
||||
@@ -46,16 +35,6 @@ enum EntityState
|
||||
entitystate_invalid,
|
||||
};
|
||||
|
||||
typedef struct EntityAnim
|
||||
{
|
||||
v4 *rect;
|
||||
i32 numRects;
|
||||
i32 currRectIndex;
|
||||
|
||||
f32 duration;
|
||||
f32 currDuration;
|
||||
} EntityAnim;
|
||||
|
||||
enum EntityAttack
|
||||
{
|
||||
entityattack_tackle,
|
||||
@@ -77,6 +56,13 @@ typedef struct EntityStats
|
||||
i32 queuedAttack;
|
||||
} EntityStats;
|
||||
|
||||
typedef struct EntityAnim_
|
||||
{
|
||||
Animation *anim;
|
||||
i32 currFrame;
|
||||
f32 currDuration;
|
||||
} EntityAnim_;
|
||||
|
||||
typedef struct Entity
|
||||
{
|
||||
v2 pos; // Position
|
||||
@@ -92,7 +78,7 @@ typedef struct Entity
|
||||
b32 collides;
|
||||
|
||||
// TODO(doyle): String based access
|
||||
EntityAnim anim[16];
|
||||
EntityAnim_ anim[16];
|
||||
i32 currAnimId;
|
||||
u32 currAnimCyclesCompleted;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user