forked from YangKaty/SpaceHackathon
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathscript.js
70 lines (54 loc) · 1.64 KB
/
script.js
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
$(document).ready(function(){
var status="waiting";
var score= 0;
var ping = new Audio();
ping.src = "music.mp3";
var fail = new Audio();
fail.src = "fail.mp3";
var tada = new Audio();
tada.src = "tada.mp3";
$('.planet').mouseenter( function(){
if (status == "started") {
fail.play();
// $('#score').text("GAME OVER! Score: " + score);
status = "lost";
$('#button').show();
$.featherlight("lose.html");
}
});
document.clickStart = function(){
if (status != "started") {
status = "started";
score = 0;
resize();
ping.play();
$('#score').text("Score: " + score);
$('.collect').show();
$('#button').hide();
} else {
alert("You have already started");
}
};
function resize() {
if (status == "started") {
$('.planet').animate({width:'-=20px',height:'-=20px'},"slow");
$('.planet').animate({width:'+=20px',height:'+=20px'},"slow",resize);
}
}
$('.collect').mouseenter(function(event){
if (status == "started"){
score = score + 1;
$('#score').text("Score: " + score);
$(event.target).hide();
}
});
$('#earth').mouseenter(function(){
if (status == "started") {
tada.play();
// $('#score').text("YOU HAVE WON!! Your score is " + score);
status = "won";
$.featherlight("win.html");
}
$('#button').show();
});
});