-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gra.html
90 lines (89 loc) · 2.25 KB
/
Gra.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<html>
<head>
<meta charset='utf-8'>
<title>Gra</title>
<link rel="StyleSheet" type="text/css" href="styl.css">
</head>
<body>
<div id="container">
<div id="footer">
<center>
</center>
</div>
<div id="gracz1">
<center>
<h1>GRACZ 1</h1>
<input class="but" type="button" value="losowanie" onclick="los()" />
</center>
</div>
<div id="gracz2">
<center>
<h1>GRACZ 2</h1>
<input class="but" type="button" value="losowanie" onclick="los2()" />
</center>
</div>
<div id="rzut1">
</div>
<div id="rzut2">
</div>
<div id="wynik1">
</div>
<div id="wynik2">
</div>
</div>
<script>
var r =parseInt(prompt('ile rund?'))
var wyn1=0;
var wyn2=0;
function los(){
var p1=Math.round((Math.random()*5)+1);
var i=10
switch(p1){
case 1 : document.getElementById('rzut1').innerHTML="><img src='kostka1.jpg'>";
w1=1
break;
case 2 : document.getElementById('rzut1').innerHTML="><img src='kostka2.jpg'>";
w1=2
break;
case 3 : document.getElementById('rzut1').innerHTML="><img src='kostka3.jpg'>";
w1=3
case 4 : document.getElementById('rzut1').innerHTML="><img src='kostka4.jpg'>";
w1=4
break;
case 5 : document.getElementById('rzut1').innerHTML="><img src='kostka5.jpg'>";
w1=5
break;
case 6 : document.getElementById('rzut1').innerHTML="<img src='kostka6.jpg'>";
w1=6
break;
}
};
function los2(){
var p2=Math.round((Math.random()*5)+1);
switch(p2){
case 1 : document.getElementById('rzut2').innerHTML="<img src='kostka1.jpg'>";
w2=1
break;
case 2 : document.getElementById('rzut2').innerHTML="<img src='kostka2.jpg'>";
w2=2
break;
case 3 : document.getElementById('rzut2').innerHTML="<img src='kostka3.jpg'>";
w2=3
break;
case 4 : document.getElementById('rzut2').innerHTML="<img src='kostka4.jpg'>";
w2=4
break;
case 5 : document.getElementById('rzut2').innerHTML="<img src='kostka5.jpg'>";
w2=5
break;
case 6 : document.getElementById('rzut2').innerHTML="<img src='kostka6.jpg'>";
w2=6
break;
}
if(w1>w2) { wyn1++; document.getElementById('wynik1').innerHTML="<center><h1>Wygrane: "+wyn1+"</h1></center>"}
else if(w2>w1) { wyn2++; document.getElementById('wynik2').innerHTML="<center><h1>Wygrane: "+wyn2+"</h1></center>"}
if (wyn2+wyn1==r+1){confirm('Koniec gry'); window.location.reload(false); };
};
</script>
</body>
</html>