-
Notifications
You must be signed in to change notification settings - Fork 1
/
size-counts.html
219 lines (192 loc) · 9.34 KB
/
size-counts.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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Size Counts | BrainStorm</title>
<link href="http://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet">
<link rel="stylesheet" href="game-css.css" type="text/css">
<link rel="stylesheet" href="../Alert/alertcss.css">
<script src="games-js.js" type="text/javascript"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.js"></script>
<script type="text/javascript">
var i = 1;
var q1 = 1;
var q2 = 2;
var randomNum = 0;
var count = 0;
var img_value = [-1, 1, 0, 1, -1, 0, -1, 1, 1, 1, -1, 0, 1, 1, -1, 0, -1, -1, 1, 0]; //Answer array.
//Function for checking answer and generating new question image.
//Here argument -1 for upper image or 0 for equal or 1 for bottom image.
function checker(check) {
//max 20 question. i.e i<=20
if (i <= 20) {
if (check === img_value[randomNum]) { //verifying answer with array.
//score counting.
if (count > 750){count = count + 150;}
else if (count > 350 && count < 750){count = count + 100;}
else {count = count + 50;}
//If answer is correct the green tick mark will be blinked.
document.getElementById('flip-img').classList.add("on");
document.getElementById('correct').classList.add("on");
setTimeout(function(){
document.getElementById('correct').classList.remove("on");
document.getElementById('flip-img').classList.remove("on");
}, 200);
}
else {
// If answer is wrong the red cross will blink.
document.getElementById('flip-img').classList.add("on");
document.getElementById('wrong').classList.add("on");
setTimeout(function(){
document.getElementById('wrong').classList.remove("on");
document.getElementById('flip-img').classList.remove("on");
}, 200);
}
i++; //increment the question count.
randomNum = getRandomInt(0,19); //generation random number for selecting next question.
//changing the quetion image according to random number generated and changing the score as per the previous answer.
if (i <= 20) {
q1 = (2 * randomNum) + 1; //for odd numbered image.
q2 = (2 * randomNum) + 2; //for even numbered image.
document.getElementById('score').innerHTML = "" + count;
document.getElementById('score1').innerHTML = "" + count;
document.getElementById('scoreDB').value = count;
document.getElementById('image1').src = "size-counts-img/Picture" + q1 + ".png";
document.getElementById('image2').src = "size-counts-img/Picture" + q2 + ".png";
}
}
//Score card at the end of game.
if (i == 21) {
document.getElementById('score1').innerHTML = "" + count;
document.getElementById('scoreDB').value = count;
document.getElementById('main-screen').style.display = "none";
document.getElementById('end-screen').classList.add("on");
//checking for new best score of the game.
var score = 0;
if (score <= count){
document.getElementById('best-score').classList.add("on");
}
}
}
//If user leave the game in between then socre is 0.
function end_screen() {
document.getElementById('score1').innerHTML = "000";
}
</script>
<script type="text/javascript">
$(document).ready(function(){
var lastScore = $.cookie("sizeCount");
$("#lastScore").text(lastScore);
var per = $.cookie("probsol");
$("#per").text(per);
});
</script>
</head>
<body style="background-color: #004d40">
<div id="start-screen">
<div class="row">
<div class="col half-wider"><h1>Size Counts <span class="info">(PROBLEM SOLVING)</span></h1></div>
<div class="col half-narrow">
<a id="ON" class="btn-circle hoverable" onclick="video_on()"><i class="material-icons"></i></a>
<a id="OFF" class="btn-circle hoverable off" onclick="video_off()"><i class="material-icons"></i></a>
</div>
</div>
<video id="video" width="500" height="415" controls>
<source src="true-color-img/Rec.mp4" type="video/mp4">
</video>
<div id="info" class="card">
<div class="row">
<div class="col half">
<span class="material-icons blue-text"></span>
<span id="lastScore" class="num">7777</span>
<span class="info black-text">LAST SCORE</span>
</div>
<div class="col half">
<span class="material-icons blue-text"></span>
<span id="per" class="num">50%</span>
<span class="info black-text">PROBLEM SOLVING</span>
</div>
</div>
<div class="divider"></div>
<div class="row black-text left-align">
<span class="num"> GAME BENEFIT :</span>
<ul>
<li>Challenges your ability to perform basic calculations.</li>
<li>Challenges your estimation and number conversion skills.</li>
</ul>
</div>
<div class="row black-text left-align">
<span class="num"> Instructions <span class="info black-text">(click on info button for video)</span> :</span>
<ol>
<li>Determine which card is larger and tap on it.</li>
<li>If both cards are equal, tap the Equal button.</li>
</ol>
</div>
</div>
<a id="button-start" class="btn start hoverable">PLAY GAME</a>
</div>
<div id="main-screen" class="off">
<div class="row">
<span class="timer">
<a id="button-stop" class="btn pause left material-icons"></a>
<a id="button-play" class="btn pause left material-icons off"></a>
00:<span id="seconds">59</span>
<a id="score" class="btn score right">000</a>
</span>
</div>
<div id="wait-screen" class="card waiting">
<div class="waring">
<span class="waring-i"></span>
<span class="waring-dot"></span>
</div>
<h1 class="black-text">Are you sure to exit?</h1>
<span class="num black-text">You will not able to record your score!</span>
<div class="row" style="margin-top: 40px">
<a id="button-no" class="btn green">No</a>
<a class="btn red" onclick="end_screen(); flip_endCard();">Yes</a>
</div>
</div>
<div id="flip-img" class="card waiting transparent">
<a id="correct" class="btn-circle check green"><i class="material-icons"></i></a>
<a id="wrong" class="btn-circle check red"><i class="material-icons"></i></a>
</div>
<div class="center-align">
<img id="image1" class="sc-img" src="size-counts-img/Picture1.png" onclick="checker(-1)">
<img id="image" class="sc-img sc-equal" src="size-counts-img/equal.png" onclick="checker(0)">
<img id="image2" class="sc-img" src="size-counts-img/Picture2.png" onclick="checker(1)">
</div>
<br/>
<div class="center-align">
<a class="btn btn-info">which one is larger?</a>
</div>
</div>
<div id="end-screen" class="off">
<div class="card">
<div class="row">
<span id="best-score" class="num green-text off">BEST NEW SCORE</span>
<span class="material-icons blue-text"></span>
<h1 class="black-text" id="score1" style="margin: 0">000</h1>
<span class="info black-text">YOUR SCORE</span>
<div class="divider"></div>
<div class="card bg-green">
<div class="row left-align">
<span class="num white-text">SUCCESS RATE :</span>
<ul><span class="info">Your success rate is 72%. Well done!
Only 18% of the users at this rank do this well.</span></ul>
</div>
</div>
<div class="divider"></div>
</div>
<div class="row">
<form action="../gameScore" method="post">
<input name="gameId" type="hidden" value="sizecount">
<input name="score" id="scoreDB" type="hidden" value="0">
<input class="btn continue hoverable" type="submit" value="Continue"></input>
</form>
</div>
</div>
</div>
</body>
</html>