This
is a complete source code of Space ship game written in C++
________________________________________________________________
#include<iostream>
#include<stdlib.h>
#include<conio.h>
using
namespace std;
int
position;
int
positiona;
int
positionf;
class
spaceship
{
private:
int health;
public:
spaceship()
{
position=39;
health=5;
}
void
moveleft()
{
position--;
}
void
moveright()
{
if(position<=80)
position++;
}
void
drawss(int in)
{
if(in=='f')
for(int i=0;i<16;i++)
{
cout.width(position);
cout<<" || ";
cout<<endl;
}
else
{
for(int i=0;i<16;i++)
cout<<endl;
}
cout.width(position);
cout<<" ** "<<endl;
cout.width(position);
cout<<" ****"<<endl;
cout.width(position);
cout<<" ** "<<endl;
cout.width(position+1);
cout<<"******"<<endl;
}
};
class
alien
{
private:
int health;
int i;
public:
alien(int p,int h)
{
positiona=p;
health=h;
}
void
drawal()
{
for(int i=0;i<2;i++)
cout<<endl;
for(i=0;i<6;i++)
{
cout.width(positiona);
cout<<" ***
";
}
cout<<endl;
for(i=0;i<6;i++)
{
cout.width(positiona+1);
cout<<"* * * ";
}
cout<<endl;
for(i=0;i<6;i++)
{
cout.width(positiona);
cout<<" ***
";
}
cout<<endl;
}
};
int
main()
{
alien a1(10,1);
spaceship s1;
char input;
int j=0;
for(;input!='x';)
{ if(j%2==0)
j++;
input=getch();
system("cls");
if(position>=1)
if(input=='a')
s1.moveleft();
if(position<=77)
if(input=='d')
s1.moveright();
a1.drawal();
s1.drawss(input);
}
return 0;
}
Its Good . Check out this free iPhone Game. Astropup is a great space adventure Game. Download for #iPhone, #iPad & #iPod touch and see for yourself. Try now: http://bit.ly/astropup-ios
ReplyDeletehow it work??not proplely work kindly email basitimtiaz32@gmail.com
ReplyDelete