#include
#include
#include "ccc_win.h"
using namespace std;
// Here is the function that will draw the spaceship.
It is a void function
//so it will not return a value, simply draw the
picture.
void spaceship(double x_coord, double y_coord)
{

cwin.coord(0,2000,2000,0);


//spaceship coordinates, will be used to construct
lines for the spaceship.
Point p0(x_coord , y_coord);
Point p1(x_coord + 50 , y_coord + 50);
Point p2(x_coord + 140, y_coord + 50);
Point p3(x_coord + 150, y_coord + 120);
Point p4(x_coord + 160, y_coord + 50);
Point p5(x_coord + 250, y_coord + 50);
Point p6(x_coord + 300, y_coord);




//spaceship lines connected all up based on above
points.
cwin << Line(p0,p6);
cwin << Line(p0,p1);
cwin << Line(p1,p5);
cwin << Line(p5,p6);
cwin << Line(p2,p3);
cwin << Line(p3,p4);

}

int ccc_win_main()

{

//These points are chosen as the starting points for
the spaceship,
//arbitrarily chosen.

double x = 300;
double y = 500;

//The spaceship is drawn for the first time.

spaceship( x, y);

//The users options as to what direction they want to
go are given here.

string direction = cwin.get_string("Enter
(U)p,(D)own, (L)eft, (R)ight ");

//Here are the effects of the users decision in if
statements, given that
//if the user presses a vertical movement, increments
of 50 will take place
//and if a horizontal movement is chosen an increment
of 20 will occur.
// In th while function I have already chosen the
values of the x/y minimum
//and maximum to achieve best visual quality for the
given window size.
//Also, the clear function is included to remove the
previous spaceship
// as it "moves."
if( direction == "u")
{
while( y < 1820)
{
cwin.clear();
x = x;
y = y + 50;
spaceship(x, y);
}
}
if( direction == "d")
{
while( y > 40 )
{
cwin.clear();
x = x;
y = y - 50;
spaceship(x, y);
}
}
if( direction == "l")
{
while( x > 0)
{
cwin.clear();
x = x - 20;
y = y;
spaceship(x,y);
}
}
if( direction == "r")
{
while( x < 1700)
{
cwin.clear();
x = x + 20;
y = y;
spaceship(x,y);
}
}

else
{
cwin.clear();
Point msg_loc(400, 800);
string error ="You chose an incorrect
letter!";
cwin << Message( msg_loc, error);
}


return 0;



}
Site hosted by Angelfire.com: Build your free website today!