-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
170 lines (155 loc) · 4.86 KB
/
index.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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<!doctype html>
<html>
<head>
<title>Growing Bubbles</title>
<meta charset="utf-8" />
<link href='https://fonts.googleapis.com/css?family=Open+Sans+Condensed:300' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Indie+Flower' rel='stylesheet' type='text/css'>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script>
$(document).ready(function() {
// kill the ability to highlight things on the page, since that's annoying
function killCopy(e) {
return false;
}
function reEnable() {
return true;
}
document.onselectstart=new Function ("return false");
if (window.sidebar) {
document.onmousedown=killCopy;
document.onclick=reEnable;
}
// set up some variables I'll be needing
var colorsArray = ["blue","green","red"];
var round = 0;
var wrongClick = 0;
// this is the main loop
var showBubbles = setInterval(function(){
// increment the round number
round += 1;
document.getElementById("yourRound").innerHTML = round;
// make some new bubbles
for (i = 0; i < 4; i++) {
var theTop = Math.floor(Math.random()*440);
var theLeft = Math.floor(Math.random()*640);
var theColor = colorsArray[Math.floor(Math.random()*3)];
$("#container").append("<div class='bubble' style='top: " + theTop + "px; left: " + theLeft + "px; background-color: " + theColor + "'></div>");
}
// grow
$(".bubble").animate({
width: "+=40px",
height: "+=40px",
}, 2500);
// shrink
$( ".bubble" ).animate({
width: "0px",
height: "0px",
}, 1500);
// when a bubble is clickedl check if blue or not
$(".bubble").click(function(){
if (this.style.backgroundColor == "blue") {
$(this).hide();
} else {
clearInterval(showBubbles);
wrongClick = 1;
$(".bubble").stop(true, true);
this.style.zIndex = "3";
$(this).animate({
width: "10000px",
height: "10000px",
left: "-5000px",
top: "-5000px"
}, 5000);
var bgColor = this.style.backgroundColor;
setTimeout(function(){
document.getElementById("container").style.backgroundColor = bgColor;
document.getElementById("container").innerHTML = "<h2 class='gameOver'>You clicked the wrong bubble!</h2><br/><h2 class='again'>Play Again</h2>";
$(".again").click(function(){
location.reload();
});
}, 2000);
}
});
// if you miss a blue bubble
setTimeout(function(){
bubbleArray = document.getElementsByClassName("bubble");
if (wrongClick == 0) {
for (j = 0; j < bubbleArray.length; j++) {
if (bubbleArray[j].style.backgroundColor == "blue" & bubbleArray[j].style.display != "none") {
clearInterval(showBubbles);
$(".bubble").stop(true, true);
document.getElementById("container").style.backgroundColor = "blue";
document.getElementById("container").innerHTML = "<h2 class='gameOver'>You missed a blue one!</h2><br/><h2 class='again'>Play Again</h2>";
$(".again").click(function(){
location.reload();
});
}
}
}
}, 4000);
}, 5000);
});
</script>
<style>
body {
font-family: "Indie Flower", "Open Sans Condensed", sans-serif;
}
.bubble {
height:0px;
width: 0px;
background: blue;
border-radius: 2500px;
position: absolute;
}
#container {
height: 500px;
width: 700px;
margin: auto;
position: relative;
background: #f2f2f2;
border-radius: 10px;
overflow: hidden;
text-align: center;
}
#container h2 {
color: #FFF;
position: relative;
}
#container .gameOver {
top: 170px;
}
#container .again {
border: solid 2px #FFF;
border-radius: 4px;
top: 120px;
display: inline-block;
padding: 10px 30px;
cursor: pointer;
}
#header, #instructions {
margin: auto;
text-align: center;
}
#header h1 {
margin: 3px auto;
}
.color {
color: blue;
}
</style>
</head>
<body>
<iframe width="0px" height="0px" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/playlists/17319478&auto_play=true&hide_related=false&show_comments=true&show_user=true&show_reposts=false&visual=true"></iframe>
<div id="header">
<h1>Growing Bubbles</h1>
</div>
<div id="container"></div>
<div id="instructions">
<span>Click only the bubbles that are</span>
<span class="color">BLUE</span>
<span>. Don't leave any of the <span class="color">BLUE</span> bubbles on the screen!</span>
<p>Round: <span id="yourRound">1</span></p>
</div>
</body>
</html>