|
| 1 | +#include "draw.h" |
| 2 | + |
| 3 | +void printTime(double seconds){ |
| 4 | + printf("%.2d:%.2d:%.2d",((int)(seconds)%3600)/60, (int)seconds%60, ((int)(seconds*100))%100); |
| 5 | +} |
| 6 | + |
| 7 | +void drawBall(vector pos, vector prev_pos){ |
| 8 | + |
| 9 | + if(pos.x != prev_pos.x || pos.y != prev_pos.y){ |
| 10 | + gotoxy(prev_pos.x, prev_pos.y); |
| 11 | + printf(" "); |
| 12 | + } |
| 13 | + gotoxy(pos.x, pos.y); |
| 14 | + printf("o"); |
| 15 | +} |
| 16 | + |
| 17 | +void drawBat(vector position, vector prev_position, int Color){ |
| 18 | + setColor(WHITE); |
| 19 | + if(prev_position.x != position.x || prev_position.y != position.y){ |
| 20 | + for(int i = -PLAYER_SIZE/2; i<=PLAYER_SIZE/2; i++){ |
| 21 | + gotoxy(prev_position.x,prev_position.y+i); |
| 22 | + printf(" "); |
| 23 | + } |
| 24 | + } |
| 25 | + setColor(Color); |
| 26 | + for(int i = -PLAYER_SIZE/2; i<=PLAYER_SIZE/2; i++){ |
| 27 | + gotoxy(position.x,position.y+i); |
| 28 | + printf("%c", 178); |
| 29 | + } |
| 30 | + setColor(WHITE); |
| 31 | +} |
| 32 | + |
| 33 | +void printScore(){ |
| 34 | + gotoxy(2,1); |
| 35 | + printf("%s score: %d", Player_1, score_1); |
| 36 | + gotoxy(WIDTH-21,1); |
| 37 | + printf("%s score: %d", Player_2, score_2); |
| 38 | +} |
| 39 | + |
| 40 | +void clearGameArea() |
| 41 | +{ |
| 42 | + gotoxy(1,3); |
| 43 | + for(int j = 3; j<HEIGHT; j++){ |
| 44 | + for(int i = 2; i<WIDTH; i++) |
| 45 | + printf(" "); |
| 46 | + gotoxy(1,j); |
| 47 | + } |
| 48 | +} |
| 49 | + |
| 50 | +void drawBorders(){ |
| 51 | + gotoxy(0,0); |
| 52 | + for(int i=0;i<WIDTH; i++){printf("%c", 178);} |
| 53 | + for(int i=1;i<HEIGHT; i++){gotoxy(0,i);printf("%c", 178);} |
| 54 | + for(int i=1;i<HEIGHT; i++){gotoxy(WIDTH-1,i);printf("%c", 178);} |
| 55 | + gotoxy(0, HEIGHT-1); |
| 56 | + for(int i=1;i<WIDTH; i++){printf("%c", 178);} |
| 57 | +} |
| 58 | + |
| 59 | +void drawLayout(){ |
| 60 | + gotoxy(0,0); |
| 61 | + for(int i=0;i<WIDTH; i++){printf("%c", 178);} |
| 62 | + for(int i=1;i<HEIGHT; i++){gotoxy(0,i);if(abs(((HEIGHT-1)/2)-i)>(GOAL_SIZE)/2)printf("%c", 178);} |
| 63 | + for(int i=1;i<HEIGHT; i++){gotoxy(WIDTH-1,i);if(abs(((HEIGHT-1)/2)-i)>(GOAL_SIZE)/2)printf("%c", 178);} |
| 64 | + gotoxy(0, HEIGHT-1); |
| 65 | + for(int i=1;i<WIDTH; i++){printf("%c", 178);} |
| 66 | + gotoxy(1,2); |
| 67 | + for(int i=0;i<WIDTH-2; i++){printf("%c", 178);} |
| 68 | + for(int i=3;i<HEIGHT-1; i++){gotoxy(WIDTH/2,i);if(i%2)printf("%c", 179);} |
| 69 | +} |
| 70 | + |
0 commit comments