diff options
author | June McEnroe <june@causal.agency> | 2019-03-22 15:53:22 -0400 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2019-03-22 15:53:22 -0400 |
commit | d976c2a3e37f90aa6b34d6edaecd9b99de70260a (patch) | |
tree | 59b387cfa6535ff867956459ea414feae415c5ff | |
parent | Implement the game (diff) | |
download | cards-d976c2a3e37f90aa6b34d6edaecd9b99de70260a.tar.gz cards-d976c2a3e37f90aa6b34d6edaecd9b99de70260a.zip |
Add F2 and b temporary key
-rw-r--r-- | sol.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/sol.c b/sol.c index ed5981d..cde7b2b 100644 --- a/sol.c +++ b/sol.c @@ -307,6 +307,20 @@ static void layoutTableau(void) { } } +static bool keyDown(SDL_KeyboardEvent key) { + switch (key.keysym.sym) { + case SDLK_F2: gameDeal(); return true; + case SDLK_b: { + layout.backTexture -= Cards_Back1; + layout.backTexture += 1; + layout.backTexture %= 12; + layout.backTexture += Cards_Back1; + return true; + } + default: return false; + } +} + static bool mouseButtonDown(SDL_MouseButtonEvent button) { struct SDL_Point point = { button.x, button.y }; if (SDL_PointInRect(&point, &layout.stacks[Stock])) { @@ -408,9 +422,6 @@ int main(void) { gameDeal(); - // FIXME: Use a portable random. - layout.backTexture = Cards_Back1 + arc4random_uniform(12); - for (;;) { layoutClear(); layoutStock(); @@ -430,6 +441,8 @@ int main(void) { SDL_WaitEvent(&event); if (event.type == SDL_QUIT) { goto quit; + } else if (event.type == SDL_KEYDOWN) { + if (keyDown(event.key)) break; } else if (event.type == SDL_MOUSEBUTTONDOWN) { if (mouseButtonDown(event.button)) break; } else if (event.type == SDL_MOUSEBUTTONUP) { |