-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_windows.c
114 lines (106 loc) · 1.73 KB
/
main_windows.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#include <stdio.h>
#include <windows.h>
#include <conio.h>
#include "helper_windows.h"
#include<unistd.h>
#define KRED "\x1B[31m"
int level;
int scan;
char b;
char s[10][10];
char type[10];
int flag=0;
int counter=0;
void gotoxy(int x,int y)
{
COORD c;
c.X=x;
c.Y=y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),c);
}
void clrscr()
{
system("@cls||clear");
}
int j=9;
int i=0;
void my_callback_on_key_arrival(char c)
{
// Just for test, remove this line
while(s[j][i]==c)
{
s[j][i]='*';
i++;
}
if(s[j][i]=='\0')
{
j--;
i=0;
counter ++;
}
// Do something with this c
}
int main()
{
// Menu stuff goes here
HANDLE thread_id = start_listening(my_callback_on_key_arrival);
// The rest of your main code goes here
printf("enter your level:1,2,3\n");
scanf("%d",&scan);
clrscr();
if(scan==1)
{
level=3;
}
if(scan==2)
{
level=2;
}
if(scan==3)
{
level=1;
}
FILE*kalamat=fopen("kalamat.txt","r");
for(int j=0;j<10;j++)
{fscanf(kalamat,"%s",s[j]);}
for(int i=0;i<120;i++)
{
gotoxy(i,29);
printf("#");
}
for(int i=0;i<20+counter;i++)
{ gotoxy(95,2);
printf("level=%d",scan);
gotoxy(15,2);
printf("score=%d",counter);
gotoxy(55,i);
for(int j=0;j<10;j++)
{ gotoxy(55,i+j);
printf("%s",s[j]);
}
sleep(level);
if(i<19+counter)
{
clrscr();
}
for(int i=0;i<120;i++)
{
gotoxy(i,29);
printf("#");
}
if(i>=19&&counter==i-19)
{
clrscr();
gotoxy(55,15);
printf("GAME OVER");
}
if(counter==10)
{ clrscr();
gotoxy(55,15);
printf("victory!!!!!");
i=100;
}
}
WaitForSingleObject(thread_id, INFINITE);
return 0;
}