From d976c2a3e37f90aa6b34d6edaecd9b99de70260a Mon Sep 17 00:00:00 2001 From: Curtis McEnroe Date: Fri, 22 Mar 2019 15:53:22 -0400 Subject: Add F2 and b temporary key --- sol.c | 19 ++++++++++++++++--- 1 file 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) { -- cgit 1.4.1