diff --git a/src/level.c b/src/level.c index 309ef35..5bc6c13 100644 --- a/src/level.c +++ b/src/level.c @@ -45,6 +45,7 @@ void SelectDerpySpritesheet(struct Game *game, char* name) { game->level.sheet_speed_modifier = tmp->speed; game->level.sheet_pos = 0; game->level.sheet_scale = tmp->scale; + game->level.sheet_successor = tmp->successor; 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); 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->aspect = atof(al_get_config_value(config, "", "aspect")); 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; game->level.derpy_sheets = s; al_destroy_config(config); @@ -221,7 +228,12 @@ void Level_Draw(struct Game *game) { game->level.sheet_pos++; 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)); diff --git a/src/main.h b/src/main.h index 45ffb10..edcfeff 100644 --- a/src/main.h +++ b/src/main.h @@ -87,6 +87,7 @@ struct Spritesheet { float speed; /*!< Speed modifier of spritesheet animation. */ float aspect; /*!< Aspect ratio 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. */ }; @@ -124,6 +125,7 @@ struct Level { int sheet_cols; /*!< Number of cols in current spritesheet. */ int sheet_pos; /*!< Frame position in 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_speed; /*!< Current speed of Derpy animation. */ float sheet_speed_modifier; /*!< Modifier of speed, specified by current spritesheet. */