-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDraw.h
70 lines (65 loc) · 1.74 KB
/
Draw.h
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
#pragma once
void drawCarSquare(const uint x, const uint y, const char letter)
{
const uint sx = gridToScreen(x);
const uint sy = gridToScreen(y);
for(uint i = 0; i < NUMCAR; i++){
if(letter == carArr[i].letter){
setColor(carArr[i].color);
break;
}
}
fillSquare(x*SCALE+10, y*SCALE+10, SCALE-20);
if(x < GRIDLEN-1 && grid[x+1][y] == grid[x][y])
fillSquare(sx+HSCALE+15, sy+15, SCALE-30);
if(y < GRIDLEN-1 && grid[x][y+1] == grid[x][y])
fillSquare(sx+15, sy+HSCALE+15, SCALE-30);
}
void drawGrid(void)
{
setColor(GREY2);
fillScreen();
setColor(GREY1);
for(uint x = 0; x < GRIDLEN; x++){
for(uint y = 0; y < GRIDLEN; y++){
fillSquare(x*SCALE+10, y*SCALE+10, SCALE-20);
}
}
setFontSize(HSCALE);
for(uint i = 0; i < GRIDLEN; i++){
drawText(i*SCALE+QSCALE-3, 2*SCALE+22, "-");
drawText(i*SCALE+QSCALE+7, 2*SCALE+22, "-");
drawText(i*SCALE+QSCALE+17, 2*SCALE+22, "-");
drawText(i*SCALE+HSCALE-10, 2*SCALE+QSCALE, ">");
}
}
void drawCarSquareOutline(const uint x, const uint y, const bool selected)
{
const uint sx = gridToScreen(x);
const uint sy = gridToScreen(y);
setColor(selected ? WHITE : BLACK);
fillSquare(x*SCALE+5, y*SCALE+5, SCALE-10);
if(x < GRIDLEN-1 && grid[x+1][y] == grid[x][y])
fillSquare(sx+HSCALE+10, sy+10, SCALE-20);
if(y < GRIDLEN-1 && grid[x][y+1] == grid[x][y])
fillSquare(sx+10, sy+HSCALE+10, SCALE-20);
}
void drawCarOutline(const char letter, const bool selected)
{
for(uint x = 0; x < GRIDLEN; x++){
for(uint y = 0; y < GRIDLEN; y++){
if(grid[x][y] == letter)
drawCarSquareOutline(x, y, selected);
}
}
}
void drawCars(void)
{
for(uint x = 0; x < GRIDLEN; x++){
for(uint y = 0; y < GRIDLEN; y++){
if(grid[x][y] != '-'){
drawCarSquare(x, y, grid[x][y]);
}
}
}
}