0

Hey guys,
For the snake game, I need to use different colours for the snake and food. At least two different colours must be used (other than white and black). How can I change the colours? I tried many ways but none did it properly :sad: !
This is the full code where I think it should go somewhere in here:

static int map_board_x_to_screen_x(int board_x) {
	return BOARD_X_OFFSET + board_x;
}

static int map_board_y_to_screen_y(int board_y) {
	return BOARD_Y_OFFSET + board_y;
}

void init_screen() {
	/* 
	** Initialise the screen, by setting it to normal display mode
	** and clear the screen.
	*/
	normal_display_mode();
	clear_terminal();	
	
	draw_horizontal_line(map_board_y_to_screen_y(-1),
            map_board_x_to_screen_x(-1),
            map_board_x_to_screen_x(BOARD_WIDTH));
    draw_horizontal_line(map_board_y_to_screen_y(BOARD_ROWS),
            map_board_x_to_screen_x(-1),
            map_board_x_to_screen_x(BOARD_WIDTH));
    draw_vertical_line(map_board_x_to_screen_x(-1),
            map_board_y_to_screen_y(-1),
            map_board_y_to_screen_y(BOARD_ROWS));
    draw_vertical_line(map_board_x_to_screen_x(BOARD_WIDTH),
            map_board_y_to_screen_y(-1),
            map_board_y_to_screen_y(BOARD_ROWS));
			
	move_cursor(SCORE_X_OFFSET, 5);
	printf_P(PSTR("SCORE"));
	output_score();

}

void output_score() {
	move_cursor(SCORE_X_OFFSET,6);
	printf_P(PSTR("%ld"), get_score());
}

void display_character_at(int8_t x, int8_t y, char c) {  
    move_cursor(map_board_x_to_screen_x(x), 
            map_board_y_to_screen_y(y));
    putchar(c);
}

void display_food_at(int8_t x, int8_t y) {
    display_character_at(x, y, '#');
}

void display_snake_at(int8_t x, int8_t y) {
    reverse_video();
    display_character_at(x, y, 'O');
	normal_display_mode();	
}


void display_blank_at(int8_t x, int8_t y) {
    display_character_at(x, y, ' ');
}

void game_over_message(void) {
	move_cursor(SCORE_X_OFFSET, 7);
	printf("Game over");
}

Help PLEASE :cry:

1
Contributor
1
Reply
2
Views
13 Years
Discussion Span
Last Post by Simplicity
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.