Stages are registered in a global array
This commit is contained in:
parent
22bb03ba85
commit
f5e18a3030
4 changed files with 37 additions and 9 deletions
12
src/main.c
12
src/main.c
|
@ -11,8 +11,7 @@
|
|||
#include "taisei_err.h"
|
||||
|
||||
#include "global.h"
|
||||
#include "stages/stage0.h"
|
||||
#include "stages/stage1.h"
|
||||
#include "stage.h"
|
||||
#include "menu/mainmenu.h"
|
||||
#include "paths/native.h"
|
||||
|
||||
|
@ -116,12 +115,11 @@ int main(int argc, char** argv) {
|
|||
}
|
||||
|
||||
init_player(&global.plr);
|
||||
StageInfo* stg = stage_get(atoi(argv[1]) - 1);
|
||||
|
||||
switch(atoi(argv[1])) {
|
||||
case 1:
|
||||
stage0_loop();
|
||||
case 2:
|
||||
stage1_loop();
|
||||
if(stg) {
|
||||
printf("** Entering %s.\n", stg->title);
|
||||
stg->loop();
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* See COPYING for further information.
|
||||
* ---
|
||||
* Copyright (C) 2011, Lukas Weber <laochailan@web.de>
|
||||
* Copyright (C) 2011, Alexeyew Andrew <https://github.com/nexAkari>
|
||||
* Copyright (C) 2011, Alexeyew Andrew <http://akari.thebadasschoobs.org/>
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
|
17
src/stage.c
17
src/stage.c
|
@ -11,6 +11,23 @@
|
|||
#include "global.h"
|
||||
#include "menu/ingamemenu.h"
|
||||
|
||||
StageInfo stages[] = {
|
||||
// TODO: Give the stages actual titles/subtitles
|
||||
|
||||
{stage0_loop, False, "Stage 1", "(insert subtitle here)"},
|
||||
{stage1_loop, False, "Stage 2", "(insert subtitle here)"},
|
||||
|
||||
{NULL, False, NULL, NULL}
|
||||
};
|
||||
|
||||
StageInfo* stage_get(int n) {
|
||||
int i;
|
||||
for(i = 0; stages[i].loop; ++i)
|
||||
if(i == n)
|
||||
return &(stages[i]);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void stage_start() {
|
||||
global.timer = 0;
|
||||
global.frames = 0;
|
||||
|
|
15
src/stage.h
15
src/stage.h
|
@ -30,8 +30,21 @@
|
|||
typedef void (*StageRule)(void);
|
||||
typedef void (*ShaderRule)(int);
|
||||
|
||||
typedef struct StageInfo {
|
||||
StageRule loop;
|
||||
int hidden;
|
||||
// reserved for draw_stage_title when/if it's used
|
||||
char *title;
|
||||
char *subtitle;
|
||||
} StageInfo;
|
||||
|
||||
StageInfo* stage_get(int);
|
||||
void stage_loop(StageRule start, StageRule end, StageRule draw, StageRule event, ShaderRule *shaderrules, int endtime);
|
||||
|
||||
void apply_bg_shaders(ShaderRule *shaderrules);
|
||||
void draw_stage_title(int t, int dur, char *stage, char *subtitle);
|
||||
#endif
|
||||
|
||||
void stage0_loop();
|
||||
void stage1_loop();
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue