AramTM commited on
Commit
2276d3c
·
verified ·
1 Parent(s): d328a2f

Start invite 3 web games - Initial Deployment

Browse files
Files changed (2) hide show
  1. README.md +7 -5
  2. index.html +452 -19
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
- title: Armgame
3
- emoji: 🦀
4
- colorFrom: indigo
5
- colorTo: purple
6
  sdk: static
7
  pinned: false
 
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: armgame
3
+ emoji: 🐳
4
+ colorFrom: purple
5
+ colorTo: red
6
  sdk: static
7
  pinned: false
8
+ tags:
9
+ - deepsite
10
  ---
11
 
12
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
index.html CHANGED
@@ -1,19 +1,452 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>3 Fun Web Games</title>
7
+ <script src="https://cdn.tailwindcss.com"></script>
8
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
9
+ <style>
10
+ /* Custom styles for the snake game */
11
+ #snakeCanvas {
12
+ border: 2px solid #4b5563;
13
+ border-radius: 0.5rem;
14
+ background-color: #1f2937;
15
+ }
16
+
17
+ /* Game card hover effect */
18
+ .game-card:hover {
19
+ transform: translateY(-5px);
20
+ box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
21
+ }
22
+
23
+ /* Memory card flip animation */
24
+ .memory-card {
25
+ perspective: 1000px;
26
+ }
27
+
28
+ .memory-card-inner {
29
+ transition: transform 0.6s;
30
+ transform-style: preserve-3d;
31
+ }
32
+
33
+ .memory-card.flipped .memory-card-inner {
34
+ transform: rotateY(180deg);
35
+ }
36
+
37
+ .memory-card-front, .memory-card-back {
38
+ backface-visibility: hidden;
39
+ position: absolute;
40
+ width: 100%;
41
+ height: 100%;
42
+ }
43
+
44
+ .memory-card-back {
45
+ transform: rotateY(180deg);
46
+ }
47
+
48
+ /* Tic-tac-toe cell hover */
49
+ .ttt-cell:hover:not(.occupied) {
50
+ background-color: #e5e7eb;
51
+ }
52
+ </style>
53
+ </head>
54
+ <body class="bg-gray-100 min-h-screen">
55
+ <div class="container mx-auto px-4 py-8">
56
+ <header class="text-center mb-12">
57
+ <h1 class="text-4xl md:text-5xl font-bold text-indigo-700 mb-4">Fun Web Games</h1>
58
+ <p class="text-lg text-gray-600 max-w-2xl mx-auto">Three classic games to challenge your skills and memory!</p>
59
+ </header>
60
+
61
+ <!-- Game Selection Tabs -->
62
+ <div class="flex justify-center mb-8">
63
+ <div class="inline-flex rounded-md shadow-sm" role="group">
64
+ <button onclick="showGame('tic-tac-toe')" class="px-4 py-2 text-sm font-medium rounded-l-lg bg-indigo-600 text-white hover:bg-indigo-700 focus:z-10 focus:ring-2 focus:ring-indigo-500">
65
+ <i class="fas fa-times mr-2"></i>Tic-Tac-Toe
66
+ </button>
67
+ <button onclick="showGame('memory')" class="px-4 py-2 text-sm font-medium bg-indigo-100 text-indigo-700 hover:bg-indigo-200 focus:z-10 focus:ring-2 focus:ring-indigo-500">
68
+ <i class="fas fa-brain mr-2"></i>Memory Game
69
+ </button>
70
+ <button onclick="showGame('snake')" class="px-4 py-2 text-sm font-medium rounded-r-lg bg-indigo-100 text-indigo-700 hover:bg-indigo-200 focus:z-10 focus:ring-2 focus:ring-indigo-500">
71
+ <i class="fas fa-snake mr-2"></i>Snake
72
+ </button>
73
+ </div>
74
+ </div>
75
+
76
+ <!-- Game Containers -->
77
+ <div class="space-y-12">
78
+ <!-- Tic-Tac-Toe Game -->
79
+ <div id="tic-tac-toe" class="game-container bg-white rounded-xl shadow-lg p-6 max-w-md mx-auto">
80
+ <div class="flex justify-between items-center mb-6">
81
+ <h2 class="text-2xl font-bold text-indigo-700">Tic-Tac-Toe</h2>
82
+ <button onclick="resetTicTacToe()" class="px-3 py-1 bg-indigo-100 text-indigo-700 rounded hover:bg-indigo-200 transition">
83
+ <i class="fas fa-redo mr-1"></i> Reset
84
+ </button>
85
+ </div>
86
+ <div class="text-center mb-4">
87
+ <p id="ttt-status" class="text-lg font-medium">Player X's turn</p>
88
+ </div>
89
+ <div class="grid grid-cols-3 gap-2 mb-4">
90
+ <!-- Tic-Tac-Toe cells will be generated by JavaScript -->
91
+ </div>
92
+ <div class="text-center">
93
+ <p class="text-sm text-gray-500">X wins: <span id="x-wins">0</span> | O wins: <span id="o-wins">0</span> | Draws: <span id="draws">0</span></p>
94
+ </div>
95
+ </div>
96
+
97
+ <!-- Memory Game -->
98
+ <div id="memory" class="game-container hidden bg-white rounded-xl shadow-lg p-6 max-w-2xl mx-auto">
99
+ <div class="flex justify-between items-center mb-6">
100
+ <h2 class="text-2xl font-bold text-indigo-700">Memory Card Game</h2>
101
+ <div class="flex items-center space-x-4">
102
+ <span class="text-gray-700">Moves: <span id="moves">0</span></span>
103
+ <span class="text-gray-700">Pairs: <span id="pairs">0</span>/8</span>
104
+ <button onclick="resetMemoryGame()" class="px-3 py-1 bg-indigo-100 text-indigo-700 rounded hover:bg-indigo-200 transition">
105
+ <i class="fas fa-redo mr-1"></i> Reset
106
+ </button>
107
+ </div>
108
+ </div>
109
+ <div class="grid grid-cols-2 sm:grid-cols-4 gap-4">
110
+ <!-- Memory cards will be generated by JavaScript -->
111
+ </div>
112
+ </div>
113
+
114
+ <!-- Snake Game -->
115
+ <div id="snake" class="game-container hidden bg-white rounded-xl shadow-lg p-6 max-w-md mx-auto">
116
+ <div class="flex justify-between items-center mb-6">
117
+ <h2 class="text-2xl font-bold text-indigo-700">Snake Game</h2>
118
+ <div class="flex items-center space-x-4">
119
+ <span class="text-gray-700">Score: <span id="score">0</span></span>
120
+ <button onclick="resetSnakeGame()" class="px-3 py-1 bg-indigo-100 text-indigo-700 rounded hover:bg-indigo-200 transition">
121
+ <i class="fas fa-redo mr-1"></i> Reset
122
+ </button>
123
+ </div>
124
+ </div>
125
+ <canvas id="snakeCanvas" width="400" height="400"></canvas>
126
+ <div class="mt-4 text-center text-sm text-gray-500">
127
+ <p>Use arrow keys or WASD to control the snake</p>
128
+ </div>
129
+ </div>
130
+ </div>
131
+ </div>
132
+
133
+ <script>
134
+ // Show the selected game and hide others
135
+ function showGame(gameId) {
136
+ document.querySelectorAll('.game-container').forEach(el => {
137
+ el.classList.add('hidden');
138
+ });
139
+ document.getElementById(gameId).classList.remove('hidden');
140
+
141
+ // Update tab styling
142
+ document.querySelectorAll('[role="group"] button').forEach(btn => {
143
+ btn.classList.remove('bg-indigo-600', 'text-white');
144
+ btn.classList.add('bg-indigo-100', 'text-indigo-700');
145
+ });
146
+ event.currentTarget.classList.remove('bg-indigo-100', 'text-indigo-700');
147
+ event.currentTarget.classList.add('bg-indigo-600', 'text-white');
148
+
149
+ // If showing snake game, focus the canvas
150
+ if (gameId === 'snake') {
151
+ document.getElementById('snakeCanvas').focus();
152
+ }
153
+ }
154
+
155
+ // Initialize with Tic-Tac-Toe visible
156
+ document.addEventListener('DOMContentLoaded', function() {
157
+ showGame('tic-tac-toe');
158
+ initTicTacToe();
159
+ initMemoryGame();
160
+ initSnakeGame();
161
+ });
162
+
163
+ // ==================== TIC-TAC-TOE GAME ====================
164
+ let currentPlayer = 'X';
165
+ let gameState = ['', '', '', '', '', '', '', '', ''];
166
+ let gameActive = true;
167
+ let xWins = 0;
168
+ let oWins = 0;
169
+ let draws = 0;
170
+
171
+ const winningConditions = [
172
+ [0, 1, 2], [3, 4, 5], [6, 7, 8], // rows
173
+ [0, 3, 6], [1, 4, 7], [2, 5, 8], // columns
174
+ [0, 4, 8], [2, 4, 6] // diagonals
175
+ ];
176
+
177
+ function initTicTacToe() {
178
+ const board = document.querySelector('#tic-tac-toe .grid');
179
+ board.innerHTML = '';
180
+
181
+ for (let i = 0; i < 9; i++) {
182
+ const cell = document.createElement('div');
183
+ cell.classList.add('ttt-cell', 'h-24', 'flex', 'items-center', 'justify-center', 'text-4xl', 'font-bold', 'border-2', 'border-gray-300', 'cursor-pointer', 'transition');
184
+ cell.setAttribute('data-index', i);
185
+ cell.addEventListener('click', handleCellClick);
186
+ board.appendChild(cell);
187
+ }
188
+
189
+ resetTicTacToe();
190
+ }
191
+
192
+ function handleCellClick() {
193
+ const clickedCell = event.target;
194
+ const clickedCellIndex = parseInt(clickedCell.getAttribute('data-index'));
195
+
196
+ if (gameState[clickedCellIndex] !== '' || !gameActive) return;
197
+
198
+ gameState[clickedCellIndex] = currentPlayer;
199
+ clickedCell.textContent = currentPlayer;
200
+ clickedCell.classList.add('occupied');
201
+
202
+ checkResult();
203
+ }
204
+
205
+ function checkResult() {
206
+ let roundWon = false;
207
+
208
+ for (let i = 0; i < winningConditions.length; i++) {
209
+ const [a, b, c] = winningConditions[i];
210
+
211
+ if (gameState[a] === '' || gameState[b] === '' || gameState[c] === '') continue;
212
+
213
+ if (gameState[a] === gameState[b] && gameState[b] === gameState[c]) {
214
+ roundWon = true;
215
+ break;
216
+ }
217
+ }
218
+
219
+ if (roundWon) {
220
+ document.getElementById('ttt-status').textContent = `Player ${currentPlayer} wins!`;
221
+ gameActive = false;
222
+
223
+ if (currentPlayer === 'X') {
224
+ xWins++;
225
+ document.getElementById('x-wins').textContent = xWins;
226
+ } else {
227
+ oWins++;
228
+ document.getElementById('o-wins').textContent = oWins;
229
+ }
230
+
231
+ return;
232
+ }
233
+
234
+ const roundDraw = !gameState.includes('');
235
+ if (roundDraw) {
236
+ document.getElementById('ttt-status').textContent = 'Game ended in a draw!';
237
+ gameActive = false;
238
+ draws++;
239
+ document.getElementById('draws').textContent = draws;
240
+ return;
241
+ }
242
+
243
+ currentPlayer = currentPlayer === 'X' ? 'O' : 'X';
244
+ document.getElementById('ttt-status').textContent = `Player ${currentPlayer}'s turn`;
245
+ }
246
+
247
+ function resetTicTacToe() {
248
+ currentPlayer = 'X';
249
+ gameState = ['', '', '', '', '', '', '', '', ''];
250
+ gameActive = true;
251
+ document.getElementById('ttt-status').textContent = `Player ${currentPlayer}'s turn`;
252
+
253
+ document.querySelectorAll('.ttt-cell').forEach(cell => {
254
+ cell.textContent = '';
255
+ cell.classList.remove('occupied', 'bg-green-100');
256
+ });
257
+ }
258
+
259
+ // ==================== MEMORY GAME ====================
260
+ const memoryCards = [
261
+ 'fa-cat', 'fa-dog', 'fa-horse', 'fa-fish',
262
+ 'fa-dragon', 'fa-kiwi-bird', 'fa-spider', 'fa-frog',
263
+ 'fa-cat', 'fa-dog', 'fa-horse', 'fa-fish',
264
+ 'fa-dragon', 'fa-kiwi-bird', 'fa-spider', 'fa-frog'
265
+ ];
266
+
267
+ let hasFlippedCard = false;
268
+ let lockBoard = false;
269
+ let firstCard, secondCard;
270
+ let moves = 0;
271
+ let pairsFound = 0;
272
+
273
+ function initMemoryGame() {
274
+ const board = document.querySelector('#memory .grid');
275
+ board.innerHTML = '';
276
+
277
+ // Shuffle cards
278
+ const shuffledCards = [...memoryCards].sort(() => 0.5 - Math.random());
279
+
280
+ shuffledCards.forEach((card, index) => {
281
+ const cardElement = document.createElement('div');
282
+ cardElement.classList.add('memory-card', 'h-24', 'cursor-pointer');
283
+ cardElement.setAttribute('data-card', card);
284
+ cardElement.setAttribute('data-index', index);
285
+
286
+ const cardInner = document.createElement('div');
287
+ cardInner.classList.add('memory-card-inner', 'relative', 'w-full', 'h-full');
288
+
289
+ const cardFront = document.createElement('div');
290
+ cardFront.classList.add('memory-card-front', 'bg-indigo-600', 'rounded-lg', 'flex', 'items-center', 'justify-center');
291
+
292
+ const cardBack = document.createElement('div');
293
+ cardBack.classList.add('memory-card-back', 'bg-white', 'border-2', 'border-indigo-300', 'rounded-lg', 'flex', 'items-center', 'justify-center');
294
+
295
+ const icon = document.createElement('i');
296
+ icon.classList.add('fas', card, 'text-3xl', 'text-indigo-700');
297
+
298
+ cardBack.appendChild(icon);
299
+ cardInner.appendChild(cardFront);
300
+ cardInner.appendChild(cardBack);
301
+ cardElement.appendChild(cardInner);
302
+
303
+ cardElement.addEventListener('click', flipCard);
304
+ board.appendChild(cardElement);
305
+ });
306
+
307
+ resetMemoryGame();
308
+ }
309
+
310
+ function flipCard() {
311
+ if (lockBoard) return;
312
+ if (this === firstCard) return;
313
+
314
+ this.classList.add('flipped');
315
+
316
+ if (!hasFlippedCard) {
317
+ hasFlippedCard = true;
318
+ firstCard = this;
319
+ return;
320
+ }
321
+
322
+ secondCard = this;
323
+ moves++;
324
+ document.getElementById('moves').textContent = moves;
325
+ checkForMatch();
326
+ }
327
+
328
+ function checkForMatch() {
329
+ const isMatch = firstCard.getAttribute('data-card') === secondCard.getAttribute('data-card');
330
+
331
+ if (isMatch) {
332
+ disableCards();
333
+ pairsFound++;
334
+ document.getElementById('pairs').textContent = pairsFound;
335
+
336
+ if (pairsFound === 8) {
337
+ setTimeout(() => {
338
+ alert(`Congratulations! You won in ${moves} moves!`);
339
+ }, 500);
340
+ }
341
+ } else {
342
+ unflipCards();
343
+ }
344
+ }
345
+
346
+ function disableCards() {
347
+ firstCard.removeEventListener('click', flipCard);
348
+ secondCard.removeEventListener('click', flipCard);
349
+
350
+ resetBoard();
351
+ }
352
+
353
+ function unflipCards() {
354
+ lockBoard = true;
355
+
356
+ setTimeout(() => {
357
+ firstCard.classList.remove('flipped');
358
+ secondCard.classList.remove('flipped');
359
+
360
+ resetBoard();
361
+ }, 1000);
362
+ }
363
+
364
+ function resetBoard() {
365
+ [hasFlippedCard, lockBoard] = [false, false];
366
+ [firstCard, secondCard] = [null, null];
367
+ }
368
+
369
+ function resetMemoryGame() {
370
+ document.querySelectorAll('.memory-card').forEach(card => {
371
+ card.classList.remove('flipped');
372
+ card.addEventListener('click', flipCard);
373
+ });
374
+
375
+ moves = 0;
376
+ pairsFound = 0;
377
+ document.getElementById('moves').textContent = '0';
378
+ document.getElementById('pairs').textContent = '0';
379
+
380
+ setTimeout(() => {
381
+ // Re-shuffle cards
382
+ const cards = Array.from(document.querySelectorAll('.memory-card'));
383
+ const shuffledIndices = [...Array(cards.length).keys()].sort(() => 0.5 - Math.random());
384
+
385
+ const board = document.querySelector('#memory .grid');
386
+ board.innerHTML = '';
387
+
388
+ shuffledIndices.forEach(index => {
389
+ board.appendChild(cards[index]);
390
+ });
391
+ }, 500);
392
+ }
393
+
394
+ // ==================== SNAKE GAME ====================
395
+ let snakeGame;
396
+ let snake = [];
397
+ let food = {};
398
+ let direction = 'right';
399
+ let nextDirection = 'right';
400
+ let score = 0;
401
+ let gameInterval;
402
+ let gridSize = 20;
403
+ let canvasSize = 400;
404
+
405
+ function initSnakeGame() {
406
+ const canvas = document.getElementById('snakeCanvas');
407
+ snakeGame = canvas.getContext('2d');
408
+
409
+ // Set canvas size for high DPI displays
410
+ const scale = window.devicePixelRatio || 1;
411
+ canvas.style.width = canvasSize + 'px';
412
+ canvas.style.height = canvasSize + 'px';
413
+ canvas.width = canvasSize * scale;
414
+ canvas.height = canvasSize * scale;
415
+ snakeGame.scale(scale, scale);
416
+
417
+ resetSnakeGame();
418
+ }
419
+
420
+ function resetSnakeGame() {
421
+ clearInterval(gameInterval);
422
+
423
+ // Initial snake
424
+ snake = [
425
+ {x: 10, y: 10},
426
+ {x: 9, y: 10},
427
+ {x: 8, y: 10}
428
+ ];
429
+
430
+ direction = 'right';
431
+ nextDirection = 'right';
432
+ score = 0;
433
+ document.getElementById('score').textContent = score;
434
+
435
+ generateFood();
436
+ drawGame();
437
+
438
+ // Focus canvas for keyboard controls
439
+ document.getElementById('snakeCanvas').focus();
440
+
441
+ gameInterval = setInterval(gameLoop, 150);
442
+ }
443
+
444
+ function gameLoop() {
445
+ moveSnake();
446
+ checkCollision();
447
+ drawGame();
448
+ }
449
+
450
+ function move
451
+ <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=AramTM/armgame" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
452
+ </html>