Game Development Reference
In-Depth Information
button is pressed, a Timer object begins to call the actionPerformed method every 0.1 seconds
to update the location, velocity, mass, and pitch angle of the rocket. The first thing the method
does is to get input data for the payload mass, rocket diameter, and number of engines from
the GUI components.
// Get some initial quantities from the text fields.
double payloadMass = Double.parseDouble(payloadTextField.getText());
double rocketDiameter =
Double.parseDouble(diameterTextField.getText());
// Determine number of engines and engine type.
String numEngineString = (String)numEngineComboBox.getSelectedItem();
int numEngines = Integer.parseInt(numEngineString);
There are two choices for engine type—F1 and RD-180. The values for thrust, mass flow
rate, engine mass, and burn time are set according to which engine has been selected.
double seaLevelThrustPerEngine;
double vacuumThrustPerEngine;
double massFlowRate;
double engineMass;
double burnTime;
String engineSelection = (String)engineTypeComboBox.getSelectedItem();
if ( engineSelection.equals("F1") ) {
seaLevelThrustPerEngine = 6.67e+6;
vacuumThrustPerEngine = 7.86e+6;
massFlowRate = 2616.0;
engineMass = 8371.0;
burnTime = 150.0;
}
else {
// RD-180 data
seaLevelThrustPerEngine = 3.83e+6;
vacuumThrustPerEngine = 4.15e+6;
engineMass = 5480.0;
massFlowRate = 1254.0;
burnTime = 227.0;
}
The propellant mass that will be used by each engine is determined by multiplying the
mass flow rate and burn time. The structural mass of the rocket is estimated by a very simple
relation based on the number of engines. The initial mass of the rocket is computed as the sum
of the engine, propellant, structural, and payload masses. Keep in mind this is a highly simpli-
fied model of initial rocket mass.
Search WWH ::




Custom Search