diff options
Diffstat (limited to 'src/assets.c')
-rw-r--r-- | src/assets.c | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/src/assets.c b/src/assets.c index 4ed3d53..05e2b04 100644 --- a/src/assets.c +++ b/src/assets.c @@ -1 +1,69 @@ #include "assets.h" +#include <raylib.h> + +const char textureAssetsNames[TEXTURE_ASSET_COUNT][ASSETS_NAME_MAX] = { + "mainScreenBackground.png", + "penguinBackground.png", + "toEmperorsEmporiumIcon.png", + "toGameIcon.png" +}; + +const char animationAssetsNames[ANIMATION_ASSET_COUNT][ASSETS_NAME_MAX] = { + "buttonBox.gif", + "penguinLol.gif" +}; + +void loadTextures(Assets* assets) +{ + for (int i = 0; i < TEXTURE_ASSET_COUNT; ++i) + { + char filePath[ASSETS_NAME_MAX]; + snprintf(filePath, ASSETS_NAME_MAX, "assets/%s", textureAssetsNames[i]); + assets->textures[i] = LoadTexture(filePath); + } +} + +void loadAnimations(Assets* assets) +{ + for (int i = 0; i < ANIMATION_ASSET_COUNT; ++i) + { + char filePath[ASSETS_NAME_MAX]; + snprintf(filePath, ASSETS_NAME_MAX, "assets/%s", animationAssetsNames[i]); + assets->animations[i] = loadAnimationFromFile(filePath); + } +} + +// Used for setting different options in assets like animation delay. +void configureAssets(Assets* assets) +{ +} + +void initAssets(Assets* assets) +{ + TraceLog(LOG_INFO, "Loading assets"); + + loadTextures(assets); + loadAnimations(assets); + configureAssets(assets); + + TraceLog(LOG_INFO, "Assets loaded"); +} + +void closeAssets(Assets* assets) +{ + TraceLog(LOG_INFO, "Closing assets"); + + // Textures. + for (int i = 0; i < TEXTURE_ASSET_COUNT; ++i) + { + UnloadTexture(assets->textures[i]); + } + + // Animations. + for (int i = 0; i < ANIMATION_ASSET_COUNT; ++i) + { + freeAnimation(&assets->animations[i]); + } + + TraceLog(LOG_INFO, "Assets closed"); +} |