-
Notifications
You must be signed in to change notification settings - Fork 0
/
coin-game.html
139 lines (135 loc) · 6.37 KB
/
coin-game.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<!DOCTYPE html>
<html>
<head>
<style>
h1{text-align:center;color:red;text-shadow:2px 2px 8px olive;}
#div1, #div2, #div3, #div4,#div5, #div6, #div7, #div8,#div9, #div10,#div11,#div12, #div13, #div14, #div15,#div16,#div17, #div18, #div19, #div20,#div21, #div22, #div23, #div24,#div25, #div26,#div27,#div28,
#div29, #div30, #div31, #div32, #div33, #div34, #div35
{float:left; width:50px; height:50px; margin:5px;padding:2px;border:1px dotted #8d67ff;text-align:center;}
</style>
</head>
<body>
<h1>Interactive Coin Game</h1>
<div style="padding-left:100px;">
<div id="div1" ondrop="drop(event)" ondragover="allowDrop(event)">
</div>
<div id="div2" ondrop="drop(event)" ondragover="allowDrop(event)">
</div>
<div id="div3" ondrop="drop(event)" ondragover="allowDrop(event)">
</div>
<div id="div4" ondrop="drop(event)" ondragover="allowDrop(event)">
<img src="images/dollar.jpg" draggable="true" ondragstart="drag(event)" id="drag1" width="50" height="50">
</div>
<div id="div5" ondrop="drop(event)" ondragover="allowDrop(event)">
</div>
<div id="div6" ondrop="drop(event)" ondragover="allowDrop(event)">
</div>
<div id="div7" ondrop="drop(event)" ondragover="allowDrop(event)">
</div>
<div style="clear:both;"></div>
<!---2nd row---->
<div id="div8" ondrop="drop(event)" ondragover="allowDrop(event)">
</div>
<div id="div9" ondrop="drop(event)" ondragover="allowDrop(event)">
</div>
<div id="div10" ondrop="drop(event)" ondragover="allowDrop(event)">
<img src="images/dollar.jpg" draggable="true" ondragstart="drag(event)" id="drag2" width="50" height="50">
</div>
<div id="div11" ondrop="drop(event)" ondragover="allowDrop(event)">
</div>
<div id="div12" ondrop="drop(event)" ondragover="allowDrop(event)">
<img src="images/dollar.jpg" draggable="true" ondragstart="drag(event)" id="drag3" width="50" height="50">
</div>
<div id="div13" ondrop="drop(event)" ondragover="allowDrop(event)">
</div>
<div id="div14" ondrop="drop(event)" ondragover="allowDrop(event)">
</div>
<div style="clear:both;"></div>
<!----3rd row---->
<div id="div15" ondrop="drop(event)" ondragover="allowDrop(event)">
</div>
<div id="div16" ondrop="drop(event)" ondragover="allowDrop(event)">
<img src="images/dollar.jpg" draggable="true" ondragstart="drag(event)" id="drag4" width="50" height="50">
</div>
<div id="div17" ondrop="drop(event)" ondragover="allowDrop(event)">
</div>
<div id="div18" ondrop="drop(event)" ondragover="allowDrop(event)">
<img src="images/dollar.jpg" draggable="true" ondragstart="drag(event)" id="drag5" width="50" height="50">
</div>
<div id="div19" ondrop="drop(event)" ondragover="allowDrop(event)">
</div>
<div id="div20" ondrop="drop(event)" ondragover="allowDrop(event)">
<img src="images/dollar.jpg" draggable="true" ondragstart="drag(event)" id="drag6" width="50" height="50">
</div>
<div id="div21" ondrop="drop(event)" ondragover="allowDrop(event)">
</div>
<div style="clear:both;"></div>
<!----4th row---->
<div id="div22" ondrop="drop(event)" ondragover="allowDrop(event)">
<img src="images/dollar.jpg" draggable="true" ondragstart="drag(event)" id="drag7" width="50" height="50">
</div>
<div id="div23" ondrop="drop(event)" ondragover="allowDrop(event)">
</div>
<div id="div24" ondrop="drop(event)" ondragover="allowDrop(event)">
<img src="images/dollar.jpg" draggable="true" ondragstart="drag(event)" id="drag8" width="50" height="50">
</div>
<div id="div25" ondrop="drop(event)" ondragover="allowDrop(event)">
</div>
<div id="div26" ondrop="drop(event)" ondragover="allowDrop(event)">
<img src="images/dollar.jpg" draggable="true" ondragstart="drag(event)" id="drag9" width="50" height="50">
</div>
<div id="div27" ondrop="drop(event)" ondragover="allowDrop(event)">
</div>
<div id="div28" ondrop="drop(event)" ondragover="allowDrop(event)">
<img src="images/dollar.jpg" draggable="true" ondragstart="drag(event)" id="drag10" width="50" height="50">
</div>
<div style="clear:both;"></div>
<!----5 th row---->
<div id="div29" ondrop="drop(event)" ondragover="allowDrop(event)">
</div>
<div id="div30" ondrop="drop(event)" ondragover="allowDrop(event)">
</div>
<div id="div31" ondrop="drop(event)" ondragover="allowDrop(event)">
</div>
<div id="div32" ondrop="drop(event)" ondragover="allowDrop(event)">
</div>
<div id="div33" ondrop="drop(event)" ondragover="allowDrop(event)">
</div>
<div id="div34" ondrop="drop(event)" ondragover="allowDrop(event)">
</div>
<div id="div35" ondrop="drop(event)" ondragover="allowDrop(event)">
</div>
<div style="clear:both;"></div>
</div>
<div style="width:400px;height:400px;margin-left:100px;">
<p>Instructions:</p>
<ol>
<li>You can drag the coins for this simple game.</li>
<li>You are supposed to <em>invert</em> the triangle with just <em>three</em> coin moves.</li>
<li>If you make more than three moves, a warning will appear.</li>
<li>If you get a warning, refresh the page and repeat - apart from making the same mistake, of course.</li>
</ol>
</div>
<script>
h = 0;
function allowDrop(ev) {
ev.preventDefault();
}
function drag(ev) {
ev.dataTransfer.setData("Text", ev.target.id);
}
function drop(ev) {
h = h + 1;
if (h <= 3) {
ev.preventDefault();
var data = ev.dataTransfer.getData("Text");
ev.target.appendChild(document.getElementById(data));
}
else {
alert('Only 3 moves allowed; refresh the page for new attempt.');
}
};
</script>
</div>
</body>
</html>