Hello, yes all was coded in C++.
About live system it's easy, you set a "O2 reserve" of say 1000
(A float value that hold 1000) then each loop you deduct the crew
consumption multiplied by DT (delta time of the loop)
You must absolutely use DT provided in the main loop otherwise
a computer with 120 FPS will use much O2 than one with 40 FPS.
Something like that: (Pseudo C++ code)
At ini time:
fO2Tank = 1000.0; // float value O2 Tank
fO2InCabin=100.0; // the O2 present in the cabin
fOneCrewConsumption=0.12; // changing this you can tune the compsumption of one crew.
fNumberOfCrewAboard=3; // changing this you can simulate EVA in the cabin.
bButtonO2Open=1; // value to simulate the O2 circuit being open or not
At loop time:
// this will deduce the O2 consumption of the crew aboard only if the O2 circuit is open
if(bButtonO2Open==1)
{
fO2Tank-=(fOneCrewConsumption*fNumberOfCrewAboard)*DT;
// fill the cabin with O2
if(fO2InCabin<100.0)
fO2InCabin+=10.0*DT;
}
else // if the circuit is closed crew will use cabin O2, once cabin empty they die.
{
fO2InCabin-=(fOneCrewConsumption*fNumberOfCrewAboard)*DT;
// no more O2 in cabin ? crew die
if(fO2InCabin<1)
bCrewIsDead=1;
}
Of course value has to be tuned and refinment can be done but the principe is here.
Hope it help ?
Dan