blob: 6a632ebd5cb2c2ae2f66b95bf76487f834b4cbd9 (
plain) (
blame)
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
|
#include "gameCommon.h"
#include <raylib.h>
#define ANIMATION_DEFAULT_DELAY 0.1
#ifndef ANIMATION_H
#define ANIMATION_H
// The asset is what is loaded from a file and the animation is like a instance of it.
typedef struct AnimationAsset {
// The animation is stored in a image and the texture is used for fast rendering.
int frameCount;
Image image;
} AnimationAsset;
typedef struct Animation {
// Frame stuff.
int frameCount;
int currentFrame;
AnimationAsset* asset;
Texture texture;
int width;
int height;
// Timing the frames.
double delay;
double lastTime;
} Animation;
AnimationAsset loadAnimationAssetFromFile(const char* fileName);
void freeAnimationAsset(AnimationAsset* animationAsset);
Animation createAnimation(AnimationAsset* asset, double delay);
void closeAnimation(Animation* animation);
// Set the frame and update the texture.
void setAnimationFrame(Animation* animation, int frame);
void runAnimation(Animation* animation);
void pauseAnimation(Animation* animation);
#endif
|