Kockagame:
<head> <Script language="JavaScript"> function dobo() { var gep, gepp, emb, embp, tet, nyert; gep=parseFloat(document.fo.gep.value) gepp=parseFloat(document.fo.gepp.value) emb=parseFloat(document.fo.emb.value) embp=parseFloat(document.fo.embp.value) tet=parseFloat(document.fo.tet.value) if (tet<=embp && tet<=gepp) {gep=Math.round (Math.random()*5+1) document.fo.gep.value=gep emb=Math.round (Math.random()*5+1) document.fo.emb.value=emb if (gep>emb) { document.fo.nyer.value="Nem nyert" gepp=gepp+tet document.fo.gepp.value=gepp embp=embp-tet document.fo.embp.value=embp } if (gep<emb) { document.fo.nyer.value="nyertél" gepp=gepp-tet document.fo.gepp.value=gepp embp=embp+tet document.fo.embp.value=embp } if (gep==emb) { document.fo.nyer.value="Döntetlen" }} else {alert("Túl nagy a téted!")} } </Script> </head> <body> <form name="fo"> Gép dobása: <input name="gep" disabled value=0> Gép pénze: <input name="gepp" disabled value=10><br> Téted<input name="tet" value=5><br> Te dobásod: <input name="emb" disabled value=0> Te pénzed: <input name="embp" disabled value=10><br> <button onclick="dobo()"> Dobok </button><br> <input name="nyer"><br> </form> </body>
|