#include
#include
#include
#define PLAYER_BULLET_MAX 5
typedef struct _bullet
{
int x;
int y;
bool fire;
}BULLET;
char bg[25][80];
int playerX;
int playerY;
int enemyX;
int enemyY;
BULLET playerBullet[PLAYER_BULLET_MAX];
void PrintfScreen(void);
void ClearScreen(void);
void GameMain(void);
void KeyControl(void);
void BulletDraw(void);
void PlayerDraw(void);
void EnemyDraw(void);
void EnemyMove(void);
void ClashEenmyAndBullet(void);
void main(void)
{
playerX = 0;
playerY = 12;
enemyX = 77;
enemyY = 12;
for(int i=0;i 75)
playerX = 75;
break;
case 80:
playerY++;
if(playerY > 23)
playerY = 23;
break;
case 32:
for(int i = 0; i 79)
{
playerBullet[i].fire = false;
}
}
}
}
void PlayerDraw(void)
{
bg[playerY - 1][playerX + 0] = '-';
bg[playerY - 1][playerX + 1] = '>';
bg[playerY + 0][playerX + 1] = '>';
bg[playerY + 0][playerX + 2] = '>';
bg[playerY + 0][playerX + 3] = '>';
bg[playerY + 1][playerX + 0] = '-';
bg[playerY + 1][playerX + 1] = '>';
}
void EnemyDraw(void)
{
bg[enemyY - 0][enemyX - 2] = '<';
bg[enemyY + 0][enemyX - 1] = '-';
bg[enemyY + 0][enemyX + 0] = '0';
bg[enemyY + 0][enemyX + 1] = '-';
bg[enemyY + 0][enemyX + 2] = '>';
}
void EnemyMove(void)
{
enemyX--;
if(enemyX<2)
{
enemyX = 77;
enemyY = (rand()%20) + 2;
}
}
void ClashEenmyAndBullet(void)
{
for(int i = 0; i= (enemyX-1)) &&(playerBullet[i].x <= (enemyX+1)))
{
enemyX = 77;
enemyY = (rand()%20) + 2;
playerBullet[i].fire = false;
}
}
}
}
}