Friedfischer
Grünschnabel
Hallo, habe folgendes Programm geschrieben, und weiß nicht ganz, wie ich die Kollisionsabfrage machen soll.
Könnt ihr mir helfen?
Wenn ihr das braucht: Ich programmiere im Borland 5 mit c++ in der Konsole.
Könnt ihr mir helfen?
Wenn ihr das braucht: Ich programmiere im Borland 5 mit c++ in der Konsole.
C++:
#include <conio>
#include <iomanip>
#include <vcl>
//------Variablendeklaration---------------------------------------------------
int dxh=37, dyh=2;
int dxg=27, dyg=28;
int dxs=37, dys;
void Hubschrauber (int dx);
void Schuss (void);
void Gegner1 (void);
//---Unterprogramm--------------------------------------------------------------
void Hubschrauber (int dx)
{
gotoxy(dxh+4,dyh);
cout<<" ";
gotoxy(dxh,dyh);
cout<<" ";
gotoxy(dxh+3,dyh);
cout<<"O";
gotoxy(dxh+2,dyh);
cout<<"-";
gotoxy(dxh+1,dyh);
cout<<"o";
gotoxy(dxh+3,dyh+1);
cout<<'\xEE';
gotoxy(dxh+4,dyh+1);
cout<<" ";
gotoxy(dxh+5,dyh);
cout<<" ";
gotoxy(dxh+5,dyh+1);
cout<<" ";
gotoxy(dxh+2,dyh+1);
cout<<" ";
gotoxy(dxh+1,dyh+1);
cout<<" ";
gotoxy(dxh+4,dyh-1);
cout<<" ";
gotoxy(dxh+2,dyh-1);
cout<<" ";
gotoxy(dxh-1,dyh);
cout<<" ";
gotoxy(dxh+5,dyh-1);
cout<<" ";
gotoxy(dxh+1,dyh-1);
cout<<" ";
gotoxy(dxh+3,dyh-1);
cout<<"_";
}
void Schuss (void)
{
for(dys=4; dys<=30; dys++)
{
gotoxy(dxs+3,dys);
cout<<"|";
gotoxy(dxs+2,2);
cout<<"-";
Sleep(30);
gotoxy(dxs+3,dys-1);
cout<<" ";
gotoxy(dxs+2,2);
cout<<"-";
}
}
void Gegner1 (void)
{
gotoxy(dxg,dyg);
cout<<'\x01';
gotoxy(dxg,dyg+1);
cout<<"0";
gotoxy(dxg-1,dyg+1);
cout<<"`";
gotoxy(dxg+1,dyg+1);
cout<<'\x60';
gotoxy(dxg+1,dyg+2);
cout<<"`";
gotoxy(dxg-1,dyg+2);
cout<<'\x60';
}
//-----------------------------------------------------------------------------
int main(int argc, char **argv)
{
_setcursortype(_NOCURSOR);
clrscr();
do
{
for (int i=1; i<2; i++)
{
if(dxh>=76)
{
return 0;
}
if(dxh<=0)
{
return 0;
}
Gegner1();
i--;
if(kbhit())
{
switch(getch())
{
case 77: 2*dxh++; 2*dxs++; Hubschrauber(dxh); break;
case 75: 2*dxh--; 2*dxs--; Hubschrauber(dxh); break;
case 80: Schuss(); break;
}
}
}
}
while(getch()!='q');
return 0;
}