mirror of
https://gitlab.com/dosowisko.net/libsuperderpy.git
synced 2025-02-01 11:06:44 +01:00
better structure of level-moonwalk relationship
This commit is contained in:
parent
90c20b0c1c
commit
3e17070298
3 changed files with 40 additions and 24 deletions
44
src/level.c
44
src/level.c
|
@ -20,32 +20,62 @@
|
|||
*/
|
||||
#include <stdio.h>
|
||||
#include "moonwalk.h"
|
||||
#include "config.h"
|
||||
#include "pause.h"
|
||||
#include "level.h"
|
||||
|
||||
void Level_Passed(struct Game *game) {
|
||||
if (game->level.current_level<6) {
|
||||
int available = atoi(GetConfigOptionDefault("MuffinAttack", "level", "1"));
|
||||
available++;
|
||||
if ((available<2) || (available>7)) available=1;
|
||||
if (available==(game->level.current_level+1)) {
|
||||
char* text = malloc(2*sizeof(char));
|
||||
sprintf(text, "%d", available);
|
||||
SetConfigOption("MuffinAttack", "level", text);
|
||||
free(text);
|
||||
}
|
||||
} else {
|
||||
SetConfigOption("MuffinAttack", "completed", "1");
|
||||
}
|
||||
}
|
||||
|
||||
void Level_Draw(struct Game *game) {
|
||||
Moonwalk_Draw(game);
|
||||
if (game->level.current_level!=1) Moonwalk_Draw(game);
|
||||
else {
|
||||
al_clear_to_color(al_map_rgb(0,0,0));
|
||||
}
|
||||
}
|
||||
|
||||
void Level_Load(struct Game *game) {
|
||||
Moonwalk_Load(game);
|
||||
if (game->level.current_level!=1) Moonwalk_Load(game);
|
||||
}
|
||||
|
||||
int Level_Keydown(struct Game *game, ALLEGRO_EVENT *ev) {
|
||||
return Moonwalk_Keydown(game, ev);
|
||||
if (game->level.current_level!=1) Moonwalk_Keydown(game, ev);
|
||||
if (ev->keyboard.keycode==ALLEGRO_KEY_ESCAPE) {
|
||||
game->gamestate = GAMESTATE_PAUSE;
|
||||
game->loadstate = GAMESTATE_LEVEL;
|
||||
Pause_Load(game);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Level_Preload(struct Game *game) {
|
||||
Moonwalk_Preload(game);
|
||||
Pause_Preload(game);
|
||||
if (game->level.current_level!=1) Moonwalk_Preload(game);
|
||||
}
|
||||
|
||||
void Level_Unload(struct Game *game) {
|
||||
Moonwalk_Unload(game);
|
||||
Pause_Unload_Real(game);
|
||||
if (game->level.current_level!=1) Moonwalk_Unload(game);
|
||||
else Level_Passed(game);
|
||||
}
|
||||
|
||||
void Level_UnloadBitmaps(struct Game *game) {
|
||||
Moonwalk_UnloadBitmaps(game);
|
||||
if (game->level.current_level!=1) Moonwalk_UnloadBitmaps(game);
|
||||
}
|
||||
|
||||
void Level_PreloadBitmaps(struct Game *game) {
|
||||
Moonwalk_PreloadBitmaps(game);
|
||||
if (game->level.current_level!=1) Moonwalk_PreloadBitmaps(game);
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
*/
|
||||
#include "main.h"
|
||||
|
||||
void Level_Passed(struct Game *game);
|
||||
void Level_Draw(struct Game *game);
|
||||
void Level_Preload(struct Game *game);
|
||||
void Level_Unload(struct Game *game);
|
||||
|
|
|
@ -20,9 +20,8 @@
|
|||
*/
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include "pause.h"
|
||||
#include "level.h"
|
||||
#include "moonwalk.h"
|
||||
#include "config.h"
|
||||
|
||||
void Moonwalk_Draw(struct Game *game) {
|
||||
if (!al_get_sample_instance_playing(game->level.moonwalk.music) && (game->loadstate==GAMESTATE_LEVEL)) {
|
||||
|
@ -36,17 +35,8 @@ void Moonwalk_Draw(struct Game *game) {
|
|||
|
||||
game->level.moonwalk.derpy_pos=game->level.moonwalk.derpy_pos+tps(game, 60*0.00092);
|
||||
if (game->level.moonwalk.derpy_pos>1) { UnloadGameState(game);
|
||||
Level_Passed(game);
|
||||
if (game->level.current_level<6) {
|
||||
|
||||
int available = atoi(GetConfigOptionDefault("MuffinAttack", "level", "1"));
|
||||
available++;
|
||||
if ((available<2) || (available>7)) available=1;
|
||||
if (available==(game->level.current_level+1)) {
|
||||
char* text = malloc(2*sizeof(char));
|
||||
sprintf(text, "%d", available);
|
||||
SetConfigOption("MuffinAttack", "level", text);
|
||||
free(text);
|
||||
}
|
||||
game->gamestate = GAMESTATE_LOADING;
|
||||
game->loadstate = GAMESTATE_MAP;
|
||||
//LoadGameState(game);
|
||||
|
@ -93,9 +83,6 @@ int Moonwalk_Keydown(struct Game *game, ALLEGRO_EVENT *ev) {
|
|||
if (ev->keyboard.keycode==ALLEGRO_KEY_ESCAPE) {
|
||||
game->level.moonwalk.music_pos = al_get_sample_instance_position(game->level.moonwalk.music);
|
||||
al_set_sample_instance_playing(game->level.moonwalk.music, false);
|
||||
game->gamestate = GAMESTATE_PAUSE;
|
||||
game->loadstate = GAMESTATE_LEVEL;
|
||||
Pause_Load(game);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -127,7 +114,6 @@ void Moonwalk_Preload(struct Game *game) {
|
|||
}
|
||||
|
||||
Moonwalk_PreloadBitmaps(game);
|
||||
Pause_Preload(game);
|
||||
}
|
||||
|
||||
void Moonwalk_UnloadBitmaps(struct Game *game) {
|
||||
|
@ -137,7 +123,6 @@ void Moonwalk_UnloadBitmaps(struct Game *game) {
|
|||
}
|
||||
|
||||
void Moonwalk_Unload(struct Game *game) {
|
||||
Pause_Unload_Real(game);
|
||||
ALLEGRO_EVENT ev;
|
||||
game->level.moonwalk.fade_bitmap = al_create_bitmap(al_get_display_width(game->display), al_get_display_height(game->display));
|
||||
al_set_target_bitmap(game->level.moonwalk.fade_bitmap);
|
||||
|
|
Loading…
Reference in a new issue