1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
#include "assets.h"
#include <raylib.h>
const char textureAssetsNames[TEXTURE_ASSET_COUNT][ASSETS_NAME_MAX] = {
"mainScreenBackground.png",
"penguinBackground.png",
"toEmperorsEmporiumIcon.png",
"toGameIcon.png",
"emperorShopUI.png",
"shopBoard"
};
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] = loadAnimationAssetFromFile(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)
{
freeAnimationAsset(&assets->animations[i]);
}
TraceLog(LOG_INFO, "Assets closed");
}
|