HRA: ODOBERANIE ZAPALIEK (2)

ID
Nazov / Name:
Popis / Description:
Dlzka / Length:
Testovane pod / Tested under:

 

183
p183.html / p183.zip
Kto odoberie poslednu zapalku, prehrava.
6430b
NN 4.04, IE 4.0

UKAZKA / CLICK HERE

Zdrojovy tvar / Source code:

<HTML> <HEAD><TITLE>JavaScript DESTINATION - P183</TITLE> <SCRIPT LANGUAGE="JavaScript"> <!-- function pocetzap() { if (pocet < 10) { var pp = pocet + " " document.images[45].src=dg[0].src document.images[46].src=dg[pp.substring(0,1)].src } else { var ppp = pocet + " " document.images[45].src=dg[ppp.substring(0,1)].src document.images[46].src=dg[ppp.substring(1,2)].src } } function isnum(s) { var ss = s + " " var sss for (var i = 0; i<ss.length - 1; i++) { sss = ss.substring(i,i+1) if ((sss < "0") || (sss > "9")) return false } return true } function newgame() { var mm = meno mm=window.prompt("Zadaj svoje meno",mm) while (mm == "") { mm=window.prompt("Zadaj svoje meno",mm) } if (mm == null) return else meno = mm var pp = pocet pp=window.prompt("Zadaj pocet zapaliek",pp) while ((pp != null) && (!isnum(pp) || (pp < 5 ) || (pp > 45))) { pp=window.prompt("Zadaj pocet zapaliek",pp) } if (pp == null) return else pocet = pp for (var ii=0; ii< 45; ii++) if (ii<pocet) document.images[ii].src=zap.src else document.images[ii].src=nic.src pocetzap() active = true } function computer() { pocetzap() if (pocet == 1) { active = false alert("Vyhral si, gratulujem") } else { if (pocet % 4 == 0) { pocet-- document.images[pocet].src=nic.src pocet-- document.images[pocet].src=nic.src pocet-- document.images[pocet].src=nic.src alert("Zobral som 3 zapalky") } else if (pocet % 4 == 1) { var nrandom = Math.round(Math.random()*10) % 3 + 1 for (var ii = 0; ii< nrandom; ii++) { pocet-- document.images[pocet].src=nic.src } alert("Zobral som "+ nrandom +" zapalky") } else if (pocet % 4 == 2) { pocet-- document.images[pocet].src=nic.src alert("Zobral som 1 zapalku") } else if (pocet % 4 == 3) { pocet-- document.images[pocet].src=nic.src pocet-- document.images[pocet].src=nic.src alert("Zobral som 2 zapalky") } if (pocet == 1) { active = false alert("Vyhral som !!!!!!!!") } pocetzap() } } function Butt1() { if (active && (pocet >0)) { pocet-- document.images[pocet].src=nic.src computer() } } function Butt2() { if (active && (pocet >1)) { pocet-- document.images[pocet].src=nic.src pocet-- document.images[pocet].src=nic.src computer() } } function Butt3() { if (active && (pocet >2)) { pocet-- document.images[pocet].src=nic.src pocet-- document.images[pocet].src=nic.src pocet-- document.images[pocet].src=nic.src computer() } } <!-- koniec --> </SCRIPT> </HEAD> <BODY BGCOLOR="#CCCCFF" TEXT="#000000" VLINK="#FF0000" ONLOAD="focus()"> <SCRIPT LANGUAGE="JavaScript"> <!-- meno = "" pocet = 45 nic=new Image(); nic.src="images/nic.gif" zap=new Image(); zap.src="images/zap.gif" dg = new Array() for(var i=0; i < 10; i++) { dg[i] = new Image() } dg[0].src = "images/dg0.gif" dg[1].src = "images/dg1.gif" dg[2].src = "images/dg2.gif" dg[3].src = "images/dg3.gif" dg[4].src = "images/dg4.gif" dg[5].src = "images/dg5.gif" dg[6].src = "images/dg6.gif" dg[7].src = "images/dg7.gif" dg[8].src = "images/dg8.gif" dg[9].src = "images/dg9.gif" for (var iy=0; iy<3; iy++) { document.write("<CENTER>") for (var ix=0; ix<15; ix++) { document.write("<IMG BORDER=0 WIDTH=20 HEIGHT=50 SRC='images/zap.gif'>") } document.write("</CENTER>") } active = false <!-- --> </SCRIPT> <CENTER> <form> <P> Kolko zapaliak chces odobrat ? <input type="button" name="Button1" value=" 1 " onclick="Butt1()"> <input type="button" name="Button2" value=" 2 " onclick="Butt2()"> <input type="button" name="Button3" value=" 3 " onclick="Butt3()"> </form> <A>Aktualny pocet zapaliek</A> <IMG BORDER=0 WIDTH=25 HEIGHT=50 SRC='images/dg4.gif'><IMG BORDER=0 WIDTH=25 HEIGHT=50 SRC='images/dg5.gif'> <form> <input type="button" name="ButtonNew" value="Nova hra" onclick="newgame()"> </form> <A HREF="javascript:history.back()">Navrat</a> / <a href="priklady-english.html">BACK</A> </CENTER> </body> </html>
[ Navrat / BACK ]