Uko67 commited on
Commit
b4f8b37
·
verified ·
1 Parent(s): ae1b097

Add 3 files

Browse files
Files changed (3) hide show
  1. README.md +7 -5
  2. index.html +173 -19
  3. prompts.txt +4 -0
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
- title: Https Huggingface Co Api Repos
3
- emoji: 👀
4
- colorFrom: indigo
5
- colorTo: yellow
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: https-huggingface-co-api-repos
3
+ emoji: ⚛️
4
+ colorFrom: green
5
+ colorTo: purple
6
  sdk: static
7
  pinned: false
8
+ tags:
9
+ - QwenSite
10
  ---
11
 
12
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
index.html CHANGED
@@ -1,19 +1,173 @@
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>Snake Game</title>
7
+ <script src="https://cdn.tailwindcss.com"></script>
8
+ <style>
9
+ body {
10
+ font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
11
+ }
12
+
13
+ canvas {
14
+ background-color: #111827;
15
+ border: 2px solid #374151;
16
+ }
17
+
18
+ @keyframes pop {
19
+ from {
20
+ transform: scale(0.8);
21
+ opacity: 0;
22
+ }
23
+ to {
24
+ transform: scale(1);
25
+ opacity: 1;
26
+ }
27
+ }
28
+
29
+ .popup {
30
+ animation: pop 0.3s ease-out forwards;
31
+ }
32
+ </style>
33
+ </head>
34
+ <body class="bg-gray-900 text-white flex flex-col items-center justify-center min-h-screen">
35
+
36
+ <h1 class="text-4xl font-bold mb-4">🐍 Snake Game</h1>
37
+
38
+ <div class="border border-gray-600 rounded-lg shadow-2xl bg-gray-800 p-4">
39
+ <canvas id="gameCanvas" width="400" height="400" class="border border-gray-500"></canvas>
40
+ <div class="mt-4 text-center space-y-2">
41
+ <p class="text-lg font-semibold">Score: <span id="score" class="text-green-400">0</span></p>
42
+ <button onclick="restartGame()" class="hidden px-4 py-2 bg-blue-600 hover:bg-blue-700 rounded-md text-white transition" id="restartBtn">
43
+ Restart Game
44
+ </button>
45
+ </div>
46
+ </div>
47
+
48
+ <script>
49
+ const canvas = document.getElementById("gameCanvas");
50
+ const ctx = canvas.getContext("2d");
51
+
52
+ const gridSize = 20;
53
+ const tileCount = canvas.width / gridSize;
54
+
55
+ let snake = [{ x: 10, y: 10 }];
56
+ let apple = { x: 15, y: 15 };
57
+
58
+ let velocity = { x: 0, y: 0 };
59
+ let gameInterval;
60
+ let score = 0;
61
+ let gameOver = false;
62
+
63
+ function drawTile(x, y, color) {
64
+ ctx.fillStyle = color;
65
+ ctx.fillRect(x * gridSize, y * gridSize, gridSize - 2, gridSize - 2);
66
+ }
67
+
68
+ function drawSnake() {
69
+ snake.forEach((segment, index) => {
70
+ drawTile(segment.x, segment.y, index === 0 ? "#10B981" : "#34D399");
71
+ });
72
+ }
73
+
74
+ function drawApple() {
75
+ drawTile(apple.x, apple.y, "#EF4444");
76
+ }
77
+
78
+ function spawnApple() {
79
+ apple = {
80
+ x: Math.floor(Math.random() * tileCount),
81
+ y: Math.floor(Math.random() * tileCount),
82
+ };
83
+
84
+ // Prevent apple from spawning on the snake
85
+ while (snake.some(segment => segment.x === apple.x && segment.y === apple.y)) {
86
+ apple = {
87
+ x: Math.floor(Math.random() * tileCount),
88
+ y: Math.floor(Math.random() * tileCount),
89
+ };
90
+ }
91
+ }
92
+
93
+ function updateScore() {
94
+ document.getElementById("score").textContent = score;
95
+ }
96
+
97
+ function restartGame() {
98
+ snake = [{ x: 10, y: 10 }];
99
+ velocity = { x: 0, y: 0 };
100
+ score = 0;
101
+ updateScore();
102
+ gameOver = false;
103
+ document.getElementById("restartBtn").classList.add("hidden");
104
+ gameLoop();
105
+ }
106
+
107
+ function handleGameOver() {
108
+ gameOver = true;
109
+ document.getElementById("restartBtn").classList.remove("hidden");
110
+ ctx.fillStyle = "rgba(0,0,0,0.6)";
111
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
112
+ ctx.fillStyle = "#FFF";
113
+ ctx.font = "30px Arial";
114
+ ctx.textAlign = "center";
115
+ ctx.fillText("Game Over", canvas.width / 2, canvas.height / 2);
116
+ }
117
+
118
+ function isSelfColliding(head, body) {
119
+ return body.some(seg => seg.x === head.x && seg.y === head.y);
120
+ }
121
+
122
+ function gameLoop() {
123
+ const newHead = { x: snake[0].x + velocity.x, y: snake[0].y + velocity.y };
124
+
125
+ // Collision detection
126
+ if (
127
+ newHead.x < 0 || newHead.x >= tileCount ||
128
+ newHead.y < 0 || newHead.y >= tileCount ||
129
+ isSelfColliding(newHead, snake)
130
+ ) {
131
+ handleGameOver();
132
+ return;
133
+ }
134
+
135
+ snake.unshift(newHead);
136
+
137
+ // Eat apple
138
+ if (newHead.x === apple.x && newHead.y === apple.y) {
139
+ score += 10;
140
+ updateScore();
141
+ spawnApple();
142
+ } else {
143
+ snake.pop();
144
+ }
145
+
146
+ // Clear canvas
147
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
148
+
149
+ drawApple();
150
+ drawSnake();
151
+ }
152
+
153
+ document.addEventListener("keydown", (e) => {
154
+ if (gameOver) return;
155
+
156
+ if (e.key === "ArrowUp" && velocity.y === 0) {
157
+ velocity = { x: 0, y: -1 };
158
+ } else if (e.key === "ArrowDown" && velocity.y === 0) {
159
+ velocity = { x: 0, y: 1 };
160
+ } else if (e.key === "ArrowLeft" && velocity.x === 0) {
161
+ velocity = { x: -1, y: 0 };
162
+ } else if (e.key === "ArrowRight" && velocity.x === 0) {
163
+ velocity = { x: 1, y: 0 };
164
+ }
165
+ });
166
+
167
+ // Start game
168
+ spawnApple();
169
+ document.getElementById("score").textContent = score;
170
+ gameInterval = setInterval(gameLoop, 100);
171
+ </script>
172
+ <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-qwensite.hf.space/logo.svg" alt="qwensite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-qwensite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >QwenSite</a> - 🧬 <a href="https://enzostvs-qwensite.hf.space?remix=Uko67/https-huggingface-co-api-repos" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
173
+ </html>
prompts.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ whatsapp
2
+ snake game
3
+ snake game
4
+ snake game