home *** CD-ROM | disk | FTP | other *** search
- /* JS Lloyd15 (C)2000 - Ondrej Mihula e-mail: omihula@cybex.cz */
- /* Pouzivani celeho nebo casti scriptu je povoleno jen se souhlasem autora */
-
- var xtimerID = null
- var xtimerRunning = false
- var xseconds = 0
- var timeOut = false
- var moveCounter = 0
- var fscore
- var desk = new Array()
- var imagesL15 = new Array()
-
- var maxTime = 3600
- var maxMoves = 1000
-
- // Preload images
- for (i=0;i<=16;i++) {
- imagesL15[i] = new Image()
- imagesL15[i].src = root + "images/Lloyd15/" + i + ".jpg"
- }
-
- function stopClock()
- {
- if (xtimerRunning) {
- clearTimeout(xtimerID)
- xtimerRunning = false
- }
- }
-
- function startClock()
- {
- stopClock()
- xseconds = 0
- showTime()
- }
-
- function showTime()
- {
- if (xseconds++ > (maxTime-1)) {
- stopClock()
- timeOut = true
- if (confirm (" ╚asov² limit vyprÜel ! Checete hrßt znovu ? "))
- window.location.reload()
- else
- return
- }
- minutes = (xseconds < 60) ? 0 : parseInt(xseconds/60)
- seconds = xseconds % 60
- timeValue = "╚as: "
- timeValue += ((minutes < 10) ? "0" : "") + minutes
- timeValue += ((seconds < 10) ? ":0" : ":") + seconds
- document.Lloyd15.xtimeDisp.value = timeValue
- showScore()
- xtimerID = setTimeout("showTime()",1000)
- xtimerRunning = true
- }
-
- function showScore()
- {
- scoreValue = "0000"
- scoreValue += parseInt(((maxTime-xseconds)*(maxMoves-moveCounter))/1000)
- scoreValue = scoreValue.substring(scoreValue.length-4,scoreValue.length)
- scoreValue = "Sk≤re: " + scoreValue
- document.Lloyd15.scoreDisp.value = scoreValue
- }
-
- function gameStart()
- {
- if (xtimerRunning) return
- if (finished() || timeOut) {
- alert(" Pokud chcete hrßt novou hru, klin∞te na Novß hra. ")
- return
- }
- startClock()
- }
-
- function gameOver()
- {
- stopClock()
- document.img_16.src = root + "images/Lloyd15/16.jpg"
- fscore = parseInt(((maxTime-xseconds)*(maxMoves-moveCounter))/1000)
- document.Lloyd15.score.value = fscore
- document.Lloyd15.frmscore.value = fscore
- cas = document.Lloyd15.xtimeDisp.value
- cas = cas.substring(cas.length-5,cas.length)
- alert (" ╚as slo₧enφ : \t" + cas + " \n" +
- " PoΦet tah∙ : \t" + moveCounter + " \n" +
- " Celkem sk≤re : \t" + fscore + " \n\n" +
- " Nynφ m∙₧ete ulo₧it sk≤re tlaΦφtkem Zapsat. \n")
- }
-
- function shuffle()
- {
- stopClock()
- var rnd
- i=0
- while (i<100) {
- rnd = 4*Math.random()
- if (rnd < 1) smer = 1
- if (rnd >= 1 && rnd < 2) smer = -1
- if (rnd >= 2 && rnd < 3) smer = 4
- if (rnd >= 3) smer = -4
- if ((empty+smer) > 0 && (empty+smer) < 17) {
- imgMove(empty+smer, (smer*-1))
- i++
- }
- }
- document.Lloyd15.xtimeDisp.value = "╚as: 00:00"
- document.Lloyd15.movesDisp.value = "Tah∙: 000"
- document.Lloyd15.score.value = 0
- }
-
- function clickCheck(pozice)
- {
- return (((pozice-1) == empty) || ((pozice+1) == empty) ||
- ((pozice+4) == empty) || ((pozice-4) == empty)) ? true : false
- }
-
- function finished()
- {
- for(i=1;i<16;i++)
- if (desk[i] != i) return false
- return true
- }
-
- function imgMove(pozice,smer)
- {
- image = eval("document.img_" + pozice)
- image.src = imagesL15[0].src
- image = eval("document.img_" + (pozice+smer))
- image.src = imagesL15[desk[pozice]].src
-
- desk[(pozice+smer)] = desk[pozice]
- desk[pozice] = 0
- empty = pozice
- }
-
- function imgClick(pozice)
- {
- var smer
- if (timeOut || finished()) {
- //alert(" Pokud chcete hrßt novou hru, klin∞te na Novß hra. ")
- return
- }
- smer = empty - pozice
- if (smer!= 1 && smer!=-1 && smer!=4 && smer!=-4) return
-
- if (!xtimerRunning && !finished()) gameStart()
-
- imgMove (pozice, smer)
- if (moveCounter++ == (maxMoves-1)) {
- stopClock()
- timeOut = true
- if (confirm (" Limit na poΦet tah∙ vyΦerpßn ! Checete hrßt znovu ? "))
- window.location.reload()
- else
- return
- }
- counterValue = "000"
- counterValue += moveCounter
- counterValue = counterValue.substring(counterValue.length-3,counterValue.length)
- document.Lloyd15.movesDisp.value = "Tah∙: " + counterValue
- showScore()
- if (finished()) gameOver()
- }
-
- function check(thisform)
- {
- if (!finished())
- return false
-
- /* if (login==0) {
- alert("Nep°ihlßÜen² u₧ivatel nem∙₧e zapsat sk≤re. ")
- return false
- } */
-
- if (isWhitespace(thisform.jmeno.value)) {
- alert ("\nZadejte prosφm svΘ jmΘno a p°φjmenφ.")
- thisform.jmeno.focus()
- return false
- }
- if (isWhitespace(thisform.ulice.value)) {
- alert ("\nZadejte prosφm ulici.")
- thisform.ulice.focus()
- return false
- }
- if (isWhitespace(thisform.mesto.value)){
- alert ("\nZadejte prosφm m∞sto.")
- thisform.mesto.focus()
- return false
- }
- if (isWhitespace(thisform.psc.value)){
- alert ("\nZadejte prosφm PS╚.")
- thisform.psc.focus()
- return false
- }
- if (!isPSC(thisform.psc.value)){
- alert ("\nPozor! PS╚ je zadßno Üpatn∞.")
- thisform.psc.focus()
- return false
- }
- if (isWhitespace(thisform.email.value)){
- alert ("\nZadejte prosφm e-mailovou adresu.")
- thisform.email.focus()
- return false
- }
- if (!isEmail(thisform.email.value)){
- alert ("\nE-mail adresa nenφ zadßna sprßvn∞.")
- thisform.email.focus()
- return false
- }
- document.Lloyd15.score.value = fscore
- return true
- }
-
-