-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
339 lines (292 loc) · 8.72 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
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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;700&family=Roboto:wght@400;700&display=swap" rel="stylesheet">
<style>
#counter1 {
background-color: #3498db;
color: #fff;
padding: 10px 20px;
border-radius: 5px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
display: flex;
justify-content: flex-end;
align-items: flex-end;
height: 100vh;
padding: 20px;
}
#visit-count {
font-weight: bold;
margin-left: 10px;
}
/* Your improved score page CSS goes here */
body {
font-family: 'Poppins', sans-serif;
background-color: #007bff; /* Deep blue background */
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}
#introWindow {
text-align: center;
background-color: rgba(255, 255, 255, 0.8); /* Semi-transparent white background */
border-radius: 10px;
box-shadow: 0 0 20px rgba(0, 0, 0, 0.4);
padding: 20px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
z-index: 9999;
animation: fadeIn 1s ease-in-out;
}
@keyframes fadeIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
h1 {
font-size: 32px;
color: #fff; /* White text */
margin-bottom: 20px;
}
p {
font-size: 18px;
color: #333; /* Dark text color */
margin-top: 20px;
}
ul {
list-style: none;
padding: 0;
}
li {
font-size: 18px;
color: #007bff; /* Deep blue text for instructions */
margin: 10px 0;
}
/* Keyframes for fade-in and slide-up animations */
@keyframes fade-in {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
@keyframes slide-up {
0% {
transform: translateY(50px);
}
100% {
transform: translateY(0);
}
}
body, html {
padding: 0;
margin: 0;
overscroll-behavior: none;
overflow: hidden;
}
.slider {
position: fixed;
bottom: 5%;
left: 50%;
transform: translateX(-50%);
width: 150px;
color: white;
font-family: sans-serif;
text-align: right;
}
.slider input {
width: 100%;
margin-bottom: 5px;
cursor: pointer;
}
#highlight {
font-size: 24px;
font-weight: bold;
margin-top: 20px;
position: relative;
}
#highlight::before {
content: "";
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(255, 234, 0, 0.5); /* Yellowish background color with opacity */
border-radius: 5px; /* Rounded corners */
z-index: -1; /* Behind the text */
}
#highlight-text {
color: #333; /* Text color */
position: relative;
z-index: 1; /* Above the background */
}
#heading {
font-size: 36px;
color: #ffea00; /* Yellow text color */
font-weight: bold;
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2); /* Text shadow for depth */
margin-bottom: 20px;
text-align: center; /* Center the text horizontally */
position: relative; /* Position for animation */
}
/* Add a rotating animation */
@keyframes rotate {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
/* Apply the animation to the heading */
#heading::after {
content: "\f12e"; /* Unicode for a play icon (you can replace it with any other icon) */
font-family: FontAwesome; /* Use a font icon library like FontAwesome */
font-size: 44px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
opacity: 0; /* Start with zero opacity */
transition: opacity 0.5s ease-in-out; /* Add a smooth fade-in transition */
}
/* Hover animation */
#heading:hover::after {
opacity: 1; /* On hover, make the icon visible */
animation: rotate 2s linear infinite; /* Add a rotating animation on hover */
}
</style>
<title>Eyes Test Game</title>
</head>
<body>
<canvas id="stars"></canvas>
<div class="slider">
<input type="range" min="0.5" max="15" value="2" step="0.5">
</div>
<div id="introWindow">
<h1 id="heading">Welcome to the Color Blindness Test Game
</h1>
<p>Instructions:</p>
<ul>
<li>This test is designed to check your color vision.</li>
<li>Click on the buttons that match the color shown in the center of the screen.</li>
<li>Score points for each correct answer.</li>
<li>Try to achieve the highest score possible.</li>
</ul>
<p>Why This Test is Important:</p>
<p>Color blindness can impact your daily life, so it's important to be aware of it.</p>
<p>Motivation for This Project:</p>
<p>We aim to raise awareness about color blindness and its effects on people's lives.</p>
<p id="highlight">
<span id="highlight-text">The game will start in 10 seconds. Good luck!</span>
</p>
<div class="website-counter">
<span id="visit-count"></span>
</div>
</div>
</div>
<script>
// Code to close the intro window after 10 seconds and start the game
setTimeout(function () {
const introWindow = document.getElementById('introWindow');
introWindow.style.animation = 'slide-down 1s ease-out'; // Slide down animation before hiding
setTimeout(function () {
introWindow.style.display = 'none'; // Hide the intro window
// Add code here to start the game or navigate to the game page
window.location.href = 'index1.html'; //
}, 1000); // 1000 milliseconds = 1 second
}, 10000); // 10000 milliseconds = 10 seconds
const canvas = document.getElementById("stars");
const ctx = canvas.getContext("2d");
const slider = document.querySelector(".slider input");
let screen, stars, params = {speed: 2, number: 300, extinction: 4};
setupStars();
updateStars();
slider.oninput = function () {
params.speed = this.value;
};
// update stars on resize to keep the thing centered
window.onresize = function () {
setupStars();
};
// star constructor
function Star() {
this.x = Math.random() * canvas.width;
this.y = Math.random() * canvas.height;
this.z = Math.random() * canvas.width;
this.move = function () {
this.z -= params.speed;
if (this.z <= 0) {
this.z = canvas.width;
}
};
this.show = function () {
let x, y, rad, opacity;
x = (this.x - screen.c[0]) * (canvas.width / this.z);
x = x + screen.c[0];
y = (this.y - screen.c[1]) * (canvas.width / this.z);
y = y + screen.c[1];
rad = canvas.width / this.z;
opacity = (rad > params.extinction) ? 1.5 * (2 - rad / params.extinction) : 1;
ctx.beginPath();
ctx.fillStyle = "rgba(255, 255, 255, " + opacity + ")";
ctx.arc(x, y, rad, 0, Math.PI * 2);
ctx.fill();
}
}
// setup <canvas>, create all the starts
function setupStars() {
screen = {
w: window.innerWidth,
h: window.innerHeight,
c: [window.innerWidth * 0.5, window.innerHeight * 0.5]
};
window.cancelAnimationFrame(updateStars);
canvas.width = screen.w;
canvas.height = screen.h;
stars = [];
for (let i = 0; i < params.number; i++) {
stars[i] = new Star();
}
}
function updateStars() {
ctx.fillStyle = "black";
ctx.fillRect(0, 0, canvas.width, canvas.height);
stars.forEach(function (s) {
s.show();
s.move();
});
window.requestAnimationFrame(updateStars);
}
var counterContainer = document.querySelector(".website-counter");
var resetButton = document.querySelector("#reset");
var visitCount = localStorage.getItem("page_view");
// Check if page_view entry is present
if (visitCount) {
visitCount = Number(visitCount) + 1;
localStorage.setItem("page_view", visitCount);
} else {
visitCount = 1;
localStorage.setItem("page_view", 1);
}
counterContainer.innerHTML = visitCount;
// Adding onClick event listener
resetButton.addEventListener("click", () => {
visitCount = 1;
localStorage.setItem("page_view", 1);
counterContainer.innerHTML = visitCount;
});
</script>
</body>
</html>