Пример #1
0
void show_instruction(int8_t status){
	move_cursor(1, INSTRUCTY + 1);
	clear_to_end_of_line();
	move_cursor(1, INSTRUCTY);
	clear_to_end_of_line();
	
	switch(status){
		case NEWGAME:	
			printf_P(PSTR("Welcome! Press 'space' to start a new game.\nPress 'L' to to load a saved game."));
			//printf_P(PSTR("Press 'L' to to load a saved game."));
			break;
		case GAMEOVER:
			printf_P(PSTR("Game Over! Press 'space' to start a new game.\nPress 'L' to to load a saved game."));
			//printf_P(PSTR("Press 'L' to to load a saved game."));
			break;
		case PAUSE:
			printf_P(PSTR("Paused... Press 'P' to continue.\nPress 'S' to save game state."));
			//printf_P(PSTR("Press 'S' to save game state."));
			break;
		case PLAYING:
			move_cursor(1, TITLEY);
			clear_to_end_of_line();
			move_cursor(1, INSTRUCTY);
			printf_P(PSTR("Have fun! Press 'N' to start a new game.\nPress 'P' to to pause the game."));
			//printf_P(PSTR("Press 'P' to to pause the game."));
			break;
	}			
}
Пример #2
0
void draw_message(const char * msg){
	move_cursor(MSG_X,MSG_Y);
	clear_to_end_of_line();
	printf_P(msg);
	
	move_cursor(WIDTH,HEIGHT);
}
Пример #3
0
void pause_game() {
	/*
	** status = 0, game is running
	** status = 1, game is paused
	*/
	static uint8_t status = 0;
	char c = 0;

	if(status) {
		move_cursor(28, TITLEY);
		clear_to_end_of_line();
		show_instruction(PLAYING);
		render_board();
		foodTimerNum = execute_function_periodically(BLINKRATE, blink_food);
		ratsTimerNum = execute_function_periodically(RATSPEED, move_rats);
		status = 0;
	}
	else {
		show_instruction(PAUSE);
		cancel_software_timer(foodTimerNum);
		cancel_software_timer(ratsTimerNum);
		empty_display();
		status = 1;

		while(c != 'p' && c != 'P'){
			if(input_available())
				c = fgetc(stdin);

			if(c == 's' || c == 'S'){
				save_state();
				//move_cursor(0, TITLEY);
				//clear_to_end_of_line();
				move_cursor(28, TITLEY);
				printf_P(PSTR("State has been saved."));
				c = 0;
			}

		}
		pause_game();

	}
}