aboutsummaryrefslogtreecommitdiff
path: root/pregame.c
diff options
context:
space:
mode:
authorNathan Vance <nathav63@gmail.com>2015-07-27 19:15:59 -0400
committerNathan Vance <nathav63@gmail.com>2015-07-27 19:15:59 -0400
commit06818a49b337ef5d3277ebf6ed0b3f13a88239d3 (patch)
tree500f311c25ac68fc9a3b8429bf0747572e4d3e69 /pregame.c
parentfixed bugs and formatting errors (diff)
download7w-06818a49b337ef5d3277ebf6ed0b3f13a88239d3.tar.gz
7w-06818a49b337ef5d3277ebf6ed0b3f13a88239d3.tar.bz2
7w-06818a49b337ef5d3277ebf6ed0b3f13a88239d3.zip
Updated to work with gcc 5.X
Diffstat (limited to 'pregame.c')
-rw-r--r--pregame.c120
1 files changed, 60 insertions, 60 deletions
diff --git a/pregame.c b/pregame.c
index 4412e68..c3f145b 100644
--- a/pregame.c
+++ b/pregame.c
@@ -1,66 +1,66 @@
#include "7w.h"
#include <stdio.h>
-int io_getkey();
-void io_clearscreen();
-void io_printborder(int x, int y, int width);
-int io_printtext(int xorigin, int y, int width, char* text);
-
-void pregame_refresh(int* data, int cursor)
-{
- io_clearscreen();
- int y = 0;
- int width = 28;
- io_printborder(0, y++, width);
- char s[40];
- sprintf(s, "Number of players: %d %c", data[7], (cursor == 0)? '*' : ' ');
- y = io_printtext(0, y, width, s);
- int i;
- for(i = 0; i < data[7]; i++) {
- sprintf(s, "Player %d is: %s %c", i+1, (data[i] == 1)? "ai " : "human", (cursor == i+1)? '*' : ' ');
- y = io_printtext(0, y, width, s);
- }
- sprintf(s, "Play %c", (cursor == data[7]+1)? '*' : ' ');
- y = io_printtext(0, y, width, s);
- io_printborder(0, y++, width);
+void pregame_refresh(int* data, int cursor) {
+ io_clearscreen();
+ int y = 0;
+ int width = 28;
+ io_printborder(0, y++, width);
+ char s[40];
+ sprintf(s, "Number of players: %d %c", data[7], (cursor == 0) ? '*' : ' ');
+ y = io_printtext(0, y, width, s);
+ int i;
+ for (i = 0; i < data[7]; i++) {
+ sprintf(s, "Player %d is: %s %c", i + 1,
+ (data[i] == 1) ? "ai " : "human",
+ (cursor == i + 1) ? '*' : ' ');
+ y = io_printtext(0, y, width, s);
+ }
+ sprintf(s, "Play %c", (cursor == data[7] + 1) ? '*' : ' ');
+ y = io_printtext(0, y, width, s);
+ io_printborder(0, y++, width);
}
-int* pregame()
-{
- static int ret[8] = {0, 1, 1, 1, 1, 1, 1, 1};
- ret[7] = 3;
- int cursor = 0;
- int pregaming = 1;
- while(pregaming) {
- pregame_refresh(ret, cursor);
- switch(io_getkey()) {
- case UP: cursor--;
- if(cursor < 0) cursor = ret[7]+1;
- break;
- case DOWN: cursor = (cursor+1)%(ret[7]+2);
- break;
- case RIGHT:
- case ENTER:
- if(cursor == 0) {
- ret[7]++;
- if(ret[7] > 7) ret[7] = 3;
- } else if(cursor == ret[7]+1) {
- pregaming = 0;
- } else {
- ret[cursor-1] = !ret[cursor-1];
- }
- break;
- case LEFT:
- if(cursor == 0) {
- ret[7]--;
- if(ret[7] < 3) ret[7] = 7;
- } else if(cursor == ret[7]+1) {
- //do nothing
- } else {
- ret[cursor-1] = !ret[cursor-1];
- }
- break;
- }
- }
- return ret;
+int* pregame() {
+ static int ret[8] = { 0, 1, 1, 1, 1, 1, 1, 1 };
+ ret[7] = 3;
+ int cursor = 0;
+ int pregaming = 1;
+ while (pregaming) {
+ pregame_refresh(ret, cursor);
+ switch (io_getkey()) {
+ case UP:
+ cursor--;
+ if (cursor < 0)
+ cursor = ret[7] + 1;
+ break;
+ case DOWN:
+ cursor = (cursor + 1) % (ret[7] + 2);
+ break;
+ case RIGHT:
+ case ENTER:
+ if (cursor == 0) {
+ ret[7]++;
+ if (ret[7] > 7)
+ ret[7] = 3;
+ } else if (cursor == ret[7] + 1) {
+ pregaming = 0;
+ } else {
+ ret[cursor - 1] = !ret[cursor - 1];
+ }
+ break;
+ case LEFT:
+ if (cursor == 0) {
+ ret[7]--;
+ if (ret[7] < 3)
+ ret[7] = 7;
+ } else if (cursor == ret[7] + 1) {
+ //do nothing
+ } else {
+ ret[cursor - 1] = !ret[cursor - 1];
+ }
+ break;
+ }
+ }
+ return ret;
}
bgstack15