43 #if (defined __WIN32__) && (!defined __CYGWIN__)
45 #define FIXED_WIDTH 80
46 #define FIXED_HEIGHT 25
49 #define FIXED_WIDTH 80
50 #define FIXED_HEIGHT 24
62 #define REFRESH_DELAY (20000 + ((9 - game.level) * 25000))
66 static char PLAYER_HEAD_CHAR =
'@';
67 static char PLAYER_CHAR =
'o';
68 static char FRUIT_CHAR =
'$';
69 static char BORDER_CHAR =
'#';
70 static char NO_BORDER_CHAR =
'.';
71 static char MENU_BORDER_CHAR =
'*';
76 enum Colors { BLACK_WHITE = 1, CYAN_BLACK, BLUE_BLACK,
77 WHITE_BLACK, GREEN_BLACK, RED_BLACK, };
105 mvaddch (1, i, BORDER_CHAR);
110 mvaddch (i, 0, BORDER_CHAR);
118 mvaddch (1, i, NO_BORDER_CHAR);
123 mvaddch (i, 0, NO_BORDER_CHAR);
166 mvprintw (0, 0,
"nSnake v");
167 mvprintw (0, 9, VERSION);
212 if (has_colors () ==
TRUE)
219 if (use_default_colors () == ERR)
220 bg_color = COLOR_BLACK;
225 init_pair (GREEN_BLACK, COLOR_GREEN, bg_color);
226 init_pair (CYAN_BLACK, COLOR_CYAN, bg_color);
227 init_pair (WHITE_BLACK, COLOR_WHITE, bg_color);
228 init_pair (RED_BLACK, COLOR_RED, bg_color);
229 init_pair (BLUE_BLACK, COLOR_BLUE, bg_color);
230 init_pair (BLACK_WHITE, COLOR_BLACK, bg_color);
233 int current_height, current_width;
235 getmaxyx (stdscr, current_height, current_width);
238 nsnake_abort (
"Your console screen is smaller than 80x24\n"
239 "Please resize your window and try again\n\n");
244 nodelay (stdscr,
TRUE);
245 keypad (stdscr,
TRUE);
260 int game_over_logo_height = 16;
261 char* game_over_logo[] =
263 " _______ _______ __ __ _______ ",
264 "| || _ || |_| || |",
265 "| ___|| |_| || || ___|",
266 "| | __ | || || |___ ",
267 "| || || || || ___|",
268 "| |_| || _ || ||_|| || |___ ",
269 "|_______||__| |__||_| |_||_______|",
270 " _______ __ __ _______ ______ ",
271 "| || | | || || _ | ",
272 "| _ || |_| || ___|| | || ",
273 "| | | || || |___ | |_|| ",
274 "| |_| || || ___|| __ |",
275 "| | | | | |___ | | ||",
276 "|_______| |___| |_______||___| ||",
277 #if (defined __WIN32__) && (!defined __CYGWIN__)
278 " Press <space> to retry",
280 " Press <enter> to retry",
288 for (i = 0; i < game_over_logo_height; i++)
289 mvaddstr (3 + i, 22, game_over_logo[i]);
293 nodelay (stdscr,
FALSE);
296 void engine_clean_game_over ()
298 nodelay (stdscr,
TRUE);
308 int speed_cur_option = 1;
309 char speed_cur_options[9] = {
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9'};
311 int menu_row_pos = 13;
312 int option_row_pos = menu_row_pos + 17;
326 mvaddch (0, i, MENU_BORDER_CHAR);
331 mvaddch (i, 0, MENU_BORDER_CHAR);
336 mvprintw(1, 3,
" ,d8888b. 888");
337 mvprintw(2, 3,
" d88P Y88b 888");
338 mvprintw(3, 3,
" Y88b. 888");
339 mvprintw(4, 3,
"88888b. Y888b. 88888b. 8888b. 888 888 .d88b.");
340 mvprintw(5, 3,
"888 88b 8Y88b. 888 88b 88b 888 .88P d8P Y8b");
341 mvprintw(6, 3,
"888 888 888b 888 888 .d888888 888888K 88888888");
342 mvprintw(7, 3,
"888 888 Y88b d88P 888 888 888 888 888 88b Y8b.");
343 mvprintw(8, 3,
"888 888 Y8888P 888 888 Y888888 888 888 Y88888");
346 mvaddch (8, 59,
'v');
347 mvprintw (8, 60, VERSION);
350 mvprintw (10, 5,
" ___________________________________________________ ");
351 mvprintw (11, 5,
"| |");
352 mvprintw (12, 5,
"| |");
353 mvprintw (13, 5,
"| |");
354 mvprintw (14, 5,
"| |");
355 mvprintw (15, 5,
"| |");
356 mvprintw (16, 5,
"| |");
357 mvprintw (17, 5,
"| |");
358 mvprintw (18, 5,
"| |");
359 mvprintw (19, 5,
"|___________________________________________________|");
360 #if (defined __WIN32__) && (!defined __CYGWIN__)
361 mvprintw (12, menu_row_pos,
"Press <space> to start game");
363 mvprintw (12, menu_row_pos,
"Press <enter> or <space> to start game");
365 mvprintw (13, menu_row_pos,
"Press <q> to quit game");
368 mvprintw (15, menu_row_pos,
"Game Mode:");
372 mvprintw (15, option_row_pos,
"Borders On");
375 mvprintw (16, option_row_pos,
"Borders Off");
380 mvprintw (15, option_row_pos,
"Borders On");
383 mvprintw (16, option_row_pos,
"Borders Off");
388 mvprintw (18, menu_row_pos,
"Starting speed:");
391 for (i = 0, j = 0; i < 9; i++)
393 if (i == (speed_cur_option-1))
398 mvprintw (18, option_row_pos+j,
"%c", speed_cur_options [i]);
403 mvprintw (
screen.
height-2, 2,
"Use --help for guidelines");
421 nodelay (stdscr,
FALSE);
459 nodelay (stdscr,
FALSE);
475 #if (defined __WIN32__) && (!defined __CYGWIN__)
487 nodelay (stdscr,
TRUE);
495 nodelay (stdscr,
FALSE);
501 nodelay (stdscr,
TRUE);
510 case KEY_UP:
case 'k':
515 case KEY_DOWN:
case 'j':
520 case KEY_LEFT:
case 'h':
521 if (*speed_cur_option > 1)
522 (*speed_cur_option)--;
525 case KEY_RIGHT:
case 'l':
526 if (*speed_cur_option < 9)
527 (*speed_cur_option)++;
530 case '1':
case '2':
case '3':
case '4':
case '5':
531 case '6':
case '7':
case '8':
case '9':
532 *speed_cur_option = (input -
'0');
547 nodelay (stdscr,
TRUE);
557 if (has_colors () ==
TRUE)