Chicken117 commited on
Commit
f9701cf
·
verified ·
1 Parent(s): 330a4a0

Add 3 files

Browse files
Files changed (3) hide show
  1. README.md +7 -5
  2. index.html +451 -19
  3. prompts.txt +0 -0
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
- title: Kids Coding
3
- emoji: 🏆
4
- colorFrom: red
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: kids-coding
3
+ emoji: 🐳
4
+ colorFrom: pink
5
+ colorTo: yellow
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,451 @@
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>Kids Coding Adventure</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
+ .command-block {
11
+ background-color: #f0f9ff;
12
+ border: 2px dashed #7dd3fc;
13
+ border-radius: 12px;
14
+ padding: 10px;
15
+ margin: 5px;
16
+ cursor: grab;
17
+ }
18
+ .command-block:active {
19
+ cursor: grabbing;
20
+ }
21
+ .workspace {
22
+ min-height: 150px;
23
+ background-color: #f8fafc;
24
+ border: 3px solid #e2e8f0;
25
+ border-radius: 12px;
26
+ padding: 15px;
27
+ }
28
+ .character {
29
+ transition: all 0.3s ease;
30
+ }
31
+ .success-animation {
32
+ animation: celebrate 1s ease infinite;
33
+ }
34
+ @keyframes celebrate {
35
+ 0%, 100% { transform: translateY(0); }
36
+ 50% { transform: translateY(-20px); }
37
+ }
38
+ .path-cell {
39
+ width: 60px;
40
+ height: 60px;
41
+ border: 1px solid #cbd5e1;
42
+ display: flex;
43
+ align-items: center;
44
+ justify-content: center;
45
+ }
46
+ .obstacle {
47
+ background-color: #fca5a5;
48
+ }
49
+ .treasure {
50
+ background-color: #fcd34d;
51
+ }
52
+ .highlight {
53
+ box-shadow: 0 0 0 3px #86efac;
54
+ }
55
+ </style>
56
+ </head>
57
+ <body class="bg-blue-50 min-h-screen">
58
+ <div class="container mx-auto px-4 py-8">
59
+ <div class="text-center mb-8">
60
+ <h1 class="text-4xl font-bold text-blue-800 mb-2">🐱 Cat Coding Adventure 🐱</h1>
61
+ <p class="text-blue-600 max-w-2xl mx-auto">
62
+ Help the cat reach the fish by dragging coding blocks to create a path!
63
+ </p>
64
+ </div>
65
+
66
+ <div class="flex flex-col lg:flex-row gap-8">
67
+ <!-- Game Board -->
68
+ <div class="lg:w-1/2 bg-white rounded-xl shadow-md p-6">
69
+ <div class="mb-6">
70
+ <div class="grid grid-cols-5 gap-0 border-2 border-slate-200 rounded-lg overflow-hidden">
71
+ <!-- Row 1 -->
72
+ <div class="path-cell" id="cell-0-0"><div id="character" class="character text-4xl">🐱</div></div>
73
+ <div class="path-cell" id="cell-0-1"></div>
74
+ <div class="path-cell obstacle" id="cell-0-2"><div class="text-2xl">🌵</div></div>
75
+ <div class="path-cell" id="cell-0-3"></div>
76
+ <div class="path-cell" id="cell-0-4"></div>
77
+
78
+ <!-- Row 2 -->
79
+ <div class="path-cell" id="cell-1-0"></div>
80
+ <div class="path-cell obstacle" id="cell-1-1"><div class="text-2xl">🌵</div></div>
81
+ <div class="path-cell" id="cell-1-2"></div>
82
+ <div class="path-cell obstacle" id="cell-1-3"><div class="text-2xl">🌵</div></div>
83
+ <div class="path-cell" id="cell-1-4"></div>
84
+
85
+ <!-- Row 3 -->
86
+ <div class="path-cell" id="cell-2-0"></div>
87
+ <div class="path-cell" id="cell-2-1"></div>
88
+ <div class="path-cell" id="cell-2-2"></div>
89
+ <div class="path-cell" id="cell-2-3"></div>
90
+ <div class="path-cell" id="cell-2-4"></div>
91
+
92
+ <!-- Row 4 -->
93
+ <div class="path-cell" id="cell-3-0"></div>
94
+ <div class="path-cell obstacle" id="cell-3-1"><div class="text-2xl">🌵</div></div>
95
+ <div class="path-cell" id="cell-3-2"></div>
96
+ <div class="path-cell" id="cell-3-3"></div>
97
+ <div class="path-cell" id="cell-3-4"></div>
98
+
99
+ <!-- Row 5 -->
100
+ <div class="path-cell" id="cell-4-0"></div>
101
+ <div class="path-cell" id="cell-4-1"></div>
102
+ <div class="path-cell" id="cell-4-2"></div>
103
+ <div class="path-cell obstacle" id="cell-4-3"><div class="text-2xl">🌵</div></div>
104
+ <div class="path-cell treasure" id="cell-4-4"><div class="text-4xl">🐟</div></div>
105
+ </div>
106
+ </div>
107
+
108
+ <div id="game-message" class="p-4 bg-blue-100 text-blue-800 rounded-lg mb-4">
109
+ <i class="fas fa-info-circle mr-2"></i>
110
+ <span>Drag coding blocks to the workspace to help the cat reach the fish!</span>
111
+ </div>
112
+
113
+ <div class="flex justify-center gap-4">
114
+ <button id="run-btn" class="px-6 py-3 bg-green-500 text-white rounded-lg hover:bg-green-600">
115
+ <i class="fas fa-play mr-2"></i>Run Code
116
+ </button>
117
+ <button id="reset-btn" class="px-6 py-3 bg-blue-500 text-white rounded-lg hover:bg-blue-600">
118
+ <i class="fas fa-redo mr-2"></i>Reset
119
+ </button>
120
+ </div>
121
+ </div>
122
+
123
+ <!-- Coding Area -->
124
+ <div class="lg:w-1/2 bg-white rounded-xl shadow-md p-6">
125
+ <h2 class="text-xl font-bold text-blue-800 mb-4">Coding Blocks</h2>
126
+
127
+ <div class="mb-6">
128
+ <h3 class="text-lg font-medium text-blue-700 mb-2">Movement</h3>
129
+ <div class="grid grid-cols-2 gap-3">
130
+ <div class="command-block" draggable="true" data-command="moveUp">
131
+ <div class="flex items-center justify-center p-2">
132
+ <i class="fas fa-arrow-up text-blue-500 mr-2"></i>
133
+ <span class="font-medium">Move Up</span>
134
+ </div>
135
+ </div>
136
+ <div class="command-block" draggable="true" data-command="moveDown">
137
+ <div class="flex items-center justify-center p-2">
138
+ <i class="fas fa-arrow-down text-blue-500 mr-2"></i>
139
+ <span class="font-medium">Move Down</span>
140
+ </div>
141
+ </div>
142
+ <div class="command-block" draggable="true" data-command="moveLeft">
143
+ <div class="flex items-center justify-center p-2">
144
+ <i class="fas fa-arrow-left text-blue-500 mr-2"></i>
145
+ <span class="font-medium">Move Left</span>
146
+ </div>
147
+ </div>
148
+ <div class="command-block" draggable="true" data-command="moveRight">
149
+ <div class="flex items-center justify-center p-2">
150
+ <i class="fas fa-arrow-right text-blue-500 mr-2"></i>
151
+ <span class="font-medium">Move Right</span>
152
+ </div>
153
+ </div>
154
+ </div>
155
+ </div>
156
+
157
+ <div class="mb-6">
158
+ <h3 class="text-lg font-medium text-blue-700 mb-2">Loops</h3>
159
+ <div class="grid grid-cols-2 gap-3">
160
+ <div class="command-block" draggable="true" data-command="repeat2">
161
+ <div class="flex items-center justify-center p-2">
162
+ <i class="fas fa-redo text-purple-500 mr-2"></i>
163
+ <span class="font-medium">Repeat 2 Times</span>
164
+ </div>
165
+ </div>
166
+ <div class="command-block" draggable="true" data-command="repeat3">
167
+ <div class="flex items-center justify-center p-2">
168
+ <i class="fas fa-redo text-purple-500 mr-2"></i>
169
+ <span class="font-medium">Repeat 3 Times</span>
170
+ </div>
171
+ </div>
172
+ </div>
173
+ </div>
174
+
175
+ <h3 class="text-lg font-medium text-blue-700 mb-2">Your Code</h3>
176
+ <div id="workspace" class="workspace mb-6">
177
+ <!-- Dropped commands will appear here -->
178
+ </div>
179
+ </div>
180
+ </div>
181
+
182
+ <!-- Success Modal -->
183
+ <div id="success-modal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center hidden">
184
+ <div class="bg-white rounded-xl p-8 max-w-md w-full text-center">
185
+ <div class="text-yellow-500 text-6xl mb-4">
186
+ <i class="fas fa-star success-animation"></i>
187
+ </div>
188
+ <h2 class="text-3xl font-bold text-blue-800 mb-2">Great Job!</h2>
189
+ <p class="text-blue-600 mb-6">You helped the cat reach the fish!</p>
190
+ <button id="play-again-btn" class="px-6 py-3 bg-blue-500 text-white rounded-lg hover:bg-blue-600">
191
+ Play Again
192
+ </button>
193
+ </div>
194
+ </div>
195
+ </div>
196
+
197
+ <script>
198
+ document.addEventListener('DOMContentLoaded', function() {
199
+ // Game state
200
+ const gameState = {
201
+ characterPosition: { row: 0, col: 0 },
202
+ commands: [],
203
+ isRunning: false
204
+ };
205
+
206
+ // DOM elements
207
+ const character = document.getElementById('character');
208
+ const workspace = document.getElementById('workspace');
209
+ const runBtn = document.getElementById('run-btn');
210
+ const resetBtn = document.getElementById('reset-btn');
211
+ const gameMessage = document.getElementById('game-message');
212
+ const successModal = document.getElementById('success-modal');
213
+ const playAgainBtn = document.getElementById('play-again-btn');
214
+ const commandBlocks = document.querySelectorAll('.command-block');
215
+ const cells = document.querySelectorAll('.path-cell');
216
+
217
+ // Initialize drag and drop for command blocks
218
+ commandBlocks.forEach(block => {
219
+ block.addEventListener('dragstart', function(e) {
220
+ e.dataTransfer.setData('text/plain', this.dataset.command);
221
+ });
222
+ });
223
+
224
+ // Set up drop zone
225
+ workspace.addEventListener('dragover', function(e) {
226
+ e.preventDefault();
227
+ this.classList.add('highlight');
228
+ });
229
+
230
+ workspace.addEventListener('dragleave', function() {
231
+ this.classList.remove('highlight');
232
+ });
233
+
234
+ workspace.addEventListener('drop', function(e) {
235
+ e.preventDefault();
236
+ this.classList.remove('highlight');
237
+
238
+ const command = e.dataTransfer.getData('text/plain');
239
+ addCommandToWorkspace(command);
240
+ });
241
+
242
+ // Add command to workspace
243
+ function addCommandToWorkspace(command) {
244
+ const commandElement = document.createElement('div');
245
+ commandElement.className = 'command-block bg-white mb-2';
246
+ commandElement.dataset.command = command;
247
+
248
+ let content = '';
249
+ switch(command) {
250
+ case 'moveUp':
251
+ content = '<i class="fas fa-arrow-up text-blue-500 mr-2"></i><span>Move Up</span>';
252
+ break;
253
+ case 'moveDown':
254
+ content = '<i class="fas fa-arrow-down text-blue-500 mr-2"></i><span>Move Down</span>';
255
+ break;
256
+ case 'moveLeft':
257
+ content = '<i class="fas fa-arrow-left text-blue-500 mr-2"></i><span>Move Left</span>';
258
+ break;
259
+ case 'moveRight':
260
+ content = '<i class="fas fa-arrow-right text-blue-500 mr-2"></i><span>Move Right</span>';
261
+ break;
262
+ case 'repeat2':
263
+ content = '<i class="fas fa-redo text-purple-500 mr-2"></i><span>Repeat 2 Times</span>';
264
+ break;
265
+ case 'repeat3':
266
+ content = '<i class="fas fa-redo text-purple-500 mr-2"></i><span>Repeat 3 Times</span>';
267
+ break;
268
+ }
269
+
270
+ commandElement.innerHTML = content;
271
+ workspace.appendChild(commandElement);
272
+
273
+ // Store the command
274
+ gameState.commands.push(command);
275
+ }
276
+
277
+ // Run the code
278
+ runBtn.addEventListener('click', async function() {
279
+ if (gameState.isRunning) return;
280
+
281
+ if (gameState.commands.length === 0) {
282
+ showMessage("Add some commands first to help the cat move!");
283
+ return;
284
+ }
285
+
286
+ gameState.isRunning = true;
287
+ runBtn.disabled = true;
288
+
289
+ // Reset character position
290
+ gameState.characterPosition = { row: 0, col: 0 };
291
+ updateCharacterPosition();
292
+
293
+ // Execute commands
294
+ let i = 0;
295
+ while (i < gameState.commands.length) {
296
+ const command = gameState.commands[i];
297
+
298
+ if (command.startsWith('repeat')) {
299
+ const repeatCount = parseInt(command.replace('repeat', ''));
300
+ const startIndex = i + 1;
301
+ const endIndex = findMatchingEnd(i);
302
+
303
+ if (endIndex === -1) {
304
+ showMessage("Oops! There's a problem with the repeat block.");
305
+ break;
306
+ }
307
+
308
+ // Execute the repeated commands
309
+ for (let r = 0; r < repeatCount; r++) {
310
+ for (let j = startIndex; j < endIndex; j++) {
311
+ await executeCommand(gameState.commands[j]);
312
+ }
313
+ }
314
+
315
+ i = endIndex;
316
+ } else {
317
+ await executeCommand(command);
318
+ i++;
319
+ }
320
+
321
+ // Check if we reached the treasure
322
+ if (gameState.characterPosition.row === 4 && gameState.characterPosition.col === 4) {
323
+ showSuccess();
324
+ break;
325
+ }
326
+ }
327
+
328
+ gameState.isRunning = false;
329
+ runBtn.disabled = false;
330
+ });
331
+
332
+ // Find the end of a repeat block
333
+ function findMatchingEnd(startIndex) {
334
+ let depth = 1;
335
+ for (let i = startIndex + 1; i < gameState.commands.length; i++) {
336
+ if (gameState.commands[i].startsWith('repeat')) {
337
+ depth++;
338
+ } else if (gameState.commands[i] === 'end') {
339
+ depth--;
340
+ if (depth === 0) {
341
+ return i;
342
+ }
343
+ }
344
+ }
345
+ return -1;
346
+ }
347
+
348
+ // Execute a single command
349
+ async function executeCommand(command) {
350
+ return new Promise(resolve => {
351
+ setTimeout(() => {
352
+ let newRow = gameState.characterPosition.row;
353
+ let newCol = gameState.characterPosition.col;
354
+
355
+ switch(command) {
356
+ case 'moveUp':
357
+ newRow = Math.max(0, gameState.characterPosition.row - 1);
358
+ break;
359
+ case 'moveDown':
360
+ newRow = Math.min(4, gameState.characterPosition.row + 1);
361
+ break;
362
+ case 'moveLeft':
363
+ newCol = Math.max(0, gameState.characterPosition.col - 1);
364
+ break;
365
+ case 'moveRight':
366
+ newCol = Math.min(4, gameState.characterPosition.col + 1);
367
+ break;
368
+ }
369
+
370
+ // Check for obstacles
371
+ const cellId = `cell-${newRow}-${newCol}`;
372
+ const cell = document.getElementById(cellId);
373
+
374
+ if (cell.classList.contains('obstacle')) {
375
+ showMessage("Oh no! The cat hit a cactus. Try a different path.");
376
+ } else {
377
+ gameState.characterPosition.row = newRow;
378
+ gameState.characterPosition.col = newCol;
379
+ updateCharacterPosition();
380
+ }
381
+
382
+ resolve();
383
+ }, 500);
384
+ });
385
+ }
386
+
387
+ // Update character position on the grid
388
+ function updateCharacterPosition() {
389
+ const cellId = `cell-${gameState.characterPosition.row}-${gameState.characterPosition.col}`;
390
+ const cell = document.getElementById(cellId);
391
+
392
+ // Remove character from all cells
393
+ cells.forEach(c => {
394
+ if (c.querySelector('.character')) {
395
+ c.removeChild(c.querySelector('.character'));
396
+ }
397
+ });
398
+
399
+ // Add character to new cell
400
+ cell.appendChild(character);
401
+ }
402
+
403
+ // Show success message
404
+ function showSuccess() {
405
+ character.classList.add('success-animation');
406
+ successModal.classList.remove('hidden');
407
+ }
408
+
409
+ // Show message
410
+ function showMessage(text) {
411
+ gameMessage.querySelector('span').textContent = text;
412
+ gameMessage.classList.remove('hidden');
413
+
414
+ // Hide after 5 seconds
415
+ setTimeout(() => {
416
+ gameMessage.classList.add('hidden');
417
+ }, 5000);
418
+ }
419
+
420
+ // Reset the game
421
+ function resetGame() {
422
+ gameState.commands = [];
423
+ gameState.characterPosition = { row: 0, col: 0 };
424
+ gameState.isRunning = false;
425
+
426
+ // Clear workspace
427
+ workspace.innerHTML = '';
428
+
429
+ // Reset character position
430
+ updateCharacterPosition();
431
+
432
+ // Enable run button
433
+ runBtn.disabled = false;
434
+
435
+ // Hide success modal
436
+ successModal.classList.add('hidden');
437
+ character.classList.remove('success-animation');
438
+
439
+ showMessage("Drag coding blocks to the workspace to help the cat reach the fish!");
440
+ }
441
+
442
+ // Event listeners
443
+ resetBtn.addEventListener('click', resetGame);
444
+ playAgainBtn.addEventListener('click', resetGame);
445
+
446
+ // Initialize the game
447
+ resetGame();
448
+ });
449
+ </script>
450
+ <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=Chicken117/kids-coding" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
451
+ </html>
prompts.txt ADDED
File without changes