unicode + sprinting

pull/2/head
bgiraudr 1 year ago
parent fbfdca746b
commit 6949e4b58f

@ -48,6 +48,7 @@ set(ASSETS_cg
assets-cg/maps/inside/2.json
assets-cg/maps/inside/3.json
assets-cg/spritesheet.png
assets-cg/uf8x9
)
fxconv_declare_assets(${ASSETS} ${ASSETS_fx} ${ASSETS_cg} WITH_METADATA)

@ -2,7 +2,16 @@ tileset.png:
type: bopti-image
name: img_tileset
profile:p4
spritesheet.png:
type: bopti-image
name: img_spritesheet
uf8x9:
type: font
name: uf8x9
charset: unicode
grid.size: 8x11
grid.padding: 1
proportional: true
height: 9

@ -52,9 +52,9 @@
294,295,294,0,0,320,321,322,0,0,0,294,295,294,0,0,0,137,138,138,138,138,84,0,0,0,0,0,0,0,0,108,0,0,110,0,0,0,0,0,0,0,0,0,0,0,113,0,349,350,351,0,28,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,49,50,0,110,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
294,0,0,0,0,349,350,351,0,0,0,0,294,0,660,661,662,663,0,0,0,0,137,84,0,0,0,0,0,0,0,137,138,138,139,0,0,0,0,0,0,0,0,0,0,0,137,84,378,379,380,0,57,0,0,0,0,0,0,0,0,0,0,0,0,320,321,322,0,0,0,82,139,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
294,0,0,0,0,378,379,380,22,23,0,0,0,0,689,690,691,692,0,0,0,0,0,137,84,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,174,0,0,0,0,113,0,0,0,0,0,0,0,0,0,0,0,26,0,0,0,0,0,349,350,351,0,0,82,139,0,0,0,0,0,323,324,325,0,0,0,0,0,0,0,28,0,323,324,325,0,0,0,0,0,0,0,0,
0,656,657,658,659,0,0,0,51,52,0,0,0,0,718,719,720,721,0,323,324,325,0,0,137,84,0,0,320,321,322,0,0,0,0,0,0,0,0,82,83,83,203,84,0,0,0,113,0,0,0,0,0,0,0,0,0,0,0,55,0,0,0,0,0,378,379,380,0,259,260,261,0,0,0,0,0,352,353,354,0,0,0,635,636,637,638,57,0,352,353,354,0,0,0,0,0,0,0,0,
0,685,686,687,688,0,0,0,0,0,0,0,0,0,747,748,749,750,0,352,353,354,0,0,0,137,84,0,349,350,351,0,0,0,0,0,0,0,0,111,0,0,232,113,0,0,0,137,84,0,0,0,0,320,321,322,0,0,0,0,0,0,0,0,0,0,0,0,0,82,139,0,0,0,0,0,0,381,382,383,0,245,0,664,665,666,667,0,0,381,382,383,0,0,0,0,0,0,0,0,
0,714,715,716,717,245,24,25,0,246,0,24,25,245,0,0,0,0,0,381,382,383,0,0,0,0,108,0,378,379,380,0,0,0,0,82,83,83,83,139,0,0,0,113,0,0,0,0,137,84,0,0,0,349,350,351,0,0,0,0,0,0,0,0,0,0,0,0,82,139,0,0,0,0,0,0,0,0,0,0,0,274,0,693,694,695,696,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,656,657,658,659,0,0,0,51,52,0,0,0,0,718,719,720,721,0,323,324,325,0,0,137,84,0,0,320,321,322,0,0,0,0,0,0,0,0,82,83,83,203,84,0,0,0,113,0,0,0,0,0,0,0,0,0,0,0,55,0,0,0,0,0,378,379,380,0,174,111,261,0,0,0,0,0,352,353,354,0,0,0,635,636,637,638,57,0,352,353,354,0,0,0,0,0,0,0,0,
0,685,686,687,688,0,0,0,0,0,0,0,0,0,747,748,749,750,0,352,353,354,0,0,0,137,84,0,349,350,351,0,0,0,0,0,0,0,0,111,0,0,232,113,0,0,0,137,84,0,0,0,0,320,321,322,0,0,0,0,0,0,0,0,0,0,0,0,0,203,139,0,0,0,0,0,0,381,382,383,0,245,0,664,665,666,667,0,0,381,382,383,0,0,0,0,0,0,0,0,
0,714,715,716,717,245,24,25,0,246,0,24,25,245,0,0,0,0,0,381,382,383,0,0,0,0,108,0,378,379,380,0,0,0,0,82,83,83,83,139,0,0,0,113,0,0,0,0,137,84,0,0,0,349,350,351,0,0,0,0,0,0,0,0,0,0,0,0,82,232,0,0,0,0,0,0,0,0,0,0,0,274,0,693,694,695,696,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,743,744,745,746,274,53,54,0,275,0,53,54,274,0,0,0,0,0,0,0,0,0,0,0,0,108,0,0,0,0,0,0,0,0,111,0,0,0,0,0,0,0,113,0,656,657,658,659,108,0,0,0,378,379,380,0,0,0,0,0,0,0,0,0,0,82,138,139,0,0,0,0,0,0,0,0,0,0,0,0,303,0,722,723,724,725,0,0,0,0,0,635,636,637,638,0,245,0,0,
0,0,29,0,0,303,0,0,0,304,0,0,0,303,0,0,0,0,0,0,0,0,0,0,0,0,108,0,0,0,0,0,0,0,0,111,0,0,0,0,0,0,0,113,0,685,686,687,688,137,84,174,0,0,0,0,0,0,0,0,0,0,0,0,0,82,139,111,0,0,18,19,0,0,0,0,0,0,0,0,0,0,0,751,752,753,754,0,0,0,0,0,664,665,666,667,0,274,0,0,
0,0,58,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,635,636,637,638,0,79,142,0,0,0,0,0,0,0,0,111,0,0,0,0,0,29,0,113,0,714,715,716,717,0,137,203,138,138,84,0,0,0,0,0,0,0,82,138,138,139,0,140,81,0,47,48,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,25,0,0,693,694,695,696,0,303,0,0,

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

@ -5,6 +5,7 @@ struct AnimData;
typedef int (anim_function_t)(struct AnimData *data, int init);
anim_function_t anim_player_walking;
anim_function_t anim_player_sprinting;
anim_function_t anim_player_idle;
struct AnimFrame
@ -37,5 +38,7 @@ struct AnimData
void dframe(int x, int y, struct AnimFrame const frame);
/*animation for player walking*/
int anim_player_walking(struct AnimData *data, int init);
/*animation for player sprinting*/
int anim_player_sprinting(struct AnimData *data, int init);
/*animation for player doing nothing*/
int anim_player_idle(struct AnimData *data, int init);

@ -65,6 +65,33 @@ int anim_player_walking(struct AnimData *data, int init) {
return 1;
}
/*animation for player walking*/
int anim_player_sprinting(struct AnimData *data, int init) {
if(init) {
data->function = anim_player_sprinting;
data->frame = 0;
data->duration = 25;
int dx = (data->dir == DIR_LEFT) - (data->dir == DIR_RIGHT);
int dy = (data->dir == DIR_UP) - (data->dir == DIR_DOWN);
data->dx = 4 * dx;
data->dy = 4 * dy;
} else {
data->dx -= sgn(data->dx);
data->dy -= sgn(data->dy);
if(!data->dx && !data->dy) {
return anim_player_idle(data, 1);
}
data->frame = (data->frame + 1) % 3;
data->duration += 25;
}
data->img = anim_frame(&anim_player, data->dir+4, data->frame);
return 1;
}
/*animation for player doing nothing*/
int anim_player_idle(struct AnimData *data, int init) {
if(init) {

@ -77,7 +77,11 @@ int engine_move(struct Game *game, int direction) {
game->player->pos.x += dx;
game->player->pos.y += dy;
game->player->idle = !anim_player_walking(&game->player->anim, 1);
if(game->player->sprint) {
game->player->idle = !anim_player_sprinting(&game->player->anim, 1);
} else {
game->player->idle = !anim_player_walking(&game->player->anim, 1);
}
engine_check_position(game);
} else {
game->player->idle = !anim_player_idle(&game->player->anim, 1);

@ -29,6 +29,10 @@ int main(void) {
usb_interface_t const *interfaces[] = {&usb_ff_bulk, NULL};
usb_open(interfaces, GINT_CALL_NULL);
/*Font*/
extern font_t uf8x9;
dfont(&uf8x9);
/*Main loop*/
while(!keydown(KEY_MENU)) {
while(!tick) sleep();

Loading…
Cancel
Save