Example #1
0
//Splash screen
void Splash() {
	ResetTimer(); //we're going to use it for random seed
	//Setup a world with a tank and a pyramid in specific places
	CloseGraphics();
	OpenGraphics();

	Point3d centre;
	world=CreateNewWorld();

	//A tank pointing straight at us
	centre=CreatePoint(0.0,0.0,45.0);
	obj=CreateTank(GREEN, centre, 4.5);
	RotateObjectYAxis(&obj, 2.0 * PI / 360.0 * 195);
	AddObjectToWorld(&world, obj);

	//A yellow pyramid behind the tank and to the right
	centre=CreatePoint(10.0, 0.0, 70.0);
	obj=CreatePyramid(YELLOW, centre, 5.0);
	RotateObjectYAxis(&obj, 3.0*PI/5.0);
	AddObjectToWorld(&world, obj);

	//A blue cube behind the tank and to the left
	centre=CreatePoint(-10.0, 0.0, 60.0);
	obj=CreateCube(BLUE, centre, 5.0);
	RotateObjectYAxis(&obj, 195.0*PI/180.0);
	AddObjectToWorld(&world,obj);

	//Draw world, add splash graphics, prompt to start
	cameraPos=CreatePoint(0.0,5.0,0.0);
	cameraAngle=CreatePoint(0.0,0.0,0.0);
	DrawWorld(&world, cameraPos, cameraAngle);
	SetTextColor(GREEN);
	DrawText(5,25, "by RorschachUK");

	SetTextColor(CYAN);
	DrawText(5,100, "Help");
	DrawText(110,100,"Start");
	DrawImage(logoImage, 5,5,RGBColor(253,255,252,0));
	DrawImage(signatureImage, 135,24,BLACK);

	Show();
	Sleep(100);
	mode=0;
}
Example #2
0
void GameEngine::setConnection(bool is_server, QString ip, int port)
{
    if(is_server) {
        conn_server = new GameServer(port, this);
    } else {
        conn_client = new GameClient(this);
    }

    protocol = new GameProtocol(scene,
                                this,
                                &vehicles,
                                conn_server,
                                conn_client,
                                ip,
                                port);
    this->ip = ip;
    this->port = port;

    if(conn_server) {
        connect(conn_server, SIGNAL(InitConnection(int)), this, SLOT(ServerInitConnection(int)));
        connect(conn_server, SIGNAL(ReceiverMSG(int,QByteArray)), this, SLOT(ServerReceiveMSG(int,QByteArray)));
        CreateTank(true);
    } else if(conn_client) {
Example #3
0
//Setup world
void InitialiseWorld() {
	world=CreateNewWorld();
	Point3d centre;
	//Camera starting point - raised 5cm off ground.
	cameraPos=CreatePoint(0.0,5.0,0.0);
	cameraAngle=CreatePoint(0.0,0.0,0.0);
	baselinePos=cameraPos;
	arrowRefAngle=0;

	//The tank
	tank=CreateTank(GREEN, CreatePoint(0,0,0), 4.5);
	tankObjectIndex=AddObjectToWorld(&world, tank);
	PlaceTank(cameraPos, cameraAngle);

	//Populate with a few shapes
	int i;
	for (i=0; i<4; i++) {
		//Random blue cubes
		centre=CreatePoint(Random(-100.0, 100.0),0.0,Random(-100.0, 100.0));
		obj=CreateCube(BLUE, centre, 4.0);
		RotateObjectYAxis(&obj, Random(0.0, 2 * PI));
		AddObjectToWorld(&world,obj);

		//Random yellow pyramids
		centre=CreatePoint(Random(-100.0, 100.0),0.0,Random(-100.0, 100.0));
		obj=CreatePyramid(YELLOW, centre, 4.0);
		RotateObjectYAxis(&obj, Random(0.0, 2 * PI));
		AddObjectToWorld(&world,obj);

		//Random red barrels
		centre=CreatePoint(Random(-100.0, 100.0),0.0,Random(-100.0, 100.0));
		obj=CreateCylinder(RED,centre, 4.0);
		RotateObjectYAxis(&obj, Random(0.0, 2 * PI));
		AddObjectToWorld(&world,obj);
	}
}