]> git.gir.st - VIper.git/blob - viiper.h
fix fast 180° turns (queue all directional keystrokes)
[VIper.git] / viiper.h
1 #ifndef __VIIPER_H__
2 #define __VIIPER_H__
3
4 #define SHORTHELP "%s [OPTIONS] [FIELDSIZE]\n"
5 #define LONGHELP \
6 "OPTIONS:\n" \
7 " -h(elp)\n" \
8 "FIELDSIZE:\n" \
9 " WxH (width 'x' height)\n" \
10 " defaults to 30x20\n" \
11 "\n" \
12 "Keybindings:\n" \
13 " hjkl: move left/down/up/right\n" \
14 " p: pause / unpause\n" \
15 " r: start a new game\n" \
16 " q: quit\n"
17
18 struct snake {
19 int r; /* row */
20 int c; /* column */
21 struct snake* next; /* points to tail */
22 };
23 struct item {
24 int r; /* row */
25 int c; /* column */
26 int t; /* type */
27 int v; /* value */ //TODO: make type only differentiate between food/bonus/etc, and use value (so we can randomly select one of each)
28 int s; /* spawn time (for bonus) */
29 struct item* prev;
30 struct item* next;
31 };
32 struct directions {
33 int d; /* direction */
34 struct directions* next;
35 };
36 enum direction {
37 NONE,
38 NORTH,
39 EAST,
40 SOUTH,
41 WEST,
42 };
43 enum item_type {
44 NO_ITEM,
45 FOOD,
46 BONUS,
47 };
48 enum food_value {
49 FOOD_5,
50 FOOD_10,
51 FOOD_20,
52 NUM_FOODS,
53 };
54 enum bonus_value {
55 NUM_BONI,
56 };
57
58 int viiper(void);
59 void snake_advance (void);
60 void spawn_item (int type, int value);
61 void consume_item (struct item* i);
62 void show_playfield (void);
63 void snake_append (struct snake* s, int row, int col);
64 void init_snake();
65 void quit (void);
66 int getctrlseq (void);
67 void append_movement (int d);
68 int get_movement (void);
69 void move_ph (int line, int col);
70 void clamp_fieldsize (void);
71 void timer_setup (int enable);
72 void signal_setup (void);
73 void signal_handler (int signum);
74 void screen_setup (int enable);
75 void raw_mode(int enable);
76 enum event {
77 /* for getctrlseq() */
78 CTRSEQ_NULL = 0,
79 CTRSEQ_EOF = -1,
80 CTRSEQ_INVALID = -2,
81 CTRSEQ_MOUSE = -3,
82 CTRSEQ_CURSOR_LEFT = -7,
83 CTRSEQ_CURSOR_DOWN = -8,
84 CTRSEQ_CURSOR_UP = -9,
85 CTRSEQ_CURSOR_RIGHT = -10,
86 };
87
88 #endif
Imprint / Impressum