Esempio n. 1
0
int main(){

	int width = 800;
	int height = 600;

	//Game Window
	static Window window("Interstellar Explorer", width, height);
	glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

	Motion motion;
	Orbit orb1;  //Also this
	Orbit orb2;

	// Construction
	PlayerObject player("Imgs/ship.png"); //Set filename to empty quotes to leave player as polygon
	vector<CircleObject> test = loadPlanets(test, "level.txt");

	//OpenGl Coordinate Grid Setup
	glViewport(0, 0, width, height);
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	glOrtho(-width / 2, width / 2, -height / 2, height / 2, 0, 1);
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

	while (!window.closed()){
		window.clear();

		checkForInput(&window, &motion);

		// Translation
		glPushMatrix();
		motion.applySpeed();
		for (unsigned int i = 0; i < test.size(); i++){
			test[i].Draw();
		}
		glPopMatrix();

		// Rotation
		glPushMatrix();
		motion.applyRotation();
		player.Draw();
		glPopMatrix();

		//Orbits
		glPushMatrix();
		orb1.orbit(test);
		glPopMatrix();

		window.update();
		Sleep(0.5); //Controls how fast the game loop runs
	}

	return 0;
}