-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdraw_screen.c
62 lines (57 loc) · 1.42 KB
/
draw_screen.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
/*
@author: Abdul-Rasheed Audu
@course: COMP 3430 - Operating Systems
@title: draW_screen.c
@purpose: Screen refresh thread.
*/
#include <unistd.h>
#include <stdbool.h>
#include <stdio.h>
#include <pthread.h>
#include "console.h"
#include "draw_screen.h"
static char *GAME_BOARD[] = {
" Lives:",
"/------\\ /------\\ /------\\ /------\\ /------\\",
"| | | | | | | | | |",
"+ +----------+ +----------+ +----------+ +----------+ +",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"",
"",
"",
"" };
extern pthread_mutex_t draw_mutex;
extern pthread_cond_t wait_for_console;
extern bool is_game_over;
void *draw_screen_run() {
pthread_mutex_lock(&draw_mutex);
if (consoleInit(GAME_ROWS, GAME_COLS, GAME_BOARD)) {
pthread_mutex_unlock(&draw_mutex);
// int i;
while (! is_game_over ) {
pthread_mutex_lock(&draw_mutex);
consoleRefresh();
pthread_mutex_unlock(&draw_mutex);
sleepTicks(1);
}
putBanner("Game is over. Press any key to exit!");
finalKeypress();
consoleFinish();
}
pthread_exit(NULL);;
}