Window::Window() : QWidget(0) { Console* console = new Console(this); connect(console, SIGNAL(LoadSelect(const QString&)), this, SLOT(Load(const QString&))); dialog = new NewWorldDialog(this); connect(dialog, SIGNAL(ConfirmedNewWorld()), this, SLOT(CreateNewWorld())); fd_save = new QFileDialog(this, "Saving"); fd_save->setFileMode(QFileDialog::AnyFile); connect(fd_save, SIGNAL(fileSelected(const QString&)), this, SLOT(Save(const QString&))); setMinimumSize(640, 480); }
//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; }
//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); } }