-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
98 lines (74 loc) · 2.08 KB
/
index.js
File metadata and controls
98 lines (74 loc) · 2.08 KB
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
function randomize_start_postion(element){
console.log("randomize");
var posx = (Math.random() * ($(document).width() - ".hidden-object")).toFixed();
var posy = (Math.random() * ($(document).height() - ".hidden-object")).toFixed();
$(this).css({
'left':posx+'px',
'top':posy+'px',
})
}
randomize_start_postion("hidden-wrench");
randomize_start_postion("hidden-fuel");
randomize_start_postion("hidden-rocket");
$('#hidden-wrench').click(function() {
console.log("clicked wrench");
$(this).remove()
$('#wrench').addClass('completed');
check_complete();
})
$('#hidden-fuel').click(function() {
console.log("clicked fuel");
$(this).remove()
$('#fuel').addClass('completed');
check_complete();
})
$('#hidden-rocket').click(function() {
console.log("clicked rocket");
$(this).remove()
$('#rocket').addClass('completed');
check_complete();
})
$('.nav').click(function() {
var current_view = $("#visor").attr("class");
var direction = $(this).attr("id");
var new_class = navigate_to(current_view, direction);
$("#visor").removeClass();
$("#visor").addClass(new_class);
});
function navigate_to(current_view, direction){
var nav_class;
if(current_view === "earth") {
if (direction === "right") {
nav_class="rover";
} else {
nav_class="desert";
}
}
if(current_view === "rover") {
if (direction === "left") {
nav_class="earth";
} else {
nav_class = current_view;
}
}
if(current_view === "desert") {
if (direction === "right") {
nav_class="earth";
} else {
nav_class = current_view;
}
}
return nav_class;
}
function check_complete() {
var length = $('.completed').length;
if(length == 3) {
blastoff();
}
}
function blastoff(){
console.log("winner winner chicken dinner!");
$("#visor").removeClass();
$('#visor').addClass('blastoff');
document.getElementById("song").play();
}