[HTML/JS] Würfel-Spiel

HTML:
<html>
<head>
<script language="JavaScript"><!--

function aktualisiereAugensumme(augensumme) {
    document.getElementById("augensumme").value = augensumme;
}

function aktualisiereSummeAllerWuerfe(augensumme) {
    var letzterWert = parseInt(document.getElementById("augensumme_summiert").value);
    
    document.getElementById("augensumme_summiert").value = letzterWert + augensumme;
}

function rechnen()
{
    zahl1=Math.ceil(Math.random()*6);
    zahl2=Math.ceil(Math.random()*6);
    
    if (zahl2 > zahl1)
    {
        jo = zahl1;
        zahl1 = zahl2;
        zahl2 = jo
    }
    
    document.images["Bilder1"].src="wurf"+zahl1+".GIF";
    document.images["Bilder2"].src="wurf"+zahl2+".GIF";
    
    
    aktualisiereAugensumme(zahl1+zahl2);
    aktualisiereSummeAllerWuerfe(zahl1+zahl2);
}

//-->
</script>


<title>Wurfeldings</title>




</head>
<body>
<img src="wurfohne.gif" width= "200" name="Bilder1" alt="hier ist ein bild">
<img src="wurfohne.gif" width= "200" name="Bilder2" alt="hier ist noch ein bild">
<form name="hallo" action="">
      <input type="button" name="a" value="Wuerfeln" OnClick="rechnen()">
   <BR>  <BR>

	<b>Augensumme aktueller Wurf:</b> <input readonly type="text" id="augensumme" value="0" /><br />
  <b>Augensumme alle Würfe:</b> <input readonly type="text" id="augensumme_summiert" value="0" /><b></b>
</form>
</body>
</html>
 
Zuletzt bearbeitet:
Kann ich ja nicht riechen ;)
HTML:
<html>
<head>
<script language="JavaScript">



var Augensumme = 0;

function rechnen()
{
    zahl1=Math.ceil(Math.random()*6);
    zahl2=Math.ceil(Math.random()*6);
    
    if (zahl2 > zahl1)
    {
        jo = zahl1;
        zahl1 = zahl2;
        zahl2 = jo
    }
    
    document.images["Bilder1"].src="wurf"+zahl1+".GIF";
    document.images["Bilder2"].src="wurf"+zahl2+".GIF";
    
    Augensumme = Augensumme + zahl1 + zahl2;
    
    document.forms["hallo"].augensumme.value = zahl1 + zahl2;
    document.forms["hallo"].augensumme_summiert.value = Augensumme;
}

//-->
</script>


<title>Wurfeldings</title>




</head>
<body>
<img src="wurfohne.gif" width= "200" name="Bilder1" alt="hier ist ein bild">
<img src="wurfohne.gif" width= "200" name="Bilder2" alt="hier ist noch ein bild">
<form name="hallo" action="">
      <input type="button" name="a" value="Wuerfeln" OnClick="rechnen()">
   <BR>  <BR>

	<b>Augensumme aktueller Wurf:</b> <input type="text" name="augensumme" value="0" /><br />
  <b>Augensumme alle Würfe:</b> <input type="text" name="augensumme_summiert" value="0" />
</form>
</body>
</html>
 
Zurück
Oben