summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--sol.c19
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) {