]> git.gir.st - VIper.git/blob - viiper.h
remove vt220 support, II
[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 " -s(peed) N\n" \
8 " -l(ength) N\n" \
9 " -h(elp)\n" \
10 "FIELDSIZE:\n" \
11 " WxH (width 'x' height)\n" \
12 " defaults to 30x20\n" \
13 "\n" \
14 "Keybindings:\n" \
15 " hjkl: move left/down/up/right\n" \
16 " p: pause / unpause\n" \
17 " r: start a new game\n" \
18 " q: quit\n"
19
20 struct snake {
21 int r; /* row */
22 int c; /* column */
23 struct snake* next; /* points to tail */
24 };
25 struct item {
26 int r; /* row */
27 int c; /* column */
28 int t; /* type */
29 int v; /* value */
30 int s; /* spawn time (for bonus) */
31 struct item* prev;
32 struct item* next;
33 };
34 enum direction {
35 NONE,
36 NORTH,
37 EAST,
38 SOUTH,
39 WEST,
40 };
41 enum item_type {
42 NO_ITEM,
43 FOOD,
44 BONUS,
45 };
46 enum food_value {
47 FOOD_5,
48 FOOD_10,
49 FOOD_20,
50 NUM_FOODS,
51 };
52 enum bonus_value {
53 BONUS_SNIP,
54 BONUS_GROW,
55 BONUS_SLOW,
56 BONUS_FAST,
57 BONUS_WRAP,
58 NUM_BONI,
59 };
60 enum game_state {
61 GAME_INIT,
62 GAME_START,
63 GAME_OVER,
64 GAME_WON,
65 GAME_EXIT,
66 };
67
68 int viiper(void);
69 void snake_advance (void);
70 void spawn_item (int type, int value, struct item* p_item);
71 void consume_item (struct item* i);
72 void show_playfield (void);
73 void draw_sprites (int erase_r, int erase_c);
74 void pause_game (void);
75 int end_screen(char* message);
76 void snake_append (struct snake** s, int row, int col);
77 void remove_bonus (struct item* i);
78 void init_snake();
79 void quit (void);
80 int getctrlseq (void);
81 void append_movement (int d);
82 void move_ph (int line, int col);
83 void clamp_fieldsize (void);
84 void timer_setup (int enable);
85 void signal_setup (void);
86 void signal_handler (int signum);
87 void screen_setup (int enable);
88 void raw_mode(int enable);
89 enum event {
90 /* for getctrlseq() */
91 CTRSEQ_NULL = 0,
92 CTRSEQ_EOF = -1,
93 CTRSEQ_INVALID = -2,
94 CTRSEQ_MOUSE = -3,
95 CTRSEQ_CURSOR_LEFT = -7,
96 CTRSEQ_CURSOR_DOWN = -8,
97 CTRSEQ_CURSOR_UP = -9,
98 CTRSEQ_CURSOR_RIGHT = -10,
99 };
100
101 #endif
Imprint / Impressum