mirror of
https://gitlab.com/dosowisko.net/libsuperderpy.git
synced 2024-12-13 04:27:59 +01:00
implement spritesheet successors
This commit is contained in:
parent
042d29aff4
commit
a6a02ba0c2
2 changed files with 15 additions and 1 deletions
14
src/level.c
14
src/level.c
|
@ -45,6 +45,7 @@ void SelectDerpySpritesheet(struct Game *game, char* name) {
|
||||||
game->level.sheet_speed_modifier = tmp->speed;
|
game->level.sheet_speed_modifier = tmp->speed;
|
||||||
game->level.sheet_pos = 0;
|
game->level.sheet_pos = 0;
|
||||||
game->level.sheet_scale = tmp->scale;
|
game->level.sheet_scale = tmp->scale;
|
||||||
|
game->level.sheet_successor = tmp->successor;
|
||||||
if (game->level.derpy) al_destroy_bitmap(game->level.derpy);
|
if (game->level.derpy) al_destroy_bitmap(game->level.derpy);
|
||||||
game->level.derpy = al_create_bitmap((game->viewportHeight*0.25)*tmp->aspect*tmp->scale, (game->viewportHeight*0.25)*tmp->scale);
|
game->level.derpy = al_create_bitmap((game->viewportHeight*0.25)*tmp->aspect*tmp->scale, (game->viewportHeight*0.25)*tmp->scale);
|
||||||
PrintConsole(game, "SUCCESS: Derpy spritesheet activated: %s (%dx%d)", name, al_get_bitmap_width(game->level.derpy), al_get_bitmap_height(game->level.derpy));
|
PrintConsole(game, "SUCCESS: Derpy spritesheet activated: %s (%dx%d)", name, al_get_bitmap_width(game->level.derpy), al_get_bitmap_height(game->level.derpy));
|
||||||
|
@ -70,6 +71,12 @@ void RegisterDerpySpritesheet(struct Game *game, char* name) {
|
||||||
s->speed = atof(al_get_config_value(config, "", "speed"));
|
s->speed = atof(al_get_config_value(config, "", "speed"));
|
||||||
s->aspect = atof(al_get_config_value(config, "", "aspect"));
|
s->aspect = atof(al_get_config_value(config, "", "aspect"));
|
||||||
s->scale = atof(al_get_config_value(config, "", "scale"));
|
s->scale = atof(al_get_config_value(config, "", "scale"));
|
||||||
|
s->successor=NULL;
|
||||||
|
const char* successor = al_get_config_value(config, "", "successor");
|
||||||
|
if (successor) {
|
||||||
|
s->successor = malloc(255*sizeof(char));
|
||||||
|
strcpy(s->successor, successor);
|
||||||
|
}
|
||||||
s->next = game->level.derpy_sheets;
|
s->next = game->level.derpy_sheets;
|
||||||
game->level.derpy_sheets = s;
|
game->level.derpy_sheets = s;
|
||||||
al_destroy_config(config);
|
al_destroy_config(config);
|
||||||
|
@ -221,7 +228,12 @@ void Level_Draw(struct Game *game) {
|
||||||
game->level.sheet_pos++;
|
game->level.sheet_pos++;
|
||||||
game->level.sheet_tmp = 0;
|
game->level.sheet_tmp = 0;
|
||||||
}
|
}
|
||||||
if (game->level.sheet_pos>=game->level.sheet_cols*game->level.sheet_rows-game->level.sheet_blanks) game->level.sheet_pos=0;
|
if (game->level.sheet_pos>=game->level.sheet_cols*game->level.sheet_rows-game->level.sheet_blanks) {
|
||||||
|
game->level.sheet_pos=0;
|
||||||
|
if (game->level.sheet_successor) {
|
||||||
|
SelectDerpySpritesheet(game, game->level.sheet_successor);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
al_set_target_bitmap(al_get_backbuffer(game->display));
|
al_set_target_bitmap(al_get_backbuffer(game->display));
|
||||||
|
|
||||||
|
|
|
@ -87,6 +87,7 @@ struct Spritesheet {
|
||||||
float speed; /*!< Speed modifier of spritesheet animation. */
|
float speed; /*!< Speed modifier of spritesheet animation. */
|
||||||
float aspect; /*!< Aspect ratio of the frame. */
|
float aspect; /*!< Aspect ratio of the frame. */
|
||||||
float scale; /*!< Scale modifier of the frame. */
|
float scale; /*!< Scale modifier of the frame. */
|
||||||
|
char* successor; /*!< Name of animation successor. If it's not blank, then animation will be played only once. */
|
||||||
struct Spritesheet* next; /*!< Next spritesheet in the queue. */
|
struct Spritesheet* next; /*!< Next spritesheet in the queue. */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -124,6 +125,7 @@ struct Level {
|
||||||
int sheet_cols; /*!< Number of cols in current spritesheet. */
|
int sheet_cols; /*!< Number of cols in current spritesheet. */
|
||||||
int sheet_pos; /*!< Frame position in current spritesheet. */
|
int sheet_pos; /*!< Frame position in current spritesheet. */
|
||||||
int sheet_blanks; /*!< Number of blank frames at the end of current spritesheet. */
|
int sheet_blanks; /*!< Number of blank frames at the end of current spritesheet. */
|
||||||
|
char* sheet_successor; /*!< Successor of current animation. If blank, then it's looped. */
|
||||||
float sheet_tmp; /*!< Temporary counter used to slow down spritesheet animation. */
|
float sheet_tmp; /*!< Temporary counter used to slow down spritesheet animation. */
|
||||||
float sheet_speed; /*!< Current speed of Derpy animation. */
|
float sheet_speed; /*!< Current speed of Derpy animation. */
|
||||||
float sheet_speed_modifier; /*!< Modifier of speed, specified by current spritesheet. */
|
float sheet_speed_modifier; /*!< Modifier of speed, specified by current spritesheet. */
|
||||||
|
|
Loading…
Reference in a new issue