]> git.gir.st - VIper.git/blob - viiper.h
green snek (dirty (temporary) hack)
[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 enum direction {
33 NONE,
34 NORTH,
35 EAST,
36 SOUTH,
37 WEST,
38 };
39 enum item_type {
40 NO_ITEM,
41 FOOD,
42 BONUS,
43 };
44 enum food_value {
45 FOOD_5,
46 FOOD_10,
47 FOOD_20,
48 NUM_FOODS,
49 };
50 enum bonus_value {
51 NUM_BONI,
52 };
53
54 int viiper(void);
55 void snake_advance (void);
56 void spawn_item (int type, int value);
57 void consume_item (struct item* i);
58 void show_playfield (void);
59 void snake_append (struct snake* s, int row, int col);
60 void init_snake();
61 void quit (void);
62 int getctrlseq (void);
63 void move_ph (int line, int col);
64 void clamp_fieldsize (void);
65 void timer_setup (int enable);
66 void signal_setup (void);
67 void signal_handler (int signum);
68 void screen_setup (int enable);
69 void raw_mode(int enable);
70 enum event {
71 /* for getctrlseq() */
72 CTRSEQ_NULL = 0,
73 CTRSEQ_EOF = -1,
74 CTRSEQ_INVALID = -2,
75 CTRSEQ_MOUSE = -3,
76 CTRSEQ_CURSOR_LEFT = -7,
77 CTRSEQ_CURSOR_DOWN = -8,
78 CTRSEQ_CURSOR_UP = -9,
79 CTRSEQ_CURSOR_RIGHT = -10,
80 };
81
82 #endif
Imprint / Impressum