45 lines
1.2 KiB
C
45 lines
1.2 KiB
C
#include <microfx/ext/img.h>
|
|
|
|
#include "game.h"
|
|
|
|
#include "assets.h"
|
|
|
|
int frames_amount_actions[A_AMOUNT] = {
|
|
8,
|
|
12
|
|
};
|
|
|
|
void pinit(Game *game) {
|
|
game->player.anim.anim_frame = 0;
|
|
game->player.anim.anim_max = 12;
|
|
game->player.action = A_RUN;
|
|
game->player.anim.delay_elapsed = 0;
|
|
game->player.anim.delay_max = 5; /* Because the game will run at 50fps (so
|
|
1 frame = 20ms), and one animation frame
|
|
takes 100ms, the delay should be
|
|
100/20 = 5. */
|
|
game->player.anim.amount_anim_done = 0;
|
|
}
|
|
|
|
void pdraw(Game *game) {
|
|
simage(
|
|
(*game->map).px, (*game->map).py,
|
|
32, 48,
|
|
player_alpha[game->player.skin * 2 + game->player.action]
|
|
[game->player.anim.anim_frame],
|
|
STRANSP
|
|
);
|
|
simage(
|
|
(*game->map).px, (*game->map).py,
|
|
32, 48,
|
|
player_sprites[game->player.skin * 2 + game->player.action]
|
|
[game->player.anim.anim_frame],
|
|
SNOWHITE
|
|
);
|
|
}
|
|
|
|
void pset_action(Game *game, int n) {
|
|
game->player.anim.anim_frame = 0;
|
|
game->player.anim.anim_max = frames_amount_actions[n];
|
|
game->player.skin = n;
|
|
} |