0

iam need to complete this game with ( jumping function - hero - enemy - the fire of enemy )
please ... iam really need your help

‪#‎include‬<iostream>
#include <conio.h>
using namespace std;
void Disp(char X[][80])
{
system("cls");
for (int r=0; r<24; r++)
{
for (int c=0; c<80; c++)
{
cout<<X[r][c];
}
}
cout.flush();
}
void Fill(char X[][80])
{
for (int r=0; r<24; r++)
{
for (int c=0; c<80; c++)
{
X[r][c] = ' ';
}
}
for (int r=10; r<15; r++)
{
for (int c=35; c<45; c++)
{
X[r][c] = '*';
}
}
for (int c=0; c<80; c++)
{
X[0][c] = '#';
X[23][c] = '#';
} 
}
void FillEnmy(char X[][80], int rE, int cE)
{
X[rE][cE] = 'E';
X[rE+1][cE] = '|';
X[rE+2][cE] = '|';
}
void MoveEnmy(int &r, int &c)
{
c++;
}
void FillHero(char X[][80], int r, int c)
{
X[r][c] = 'H';
X[r][c+1] = 'H';
X[r+1][c]='|';
X[r+1][c+1]='|';
}
void MoveHero(int &r, int &c)
{
char ch = getch();
switch (ch)
{
case 'w':
r--;
break;
case 's':
r++;
break;
case 'a':
c--;
break;
case 'd':
c++;
break;
}
}
void main()
{
char X[24][80];
int RE = 5;
int CE = 10;
int RH = 12;
int CH = 75;
while (1)
{
while( !kbhit() )
{
Fill(X);
MoveEnmy(RE, CE);
FillEnmy(X , RE, CE);
FillHero(X , RH, CH);
Disp(X);
}
MoveHero(RH, CH);
FillHero(X , RH, CH);
Disp(X);
}
}
2
Contributors
1
Reply
24
Views
2 Years
Discussion Span
Last Post by David W
0

Does your program compile?
Are there errors?

Can you isolate (provide a small sample of code to illustrate where the error seems to be?)

(And when you copy/paste your code, to preserve the indentation, 'select' all the code, then press 'tab' before you submit it ... thus, the indents will be preserved and your code can be read.)

Edited by David W

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.