-
Notifications
You must be signed in to change notification settings - Fork 0
/
screen_printing.c
76 lines (67 loc) · 1.85 KB
/
screen_printing.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include "hardware_communication.h"
#include "screen_data.h"
#include "screen_printing.h"
#include "text_print.h"
void print_statusbar(board_values ** scaled_board){
for(int i = 0; 10 + text_height() > i * scale; i++){
for(int j = 0; j < scaleX; j++){
scaled_board[i][j] = STATUS_BAR;
}
}
}
void update_lcd_board_from_scaled_board(board_values **scaled_board, board_values **lcd_board){
for(int i = 0; i < SCREEN_Y; i++){
for(int j = 0; j < SCREEN_X; j++){
int boardI = i/scale;
int boardJ = j/scale;
lcd_board[i][j] = scaled_board[boardI][boardJ];
}
}
}
void update_menu_view(int item_num, board_values ** board){
//print background
for(int i = 0; i < scaleY; i++){
for(int j = 0; j < scaleX; j++){
board[i][j] = MENU;
}
}
//print selection
for(int i = 4 * item_num; i < 4 * item_num + 4; i++){
for(int j = 7; j < scaleX - 7; j++){
board[i][j] = SELECTED_MENU_ITEM;
}
}
}
void print_screen(board_values **lcd_board){
for(int i = 0; i < SCREEN_Y; i++){
for(int j = 0; j < SCREEN_X; j++){
switch(lcd_board[i][j]){
case SNAKE1:
draw_pixel(j,i,SNAKE_1_COLOR);
break;
case SNAKE2:
draw_pixel(j,i,SNAKE_2_COLOR);
break;
case APPLE:
draw_pixel(j,i,APPLE_COLOR);
break;
case EMPTY_PIXEL:
draw_pixel(j,i,EMPTY_PIXEL_COLOR);
break;
case TEXT:
draw_pixel(j,i,TEXT_COLOR);
break;
case STATUS_BAR:
draw_pixel(j,i,STATUS_BAR_COLOR);
break;
case MENU:
draw_pixel(j,i,MENU_COLOR);
break;
case SELECTED_MENU_ITEM:
draw_pixel(j,i,SELECTED_MENU_ITEM_COLOR);
break;
}
}
}
update_screen();
}