void SolarSystem::Simulate(float deltaTime) { if (Keyboard::getKeyPressed(KEY_Z)) { simulationDeltaTime -= 0.001f; simulationDeltaTime = MathHelper::Clampf(simulationDeltaTime, 0.001f, 0.05f); } if (Keyboard::getKeyPressed(KEY_X)) { simulationDeltaTime += 0.001f; simulationDeltaTime = MathHelper::Clampf(simulationDeltaTime, 0.001f, 0.05f); } if (Keyboard::getKeyPressed(KEY_J)) { addMoon(); } for (size_t i = 0; i < m_Planets.size(); i++){ m_Planets[i]->simulate(simulationDeltaTime); } }
void keyDown(unsigned char key, int x, int y) { if (key==0x1b){exit(0);} //if(key=='1'){printf("Mercury\n");} //if(key=='2'){printf("Venus\n");} //if(key=='3'){printf("Earth\n");} //if(key=='4'){printf("Mars\n");} //if(key=='5'){printf("Jupiter\n");} //if(key=='6'){printf("Saturn\n");} //if(key=='7'){printf("Uranus\n");} //if(key=='8'){printf("Neptune\n");} //if(key=='9'){printf("Pluto\n");} // printf("Key is %c %d\n",key,(int)key); // check for numerical keys if (key > '0' && key <= '9') { //printf("Key is %c %d\n",key,(int)key); // point at the specified planet float vec[3]; solarSystem.getPlanetPosition(key - '0', vec); camera.pointAt(vec); // printf("VECTOR %f - %f - %f \n", vec[0], vec[1], vec[2]); // select that planet planetSelected = key - '0'; } switch (key) { case '-': timeSpeed /= 2.0f; // half the rate of time passing break; case '=': timeSpeed *= 2.0f; // double the rate of time passing break; case 'h': helpDialogue = !helpDialogue; // toggle the dialogue break; case '[': planetSizeScale /= 1.2; // make planet scale smaller break; case ']': planetSizeScale *= 1.2; // make planet scale bigger break; case 'o': showOrbits = !showOrbits; // toggle show orbits break; case 'm': addMoon(); // add a moon to the selected planet break; case 't': planetSizeScale = 0.000050f; break; case 'u': timeSpeed = 0.10f; break; case 'v': planetSizeScale = 0.0000050f; break; case 'r': planetSizeScale = distanceScale; break; case ',': camera.slowDown(); // slow down camera break; case '.': camera.speedUp(); // speed up camera break; // these are all camera controls case 'w': controls.forward = true; break; case 's': controls.backward = true; break; case 'a': controls.left = true; break; case 'd': controls.right = true; break; case 'l': controls.rollRight = true; break; case 'j': controls.rollLeft = true; break; case 'i': controls.pitchDown = true; break; case 'k': controls.pitchUp = true; break; case 'q': controls.yawLeft = true; break; case 'e': controls.yawRight = true; break; } }