Skip to content

Commit 30c264b

Browse files
committed
added first-attempt game loop
1 parent 8bc9fdd commit 30c264b

File tree

5 files changed

+210
-197
lines changed

5 files changed

+210
-197
lines changed

explode.png

20.6 KB
Loading

index.html

Lines changed: 42 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,42 @@
1-
<!DOCTYPE html>
2-
<html>
3-
<head>
4-
<title>Index</title>
5-
6-
<link rel="stylesheet" href="styles.css" type="text/css">
7-
<script src="jquery-1.10.2.min.js" type="text/javascript"></script>
8-
<script src="script.js" type="text/javascript"></script>
9-
10-
</head>
11-
12-
<body class="index">
13-
14-
<div id="container">
15-
<div class="picture">
16-
17-
<button type="button">Play</button>
18-
19-
<div id="moleOne" class="mole">
20-
</div>
21-
22-
<div id="moleTwo" class="mole">
23-
</div>
24-
25-
<div id="moleThree" class="mole">
26-
</div>
27-
28-
<div id="moleFour" class="mole">
29-
</div>
30-
31-
32-
33-
34-
35-
36-
</div>
37-
</div>
38-
39-
</body>
40-
41-
</html>
42-
43-
44-
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Index</title>
5+
6+
<link rel="stylesheet" href="styles.css" type="text/css">
7+
<script src="jquery-1.10.2.min.js" type="text/javascript"></script>
8+
<script src="script.js" type="text/javascript"></script>
9+
10+
</head>
11+
12+
<body class="index">
13+
14+
<div id="container">
15+
<div class="picture">
16+
17+
<div id="moleOne" class="mole">
18+
</div>
19+
20+
<div id="moleTwo" class="mole">
21+
</div>
22+
23+
<div id="moleThree" class="mole">
24+
</div>
25+
26+
<div id="moleFour" class="mole">
27+
</div>
28+
29+
30+
31+
32+
33+
34+
</div>
35+
</div>
36+
37+
</body>
38+
39+
</html>
40+
41+
42+

mallet.png

3.23 KB
Loading

script.js

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,29 @@
1-
$( document ).ready(function() {
2-
3-
4-
$("button").click(function() {
5-
var mole = $(".mole").toArray();
6-
var elemlength = mole.length;
7-
var randomnum = Math.floor(Math.random()*elemlength);
8-
var randomitem = mole[randomnum];
9-
$(randomitem).css("display", "block").addClass("active");
10-
});
11-
12-
13-
$(".mole").click(function() {
14-
15-
if ($(this).hasClass("active")) {
16-
$(this).css("display", "none").removeClass("active");
17-
}
18-
});
19-
20-
});
1+
$(document).on('ready',function(){
2+
setInterval(whaka,500);
3+
});
4+
5+
function whaka(){
6+
var mole = $(".mole").toArray();
7+
var elemlength = mole.length;
8+
var randomnum = Math.floor(Math.random()*elemlength);
9+
var randomitem = mole[randomnum];
10+
//$(randomitem).css("display", "block").addClass("active");
11+
$(randomitem).removeClass("explode").toggle().toggleClass("active");
12+
}
13+
14+
15+
$(document).ready(function(){
16+
17+
//$("#container").css( 'cursor', 'url(mallet.png), auto' );
18+
19+
$(".mole").click(function() {
20+
//alert("!! whaka !!");
21+
if ($(this).hasClass("active")) {
22+
$(this).css("display","none").addClass("explode");
23+
}
24+
});
25+
26+
});
27+
28+
29+

0 commit comments

Comments
 (0)