Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <meta charset="UTF-8"/>
- </head>
- </style>
- <script>
- function start(){
- z = 0;
- z = Math.round((Math.random() * 99)+1);
- zycia=8;
- proba=0;
- document.getElementById('life').innerHTML = 'Ilość żyć ' + zycia;
- document.getElementById('proby').innerHTML = 'Ilość ruchów ' + proba;
- alert('Zaczynamy');
- document.getElementById('podana').focus();
- }
- function sprawdz(){
- if (czyliczba())
- {
- if(document.getElementById('podana').value == z)
- {
- alert('wygrałeś');
- if (confirm('Jeszcze raz?'))
- {
- start();
- document.getElementById('podana').value = ' ';
- }
- else
- location.reload();
- }
- else if(document.getElementById('podana').value > z)
- {
- alert('podaj mniejszą');
- zycia = zycia - 1;
- proba = proba + 1;
- document.getElementById('life').innerHTML = 'Ilość żyć ' + zycia;
- if(zycia == 0)
- {
- alert('Przegrałeś');
- if (confirm('Jeszcze raz?'))
- {
- start();
- document.getElementById('podana').value = ' ';
- }
- else
- location.reload();
- }
- document.getElementById('proby').innerHTML = 'Ilość ruchów ' + proba;
- document.getElementById('podana').value = ' ';
- document.getElementById('podana').focus();
- }
- else if(document.getElementById('podana').value < z)
- {
- alert('podaj większą');
- zycia = zycia - 1;
- proba = proba + 1;
- document.getElementById('life').innerHTML = 'Ilość żyć ' + zycia;
- if(zycia == 0)
- {
- alert('Przegrałeś');
- if (confirm('Jeszcze raz?'))
- {
- start();
- document.getElementById('podana').value = ' ';
- }
- else
- location.reload();
- }
- document.getElementById('proby').innerHTML = 'Ilość ruchów ' + proba;
- document.getElementById('podana').value = ' ';
- document.getElementById('podana').focus();
- }
- }
- else if(!czyliczba())
- {
- alert('Podaj liczbę z zakresu <1;100>');
- document.getElementById('podana').value = ' ';
- document.getElementById('podana').focus();
- }
- }
- function czyliczba(){
- if ((document.getElementById('podana').value >= 1) && (document.getElementById('podana').value <= 100))
- return true;
- return false;
- }
- var start;
- function time(){
- var wyniki = [];
- var start = Date.now();
- imie = prompt ('Dawaj imie')
- //alert('Wystartowalismy to zastopuj');
- //var stop = Date.now();
- }
- function stoptime(){
- var stop = Date.now();
- czas_ms = (stop - start)/1000;
- alert('Uplynelo' + czas_ms + ' sekundy');
- wyniki.push({imie, czas_ms});
- koniec_zabawy = prompt('Konczymy? t=tak, nie to wpisz cokolwiek');
- if(koniec_zabawy == 't') {break};
- }
- </script>
- <body>
- <div class="box1">
- <p id="gratytul">Zgadnij liczbe</p><hr>
- <div id="gra">
- <div id="grasrodek">
- <input type="text" name="podana" id="podana" ><br>
- <input type="button" name="START" value="START" onclick="start()">
- <input type="button" name="Time" value="time" onclick="time()" >
- <input type="button" name="Sprawdz" value="Sprawdz" onclick="sprawdz()" ><br />
- </div>
- <p id="life"></p>
- <p id="proby"></p>
- </div>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement