summaryrefslogtreecommitdiff
path: root/src/hungrycat.c
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2023-10-14 00:25:32 -0700
committerVito Caputo <vcaputo@pengaru.com>2023-10-14 00:25:32 -0700
commit3e6bcb386cc9df28990b9cd570f6df7617e91f91 (patch)
tree0f5c01f4a98727b0adb9b733c8ff631117e473df /src/hungrycat.c
parent723dc1a9bd275bb314a5e2d2673ed0ea84fee330 (diff)
sars,hungrycat: add --wait flag
This tells sars to just wait indefinitely until an ESC is pressed pre-fadein during the opening hungrycat context. The --delay [seconds] flag was added to facilitate screen captures, but it's actually rather annoying to use. This way the sars window will just sit there ignoring any spurious events waiting for an ESC to proceed onto DELAY->FADEIN... Probably not useful but technically this composes with --delay as well, such that if you have --delay and --wait specified, once you hit ESC to leave the WAIT state, the delay will then begin.
Diffstat (limited to 'src/hungrycat.c')
-rw-r--r--src/hungrycat.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/hungrycat.c b/src/hungrycat.c
index d31b8e3..41474ef 100644
--- a/src/hungrycat.c
+++ b/src/hungrycat.c
@@ -36,6 +36,7 @@
#define HUNGRYCAT_FADE_TIMER PLAY_TICKS_TIMER0
typedef enum hungrycat_state_t {
+ HUNGRYCAT_STATE_WAIT,
HUNGRYCAT_STATE_DELAY,
HUNGRYCAT_STATE_FADEIN,
HUNGRYCAT_STATE_SHOW,
@@ -71,9 +72,13 @@ static void * hungrycat_init(play_t *play, int argc, char *argv[], unsigned flag
static void hungrycat_enter(play_t *play, void *context)
{
hungrycat_t *hungrycat = context;
+ sars_t *sars = play_context(play, SARS_CONTEXT_SARS);
assert(hungrycat);
+ if (!sars->wait)
+ hungrycat->state = HUNGRYCAT_STATE_DELAY;
+
play_ticks_reset(play, HUNGRYCAT_FADE_TIMER);
}
@@ -92,6 +97,11 @@ static void hungrycat_update(play_t *play, void *context)
assert(hungrycat);
switch (hungrycat->state) {
+ case HUNGRYCAT_STATE_WAIT:
+ /* just wait indefinitely until an ESC is pressed (see hungrycat_dispatch()) */
+ stage_dirty(hungrycat->node);
+ break;
+
case HUNGRYCAT_STATE_DELAY:
stage_dirty(hungrycat->node);
if (!play_ticks_elapsed(play, HUNGRYCAT_FADE_TIMER, sars->delay_seconds * 1000))
@@ -168,11 +178,16 @@ static void hungrycat_dispatch(play_t *play, void *context, SDL_Event *event)
switch (event->type) {
case SDL_KEYDOWN:
- if (event->key.keysym.sym == SDLK_ESCAPE)
- exit(0);
+ if (event->key.keysym.sym == SDLK_ESCAPE) {
+ if (hungrycat->state != HUNGRYCAT_STATE_WAIT)
+ exit(0);
+
+ hungrycat->state = HUNGRYCAT_STATE_DELAY;
+ }
/* fallthrough */
case SDL_FINGERDOWN:
- if (hungrycat->state != HUNGRYCAT_STATE_DELAY)
+ if (hungrycat->state != HUNGRYCAT_STATE_WAIT &&
+ hungrycat->state != HUNGRYCAT_STATE_DELAY)
play_context_enter(play, SARS_CONTEXT_GAME);
break;
© All Rights Reserved