allow endings to be skipped
This commit is contained in:
parent
235e2e0783
commit
06900313af
1 changed files with 16 additions and 4 deletions
20
src/ending.c
20
src/ending.c
|
@ -206,6 +206,16 @@ void ending_preload(void) {
|
|||
preload_resource(RES_BGM, "ending", RESF_OPTIONAL);
|
||||
}
|
||||
|
||||
static void ending_advance(Ending *e) {
|
||||
if(
|
||||
e->pos < e->count-1 &&
|
||||
e->entries[e->pos].time + ENDING_FADE_TIME < global.frames &&
|
||||
global.frames < e->entries[e->pos+1].time - ENDING_FADE_TIME
|
||||
) {
|
||||
e->entries[e->pos+1].time = global.frames+(e->pos != e->count-2)*ENDING_FADE_TIME;
|
||||
}
|
||||
}
|
||||
|
||||
static bool ending_input_handler(SDL_Event *event, void *arg) {
|
||||
Ending *e = arg;
|
||||
|
||||
|
@ -215,10 +225,7 @@ static bool ending_input_handler(SDL_Event *event, void *arg) {
|
|||
switch(type) {
|
||||
case TE_GAME_KEY_DOWN:
|
||||
if(code == KEY_SHOT) {
|
||||
if(e->pos < e->count-1
|
||||
&& e->entries[e->pos].time+ENDING_FADE_TIME < global.frames
|
||||
&& global.frames < e->entries[e->pos+1].time-ENDING_FADE_TIME)
|
||||
e->entries[e->pos+1].time = global.frames+(e->pos != e->count-2)*ENDING_FADE_TIME;
|
||||
ending_advance(e);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -252,6 +259,11 @@ static FrameAction ending_logic_frame(void *arg) {
|
|||
return LFRAME_STOP;
|
||||
}
|
||||
|
||||
if(gamekeypressed(KEY_SKIP)) {
|
||||
ending_advance(e);
|
||||
return LFRAME_SKIP;
|
||||
}
|
||||
|
||||
return LFRAME_WAIT;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue