forked from brilliant7769/skyhighchessleague.com
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathareyoubored.html
More file actions
293 lines (251 loc) · 8.92 KB
/
areyoubored.html
File metadata and controls
293 lines (251 loc) · 8.92 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
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
289
290
291
292
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Are You Bored? - Sky High Chess League</title>
<style>
body {
background: linear-gradient(to bottom, #00f, #0ff);
color: #fff;
text-align: center;
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
}
h2 {
margin-top: 20px;
}
.games-section {
margin-top: 30px;
}
.game-banner {
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
margin-bottom: 20px;
}
.game-banner img {
width: 200px;
height: auto;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
margin-bottom: 10px;
}
.game-banner button {
padding: 10px 20px;
font-size: 1em;
background-color: #ffcc00;
border: none;
border-radius: 5px;
cursor: pointer;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
}
.game-banner button:hover {
background-color: #e6b800;
}
#game-board, #rps-game, #guess-game {
display: none; /* Initially hidden */
margin: 20px auto;
}
#game-board {
display: grid;
grid-template-columns: repeat(3, 100px);
grid-template-rows: repeat(3, 100px);
gap: 10px;
justify-content: center;
}
.cell {
width: 100px;
height: 100px;
background-color: #fff;
color: #000;
font-size: 2em;
display: flex;
justify-content: center;
align-items: center;
cursor: pointer;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
}
#rps-result, #guess-result {
margin-top: 10px;
font-size: 1.2em;
}
input[type="text"] {
padding: 10px;
font-size: 1em;
margin-top: 10px;
}
button {
padding: 10px 20px;
font-size: 1em;
margin-top: 10px;
cursor: pointer;
border: none;
border-radius: 5px;
background-color: #ffcc00;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
}
button:hover {
background-color: #e6b800;
}
.back-home {
margin-top: 20px;
}
</style>
</head>
<body>
<h2>Are You Bored?</h2>
<p>Try some of these fun games to pass the time!</p>
<div class="games-section">
<!-- Tic-Tac-Toe Game -->
<div class="game-banner">
<img src="https://i.postimg.cc/ZvztK9nc/tic-tac-toe.jpg" alt="Tic-Tac-Toe">
<button onclick="showTicTacToe()">Play Tic-Tac-Toe</button>
</div>
<!-- Rock-Paper-Scissors Game -->
<div class="game-banner">
<img src="https://i.postimg.cc/hX9mB45x/rock-paper-scissors.jpg" alt="Rock-Paper-Scissors">
<button onclick="showRPSGame()">Play Rock-Paper-Scissors</button>
</div>
<!-- Number Guessing Game -->
<div class="game-banner">
<img src="https://i.postimg.cc/jWPZBrzk/guessing-game.jpg" alt="Guessing Game">
<button onclick="showGuessGame()">Play Number Guessing Game</button>
</div>
</div>
<!-- Tic-Tac-Toe Game Board -->
<div id="game-board">
<!-- Tic-Tac-Toe game board will be generated here -->
</div>
<div id="status"></div>
<!-- Rock-Paper-Scissors Game -->
<div id="rps-game">
<h3>Rock-Paper-Scissors</h3>
<button onclick="playRPS('rock')">Rock</button>
<button onclick="playRPS('paper')">Paper</button>
<button onclick="playRPS('scissors')">Scissors</button>
<div id="rps-result"></div>
</div>
<!-- Number Guessing Game -->
<div id="guess-game">
<h3>Number Guessing Game</h3>
<p>Guess a number between 1 and 100</p>
<input type="text" id="guess-input">
<button onclick="checkGuess()">Submit Guess</button>
<div id="guess-result"></div>
</div>
<!-- Back to Home Button -->
<div class="back-home">
<button onclick="backHome()">Back to Home</button>
</div>
<script>
const boardElement = document.getElementById('game-board');
const statusElement = document.getElementById('status');
const cells = Array(9).fill(null);
let currentPlayer = 'X';
let isGameActive = true;
function showTicTacToe() {
hideAllGames();
createBoard();
boardElement.style.display = 'grid';
statusElement.style.display = 'block';
statusElement.textContent = `Player ${currentPlayer}'s turn`;
}
function createBoard() {
boardElement.innerHTML = '';
cells.forEach((cell, index) => {
const cellElement = document.createElement('div');
cellElement.classList.add('cell');
cellElement.dataset.index = index;
cellElement.addEventListener('click', handleCellClick);
boardElement.appendChild(cellElement);
});
}
function handleCellClick(event) {
const cellElement = event.target;
const index = cellElement.dataset.index;
if (cells[index] !== null || !isGameActive) {
return;
}
cells[index] = currentPlayer;
cellElement.textContent = currentPlayer;
if (checkWinner()) {
statusElement.textContent = `Player ${currentPlayer} wins!`;
isGameActive = false;
} else if (cells.every(cell => cell !== null)) {
statusElement.textContent = 'Draw!';
isGameActive = false;
} else {
currentPlayer = currentPlayer === 'X' ? 'O' : 'X';
statusElement.textContent = `Player ${currentPlayer}'s turn`;
}
}
function checkWinner() {
const winningCombinations = [
[0, 1, 2],
[3, 4, 5],
[6, 7, 8],
[0, 3, 6],
[1, 4, 7],
[2, 5, 8],
[0, 4, 8],
[2, 4, 6]
];
return winningCombinations.some(combination => {
const [a, b, c] = combination;
return cells[a] !== null && cells[a] === cells[b] && cells[a] === cells[c];
});
}
function showRPSGame() {
hideAllGames();
document.getElementById('rps-game').style.display = 'block';
}
function playRPS(userChoice) {
const choices = ['rock', 'paper', 'scissors'];
const computerChoice = choices[Math.floor(Math.random() * choices.length)];
let result = '';
if (userChoice === computerChoice) {
result = "It's a draw!";
} else if (
(userChoice === 'rock' && computerChoice === 'scissors') ||
(userChoice === 'paper' && computerChoice === 'rock') ||
(userChoice === 'scissors' && computerChoice === 'paper')
) {
result = 'You win!';
} else {
result = 'You lose!';
}
document.getElementById('rps-result').textContent = `You chose ${userChoice}, computer chose ${computerChoice}. ${result}`;
}
function showGuessGame() {
hideAllGames();
document.getElementById('guess-game').style.display = 'block';
}
const randomNumber = Math.floor(Math.random() * 100) + 1;
function checkGuess() {
const userGuess = parseInt(document.getElementById('guess-input').value);
let result = '';
if (userGuess === randomNumber) {
result = 'Congratulations! You guessed the right number!';
} else if (userGuess < randomNumber) {
result = 'Too low! Try again.';
} else if (userGuess > randomNumber) {
result = 'Too high! Try again.';
}
document.getElementById('guess-result').textContent = result;
}
function hideAllGames() {
boardElement.style.display = 'none';
statusElement.style.display = 'none';
document.getElementById('rps-game').style.display = 'none';
document.getElementById('guess-game').style.display = 'none';
}
function backHome() {
window.location.href = 'index.html'; // Navigate back to homepage
}
</script>
</body>
</html>