Praktikum 1/2 und gulp.js

This commit is contained in:
Andrea Gaertner
2020-04-30 17:03:44 +02:00
parent 1630464f79
commit c52c2536db
9 changed files with 170 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
alert("Hello World!");
+61
View File
@@ -0,0 +1,61 @@
function simulation() {
function switchOn() {
schub = true;
update();
}
function switchOff() {
schub = false;
update();
}
function a() {
if (schub == false || fuel <= 0)
return -1.63;
else {
fuel = fuel - 100;
return -1.63 + 12;
}
}
function setStartValues() {
var v = -1000;
var s = 50000;
var fuel = 10000;
var schub = false;
}
function update() {
v = v + a();
s = s + v;
if (s <= 0) {
s = 0;
gameOver();
}
$("#height").html("Höhe: " + s + "m");
$("#speed").html("Geschwindigkeit: " + v + "m/s");
$("#fuel").html("Treibstoffvorrat: " + fuel + "l");
}
function gameOver() {
if (v > -10)
alert("Mondlandung geglückt!!!");
else
alert("Mondlandung gescheitert ...");
setStartValues();
}
$("body").append("<div id='height'>Höhe: </div>");
$("body").append("<div id='speed'>Geschwindigkeit: </div>");
$("body").append("<div id='fuel'>Treibstoffvorrat: </div>");
$("body").append("<button id='energy'>Triebwerk an</button>");
$("body").append("<button id='no-energy'>Triebwerk aus</button>");
$("#energy").click(switchOn);
$("#no-energy").click(switchOff);
setStartValues();
}
$(document).ready(simulation);