1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- function simulation() {
- var v;
- var s;
- var fuel;
- var schub = false;
-
- setStartValues(50000, -1000, 10000);
-
- function switchon() {
- schub = true;
- update();
- checkGameOver();
- }
-
- function switchoff() {
- schub = false;
- update();
- checkGameOver();
- }
-
- function a() {
- if (schub == false || fuel <= 0)
- return -1.63;
- else {
- fuel = fuel - 100;
- return -1.63 + 12;
- }
- }
-
- function showValues() {
- $("#height").html("Höhe: " + s + " m");
- $("#speed").html("Geschwindigkeit: " + v + " m/s");
- $("#fuel").html("Teibstoffvorrat: " + fuel + " l");
- }
-
-
- function update() {
- v = v + a();
- s = s + v;
- showValues();
- }
-
- function checkGameOver() {
- if (s <= 0) {
- if (v < -10)
- alert("Fehlschlag");
- else
- alert("Erfolgreich");
-
- setStartValues(50000, -1000, 10000);
- showValues();
- }
- }
-
- function setStartValues(height, velocity, Newfuel) {
- v = velocity;
- s = height;
- fuel = Newfuel;
- }
-
- $('#content').html("<h2>Mondlandung</h2>");
- $("#content").append("<div class='menu'>Hauptmenü</div>")
- $("#content").append("<div id='height'>Höhe: </div>");
- $("#content").append("<div id='speed'>Geschwindikgiet: </div>");
- $("#content").append("<div id='fuel'>Treibstoffvorrat: </div>");
- $("#content").append("<button id='energy' class='btn-style'>Triebwerk an</button>");
- $("#content").append("<button id='no-energy' class='btn-style'>Triebwerk aus</button>");
-
-
-
- $("#energy").click(switchon);
- $("#no-energy").click(switchoff);
-
- showValues();
- }
-
|