summaryrefslogtreecommitdiff
path: root/src/game.c
diff options
context:
space:
mode:
authorReiner Herrmann <reiner@reiner-h.de>2011-01-04 22:36:06 +0100
committerReiner Herrmann <reiner@reiner-h.de>2011-01-04 22:36:06 +0100
commit84b90fce2dbe99ad738e53ad6416000765e18c00 (patch)
tree55186dd40d9331e552598b9fb0f124efed9d97c1 /src/game.c
parent3cbdd2f4e4c5e3bb93d9ff43e1aec47b5b5aafd4 (diff)
added game loop entry with mainstack; shuffle it at beginning
Diffstat (limited to 'src/game.c')
-rw-r--r--src/game.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/game.c b/src/game.c
new file mode 100644
index 0000000..a7e33be
--- /dev/null
+++ b/src/game.c
@@ -0,0 +1,40 @@
+#include "game.h"
+#include "card.h"
+#include <stdlib.h>
+#include <stdbool.h>
+#include <time.h>
+
+void init_mainstack(card* stack, const uint32_t size)
+{
+ // assign card values to main stack
+ for(uint32_t i=0, val=MIN_CARD; i<size; i++, val++)
+ stack[i] = val;
+
+ // shuffle stack
+ for(uint32_t i=0; i<3*size; i++)
+ {
+ uint32_t x = rand() % size;
+ uint32_t y = rand() % size;
+ card tmp = stack[x];
+ stack[x] = stack[y];
+ stack[y] = tmp;
+ }
+}
+
+void start_game(void)
+{
+ bool running = true;
+ int cards = MAX_CARD - MIN_CARD + 1;
+ card mainstack[cards];
+
+ srand(time(0));
+
+ init_mainstack(mainstack, cards);
+
+ // main game loop
+ while(running)
+ {
+
+ }
+}
+