#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;
// 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("&");
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("");
}
void systemMissile(int x, int y, int damage) {
/*
while(1) {
gotoxy(x,y-1);
printf("|");
gotoxy(x,y);
printf(" ");
}
*/
}
void mobRegen(int x, int y) {
if(enemyCount > 15) {
return ;
}
gotoxy(x,y);
enemyCount++;
printf("#");
}
int main()
{
int a,b;
char key;
int x=10, y=10;
int mX, mY;
int monster;
enemyCount = 0;
srand(time(NULL));
gotoxy(x, y);
map();
while(1)
{
key = getch();
mX = rand()%15+6;
mY = rand()%15+6;
mobRegen(mX, mY);
//system("cls");
switch(key)
{
case ATTACK:
gotoxy(x,y-1);
systemMissile(x, y, 1);
break;
case DOWN:
gotoxy(x,y);
printf(" ");
y++;
if(y==29)
{
y--;
}
scoreBoard();
//printf("DOWN\n");
break;
case UP:
gotoxy(x,y);
printf(" ");
y--;
if(y==5)
{
y++;
}
//printf("UP\n");
break;
case LEFT:
gotoxy(x,y);
printf(" ");
x--;
if(x==5)
{
x++;
}
//printf("LEFT\n");
break;
case RIGHT:
gotoxy(x,y);
printf(" ");
x++;
if(x==29)
{
x--;
}
//printf("RIGHT\n");
break;
}
gotoxy(x,y);
printf("*");
}
return 0;
}