Skip to content

Commit

Permalink
Will prevent the user from getting to the debug screen by pressing ke…
Browse files Browse the repository at this point in the history
…ys at random on game start
  • Loading branch information
alemart committed Oct 5, 2019
1 parent 62335d6 commit c7fbb45
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
25 changes: 23 additions & 2 deletions src/scenes/intro.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Open Surge Engine
* intro.c - introduction screen
* Copyright (C) 2008-2011, 2013, 2018 Alexandre Martins <[email protected]>
* Copyright (C) 2008-2011, 2013, 2018, 2019 Alexandre Martins <[email protected]>
* http://opensurge2d.org
*
* This program is free software; you can redistribute it and/or modify
Expand All @@ -18,6 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include <stdbool.h>
#include <stdlib.h>
#include "intro.h"
#include "../core/global.h"
Expand All @@ -44,6 +45,8 @@ static int debug_mode;
static font_t* fnt;
static input_t* in;
static image_t* box;
static bool any_button_pressed(input_t* in);


/* public functions */

Expand Down Expand Up @@ -100,6 +103,8 @@ void intro_release()
*/
void intro_update()
{
static int cnt = 0;

/* elapsed time */
elapsed_time += timer_get_delta();

Expand All @@ -120,14 +125,15 @@ void intro_update()

/* secret */
if(input_button_pressed(in, IB_RIGHT)) {
static int cnt = 0;
if(!debug_mode && ++cnt == 3) {
sound_play(SFX_SECRET);
elapsed_time += INTRO_TIMEOUT;
debug_mode = TRUE;
cnt = 0;
}
}
else if(any_button_pressed(in) && cnt < 3)
cnt = 0;
}

/*
Expand All @@ -142,4 +148,19 @@ void intro_render()
image_clear(color_hex("ff8800"));
image_draw_rotated(box, VIDEO_SCREEN_W / 2, VIDEO_SCREEN_H / 2, image_width(box)/2, image_height(box)/2, angle, IF_NONE);
font_render(fnt, camera);
}



/* private stuff */

/* checks if any button has been pressed */
bool any_button_pressed(input_t* in)
{
for(int i = 0; i < (int)IB_MAX; i++) {
if(input_button_pressed(in, (inputbutton_t)i))
return true;
}

return false;
}
2 changes: 2 additions & 0 deletions src/scenes/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -897,13 +897,15 @@ static void group_stageselect_update(group_t *g)
stageselect_enable_debug = true;
cnt = -1;
}
cnt2 = min(cnt2, 0);
}
else if(input_button_pressed(input, IB_LEFT)) { /* stage select: quest select trick */
if(cnt2 >= 0 && ++cnt2 == 3) {
sound_play(SFX_SECRET);
scn = SCENE_QUESTSELECT;
cnt2 = -1;
}
cnt = min(cnt, 0);
}
else if(input_button_pressed(input, IB_UP) || input_button_pressed(input, IB_DOWN)) {
cnt = min(cnt, 0);
Expand Down

0 comments on commit c7fbb45

Please sign in to comment.