#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<windows.h>
#include<string.h>
#define UP 72
#define DOWN 80
#define LEFT 75
#define RIGHT 77
#define ATTACK 32
int enemyCount;
int enemyQueue[1000][2];
int rear=0, front=0;
int mapArr[100][100];
int Score;
char adv[100] = {0};
int adMin, adMax;
// queue<
void gotoxy(int x,int y)
{
COORD pos= {x,y};
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos);
}
void setColor(int color, int bgcolor)
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), ((bgcolor&0xf)<<4) | (color&0xf));
}
void map()
{
int i, j;
for(i=5; i<30; i++)
{
for(j=5; j<30; j++)
{
if(i==5||j==5||i==29||j==29)
{
gotoxy(i, j);
setColor(12, 15);
printf("&");
mapArr[i][j] = 8;
setColor(15, 0);
}
}
}
}
void scoreBoard()
{
printf("*");
gotoxy(15,3);
printf("fire");
gotoxy(14,2);
setColor(12,12);
printf("******");
gotoxy(14,3);
printf("*");
gotoxy(19,3);
printf("*");
gotoxy(14,4);
printf("******");
setColor(15,0);
gotoxy(40,5);
printf("Max Score");
gotoxy(40,6);
printf("");
gotoxy(39,4);
setColor(11,14);
printf("***********");
gotoxy(39,5);
printf("*");
gotoxy(49,5);
printf("*");
gotoxy(39,6);
printf("*");
gotoxy(49,6);
printf("*");
gotoxy(39,7);
printf("***********");
setColor(15,0);
gotoxy(40,9);
printf("Now Score");
gotoxy(40,10);
printf("%d",Score);
}
void systemMissile(int x, int y, int damage)
{
/*
while(1) {
gotoxy(x,y-1);
printf("|");
gotoxy(x,y);
printf(" ");
}
*/
}
void showBoard()
{
int i,j;
for(i=5; i<30; i++)
{
for(j=5; j<30; j++)
{
gotoxy(50+i,j);
printf("%d",mapArr[i][j]);
}
}
}
void mobRegen(int x, int y)
{
if(enemyCount > 15)
{
return ;
}
gotoxy(x,y);
enemyCount++;
printf("#");
mapArr[x][y]=1;
}
void advertise() {
char f = adv[0];
for(int i=1; i<strlen(adv); i++) {
adv[i-1] = adv[i];
}
adv[adMax-1] = f;
adv[adMax] = '\0';
printf("%s", adv);
Sleep(10);
}
int main()
{
int a,b;
char key;
int x=10, y=10;
int mX, mY;
int monster;
enemyCount = 0;
strcpy(adv, "HEE KWON FIGHTING ");
adMin = 0;
adMax = strlen(adv);
srand(time(NULL));
gotoxy(x, y);
map();
while(1)
{
gotoxy(8, 1);
//advertise(); // after edit code
scoreBoard();
if(enemyCount<15) {
mX = rand()%15+6;
mY = rand()%15+6;
mobRegen(mX, mY);
}
if(kbhit())
{
key=getch();
switch(key)
{
case DOWN:
gotoxy(x,y);
printf(" ");
mapArr[x][y]=0;
y++;
if(y==29)
{
y--;
}
if(mapArr[x][y]==1)
{
Score++;
enemyCount--;
}
break;
case UP:
gotoxy(x,y);
printf(" ");
mapArr[x][y]=0;
y--;
if(y==5)
{
y++;
}
if(mapArr[x][y]==1)
{
Score++;
enemyCount--;
}
break;
case LEFT:
gotoxy(x,y);
printf(" ");
mapArr[x][y]=0;
x--;
if(x==5)
{
x++;
}
if(mapArr[x][y]==1)
{
Score++;
enemyCount--;
}
break;
case RIGHT:
gotoxy(x,y);
printf(" ");
mapArr[x][y]=0;
x++;
if(x==29)
{
x--;
}
if(mapArr[x][y]==1)
{
Score++;
enemyCount--;
}
}
gotoxy(x,y);
printf("*");
mapArr[x][y]=9;
showBoard();
}
}
return 0;
}