yefem16191 commited on
Commit
ce5c7f8
·
verified ·
1 Parent(s): 1c31334

🎮 PARTE 1 — BASE DO JOGO 3D (MAPA + PERSONAGEM + CONTROLES) ✅ Objetivo: Criar a estrutura base com: Terreno simples Personagem articulado Controles funcionais Câmera em terceira pessoa Física e gravidade 🧾 Prompt 1 — Estrutura inicial do jogo: Crie um jogo 3D leve e minimalista com: • Um personagem com corpo articulado (braços, pernas e cabeça) estilo low poly. • O personagem deve começar acima do terreno e completamente visível. • Movimentação com teclado: W, A, S, D para andar; Espaço para pular; Shift para correr. • Câmera em terceira pessoa, acompanhando o personagem suavemente por trás. • Um terreno plano grande e algumas plataformas elevadas espalhadas. • Física básica: gravidade ativa, colisão entre o personagem e o terreno/plataformas. • Iluminação clara e céu azul com luz ambiente suave. Este será o esqueleto do jogo. - Initial Deployment

Browse files
Files changed (2) hide show
  1. README.md +7 -5
  2. index.html +734 -19
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
- title: Erer
3
- emoji: 🐨
4
- colorFrom: yellow
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: erer
3
+ emoji: 🐳
4
+ colorFrom: gray
5
+ colorTo: pink
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,734 @@
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>Oxygen Runner</title>
7
+ <script src="https://cdn.tailwindcss.com"></script>
8
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
9
+ <script src="https://cdn.jsdelivr.net/npm/three@0.128.0/examples/js/controls/OrbitControls.min.js"></script>
10
+ <style>
11
+ body {
12
+ margin: 0;
13
+ overflow: hidden;
14
+ font-family: 'Arial', sans-serif;
15
+ }
16
+ #game-container {
17
+ position: relative;
18
+ width: 100%;
19
+ height: 100vh;
20
+ }
21
+ #ui-overlay {
22
+ position: absolute;
23
+ top: 0;
24
+ left: 0;
25
+ width: 100%;
26
+ height: 100%;
27
+ pointer-events: none;
28
+ }
29
+ .oxygen-bar {
30
+ transition: width 0.3s ease;
31
+ }
32
+ #mobile-controls {
33
+ display: none;
34
+ }
35
+ @media (max-width: 768px) {
36
+ #mobile-controls {
37
+ display: flex;
38
+ }
39
+ }
40
+ </style>
41
+ </head>
42
+ <body class="bg-blue-50">
43
+ <div id="game-container" tabindex="0">
44
+ <div id="ui-overlay" class="flex flex-col p-4">
45
+ <!-- Oxygen and score display -->
46
+ <div class="flex justify-between items-center">
47
+ <div class="bg-white bg-opacity-70 rounded-lg p-2 shadow-lg">
48
+ <div class="text-sm font-bold text-gray-800">OXYGEN</div>
49
+ <div class="w-40 h-4 bg-gray-300 rounded-full overflow-hidden">
50
+ <div id="oxygen-bar" class="oxygen-bar h-full bg-blue-500" style="width: 100%;"></div>
51
+ </div>
52
+ <div id="oxygen-time" class="text-xs font-semibold text-gray-700">02:30</div>
53
+ </div>
54
+
55
+ <div class="bg-white bg-opacity-70 rounded-lg p-2 shadow-lg">
56
+ <div class="text-sm font-bold text-gray-800">GREEN ZONES</div>
57
+ <div id="green-zones" class="text-lg font-bold text-green-600">0/5</div>
58
+ </div>
59
+ </div>
60
+
61
+ <!-- Game messages -->
62
+ <div id="game-message" class="mt-4 mx-auto bg-white bg-opacity-80 rounded-lg px-4 py-2 shadow-lg text-center text-gray-800 font-bold text-lg hidden"></div>
63
+
64
+ <!-- Start screen -->
65
+ <div id="start-screen" class="absolute inset-0 flex flex-col items-center justify-center bg-black bg-opacity-60">
66
+ <h1 class="text-4xl md:text-6xl font-bold text-white mb-4">OXYGEN RUNNER</h1>
67
+ <p class="text-white text-lg mb-8 max-w-md text-center">Restore the planet's green zones before your oxygen runs out!</p>
68
+ <button id="start-button" class="bg-green-500 hover:bg-green-600 text-white font-bold py-3 px-8 rounded-full text-xl shadow-lg transition-all transform hover:scale-105 pointer-events-auto">
69
+ START MISSION
70
+ </button>
71
+ <div class="mt-8 text-white">
72
+ <div class="mb-2">WASD: Move</div>
73
+ <div class="mb-2">SPACE: Jump</div>
74
+ <div class="mb-2">SHIFT: Run</div>
75
+ <div>E: Interact</div>
76
+ </div>
77
+ </div>
78
+
79
+ <!-- Game over screen -->
80
+ <div id="game-over-screen" class="absolute inset-0 flex flex-col items-center justify-center bg-black bg-opacity-60 hidden">
81
+ <h1 id="game-over-title" class="text-4xl md:text-6xl font-bold text-white mb-4"></h1>
82
+ <p id="game-over-message" class="text-white text-lg mb-8 max-w-md text-center"></p>
83
+ <button id="restart-button" class="bg-green-500 hover:bg-green-600 text-white font-bold py-3 px-8 rounded-full text-xl shadow-lg transition-all transform hover:scale-105 pointer-events-auto">
84
+ TRY AGAIN
85
+ </button>
86
+ </div>
87
+
88
+ <!-- Mobile controls -->
89
+ <div id="mobile-controls" class="absolute bottom-4 w-full px-4 pointer-events-auto">
90
+ <div class="grid grid-cols-3 gap-2">
91
+ <div></div>
92
+ <button id="mobile-up" class="bg-white bg-opacity-70 rounded-full h-16 flex items-center justify-center shadow-lg">
93
+
94
+ </button>
95
+ <div></div>
96
+ <button id="mobile-left" class="bg-white bg-opacity-70 rounded-full h-16 flex items-center justify-center shadow-lg">
97
+
98
+ </button>
99
+ <button id="mobile-interact" class="bg-green-500 bg-opacity-80 rounded-full h-16 flex items-center justify-center shadow-lg text-white font-bold">
100
+ E
101
+ </button>
102
+ <button id="mobile-right" class="bg-white bg-opacity-70 rounded-full h-16 flex items-center justify-center shadow-lg">
103
+
104
+ </button>
105
+ <button id="mobile-jump" class="bg-white bg-opacity-70 rounded-full h-16 flex items-center justify-center shadow-lg">
106
+ ↑↑
107
+ </button>
108
+ <button id="mobile-run" class="bg-white bg-opacity-70 rounded-full h-16 flex items-center justify-center shadow-lg">
109
+ RUN
110
+ </button>
111
+ </div>
112
+ </div>
113
+ </div>
114
+ </div>
115
+
116
+ <script>
117
+ // Background music and sounds
118
+ const bgMusic = new Audio('https://assets.mixkit.co/music/preview/mixkit-forest-trek-583.mp3');
119
+ bgMusic.loop = true;
120
+ bgMusic.volume = 0.4;
121
+
122
+ // Preload sounds
123
+ const soundEffects = {
124
+ collect: new Audio('https://assets.mixkit.co/sfx/preview/mixkit-achievement-bell-600.mp3'),
125
+ restore: new Audio('https://assets.mixkit.co/sfx/preview/mixkit-unlock-game-notification-253.mp3'),
126
+ jump: new Audio('https://assets.mixkit.co/sfx/preview/mixkit-quick-jump-arcade-game-239.mp3'),
127
+ step: new Audio('https://assets.mixkit.co/sfx/preview/mixkit-footsteps-on-grass-531.mp3'),
128
+ win: new Audio('https://assets.mixkit.co/sfx/preview/mixkit-winning-chimes-2015.mp3')
129
+ };
130
+
131
+ // Set volumes
132
+ Object.values(soundEffects).forEach(sound => {
133
+ sound.volume = 0.3;
134
+ });
135
+
136
+ // Game variables
137
+ let scene, camera, renderer, controls, player, oxygenSpheres = [], greenZones = [];
138
+ let oxygenLevel = 100;
139
+ let oxygenTime = 150; // 2.5 minutes in seconds
140
+ let collectedSpheres = 0;
141
+ let restoredZones = 0;
142
+ let totalZones = 5;
143
+ let gameActive = false;
144
+ let playerSpeed = 0.1;
145
+ let clock = new THREE.Clock();
146
+ let keys = {};
147
+
148
+ // Initialize the game
149
+ function init() {
150
+ // Create scene
151
+ scene = new THREE.Scene();
152
+ scene.background = new THREE.Color(0x87CEEB);
153
+
154
+ // Create camera
155
+ camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
156
+ camera.position.set(0, 10, 15);
157
+
158
+ // Create renderer
159
+ renderer = new THREE.WebGLRenderer({ antialias: true });
160
+ renderer.setSize(window.innerWidth, window.innerHeight);
161
+ document.getElementById('game-container').prepend(renderer.domElement);
162
+
163
+ // Add lights
164
+ const ambientLight = new THREE.AmbientLight(0xffffff, 0.6);
165
+ scene.add(ambientLight);
166
+
167
+ const directionalLight = new THREE.DirectionalLight(0xffffff, 0.8);
168
+ directionalLight.position.set(10, 20, 10);
169
+ scene.add(directionalLight);
170
+
171
+ // Create ground
172
+ const groundGeometry = new THREE.PlaneGeometry(50, 50);
173
+ const groundMaterial = new THREE.MeshStandardMaterial({ color: 0xB8860B });
174
+ const ground = new THREE.Mesh(groundGeometry, groundMaterial);
175
+ ground.rotation.x = -Math.PI / 2;
176
+ ground.receiveShadow = true;
177
+ scene.add(ground);
178
+
179
+ // Create more realistic player
180
+ player = new THREE.Group();
181
+
182
+ // Body
183
+ const bodyGeometry = new THREE.CylinderGeometry(0.3, 0.3, 0.8, 8);
184
+ const bodyMaterial = new THREE.MeshStandardMaterial({ color: 0x4682B4 });
185
+ const body = new THREE.Mesh(bodyGeometry, bodyMaterial);
186
+ body.position.y = 0.4;
187
+ body.rotation.x = Math.PI / 2;
188
+ player.add(body);
189
+
190
+ // Head
191
+ const headGeometry = new THREE.SphereGeometry(0.25, 16, 16);
192
+ const headMaterial = new THREE.MeshStandardMaterial({ color: 0xFFD700 });
193
+ const head = new THREE.Mesh(headGeometry, headMaterial);
194
+ head.position.y = 0.8;
195
+ player.add(head);
196
+
197
+ // Arms
198
+ const armGeometry = new THREE.CylinderGeometry(0.08, 0.08, 0.6, 8);
199
+ const armMaterial = new THREE.MeshStandardMaterial({ color: 0xFFD700 });
200
+
201
+ const leftArm = new THREE.Mesh(armGeometry, armMaterial);
202
+ leftArm.position.set(-0.3, 0.4, 0);
203
+ leftArm.rotation.z = Math.PI / 2;
204
+ player.add(leftArm);
205
+
206
+ const rightArm = new THREE.Mesh(armGeometry, armMaterial);
207
+ rightArm.position.set(0.3, 0.4, 0);
208
+ rightArm.rotation.z = Math.PI / 2;
209
+ player.add(rightArm);
210
+
211
+ // Legs
212
+ const legGeometry = new THREE.CylinderGeometry(0.1, 0.1, 0.6, 8);
213
+ const legMaterial = new THREE.MeshStandardMaterial({ color: 0x4682B4 });
214
+
215
+ const leftLeg = new THREE.Mesh(legGeometry, legMaterial);
216
+ leftLeg.position.set(-0.15, -0.3, 0);
217
+ player.add(leftLeg);
218
+
219
+ const rightLeg = new THREE.Mesh(legGeometry, legMaterial);
220
+ rightLeg.position.set(0.15, -0.3, 0);
221
+ player.add(rightLeg);
222
+
223
+ player.position.y = 1;
224
+ player.castShadow = true;
225
+ player.userData = {
226
+ armSwing: 0,
227
+ legSwing: 0,
228
+ isMoving: false
229
+ };
230
+ scene.add(player);
231
+
232
+ // Create platforms and obstacles
233
+ createEnvironment();
234
+
235
+ // Create oxygen spheres
236
+ createOxygenSpheres();
237
+
238
+ // Create green zones
239
+ createGreenZones();
240
+
241
+ // Add event listeners
242
+ window.addEventListener('resize', onWindowResize);
243
+ document.addEventListener('keydown', onKeyDown);
244
+ document.addEventListener('keyup', onKeyUp);
245
+
246
+ // Mobile controls
247
+ document.getElementById('mobile-up').addEventListener('touchstart', () => keys['w'] = true);
248
+ document.getElementById('mobile-up').addEventListener('touchend', () => keys['w'] = false);
249
+ document.getElementById('mobile-left').addEventListener('touchstart', () => keys['a'] = true);
250
+ document.getElementById('mobile-left').addEventListener('touchend', () => keys['a'] = false);
251
+ document.getElementById('mobile-right').addEventListener('touchstart', () => keys['d'] = true);
252
+ document.getElementById('mobile-right').addEventListener('touchend', () => keys['d'] = false);
253
+ document.getElementById('mobile-jump').addEventListener('touchstart', () => keys[' '] = true);
254
+ document.getElementById('mobile-jump').addEventListener('touchend', () => keys[' '] = false);
255
+ document.getElementById('mobile-run').addEventListener('touchstart', () => keys['Shift'] = true);
256
+ document.getElementById('mobile-run').addEventListener('touchend', () => keys['Shift'] = false);
257
+ document.getElementById('mobile-interact').addEventListener('touchstart', () => interact());
258
+
259
+ // Game buttons
260
+ document.getElementById('start-button').addEventListener('click', startGame);
261
+ document.getElementById('restart-button').addEventListener('click', restartGame);
262
+
263
+ // Start animation loop
264
+ animate();
265
+ }
266
+
267
+ function createEnvironment() {
268
+ // Add some platforms
269
+ const platformGeometry = new THREE.BoxGeometry(8, 0.5, 8);
270
+ const platformMaterial = new THREE.MeshStandardMaterial({ color: 0x8B4513 });
271
+
272
+ for (let i = 0; i < 5; i++) {
273
+ const platform = new THREE.Mesh(platformGeometry, platformMaterial);
274
+ platform.position.x = (Math.random() - 0.5) * 30;
275
+ platform.position.z = (Math.random() - 0.5) * 30;
276
+ platform.position.y = Math.random() * 3;
277
+ scene.add(platform);
278
+ }
279
+
280
+ // Add some dead trees
281
+ const treeGeometry = new THREE.ConeGeometry(0.5, 2, 4);
282
+ const treeMaterial = new THREE.MeshStandardMaterial({ color: 0x556B2F });
283
+
284
+ for (let i = 0; i < 10; i++) {
285
+ const tree = new THREE.Mesh(treeGeometry, treeMaterial);
286
+ tree.position.x = (Math.random() - 0.5) * 40;
287
+ tree.position.z = (Math.random() - 0.5) * 40;
288
+ tree.position.y = 1;
289
+ scene.add(tree);
290
+ }
291
+ }
292
+
293
+ function createOxygenSpheres() {
294
+ const sphereGeometry = new THREE.SphereGeometry(0.5, 16, 16);
295
+ const sphereMaterial = new THREE.MeshStandardMaterial({
296
+ color: 0x00BFFF,
297
+ transparent: true,
298
+ opacity: 0.8,
299
+ emissive: 0x00BFFF,
300
+ emissiveIntensity: 0.5
301
+ });
302
+
303
+ for (let i = 0; i < 10; i++) {
304
+ const sphere = new THREE.Mesh(sphereGeometry, sphereMaterial);
305
+ sphere.position.x = (Math.random() - 0.5) * 40;
306
+ sphere.position.z = (Math.random() - 0.5) * 40;
307
+ sphere.position.y = 10 + Math.random() * 5; // Start higher up
308
+
309
+ // Physics properties
310
+ sphere.userData = {
311
+ velocity: new THREE.Vector3(0, -0.1, 0),
312
+ onGround: false,
313
+ time: Math.random() * Math.PI * 2
314
+ };
315
+
316
+ oxygenSpheres.push(sphere);
317
+ scene.add(sphere);
318
+ }
319
+ }
320
+
321
+ function createGreenZones() {
322
+ const zoneGeometry = new THREE.CylinderGeometry(2, 2, 0.1, 32);
323
+ const zoneMaterial = new THREE.MeshStandardMaterial({
324
+ color: 0x228B22,
325
+ transparent: true,
326
+ opacity: 0.7,
327
+ emissive: 0x00FF00,
328
+ emissiveIntensity: 0.8
329
+ });
330
+
331
+ // Enhanced white outline effect with glow
332
+ const zoneOutlineGeometry = new THREE.RingGeometry(1.9, 2.2, 32);
333
+ const zoneOutlineMaterial = new THREE.MeshBasicMaterial({
334
+ color: 0xFFFFFF,
335
+ side: THREE.DoubleSide,
336
+ transparent: true,
337
+ opacity: 0.9
338
+ });
339
+
340
+ // Add pulsing glow effect
341
+ const zoneGlowGeometry = new THREE.RingGeometry(2.1, 2.5, 32);
342
+ const zoneGlowMaterial = new THREE.MeshBasicMaterial({
343
+ color: 0x00FF00,
344
+ side: THREE.DoubleSide,
345
+ transparent: true,
346
+ opacity: 0.5
347
+ });
348
+
349
+ for (let i = 0; i < totalZones; i++) {
350
+ const zone = new THREE.Mesh(zoneGeometry, zoneMaterial);
351
+ zone.position.x = (Math.random() - 0.5) * 40;
352
+ zone.position.z = (Math.random() - 0.5) * 40;
353
+ zone.position.y = 0.05;
354
+ zone.visible = false;
355
+
356
+ greenZones.push(zone);
357
+ scene.add(zone);
358
+ }
359
+ }
360
+
361
+ function onWindowResize() {
362
+ camera.aspect = window.innerWidth / window.innerHeight;
363
+ camera.updateProjectionMatrix();
364
+ renderer.setSize(window.innerWidth, window.innerHeight);
365
+ }
366
+
367
+ function onKeyDown(event) {
368
+ // Only process keys when game container has focus
369
+ if (document.activeElement.id === 'game-container') {
370
+ keys[event.key] = true;
371
+
372
+ // Prevent space bar from scrolling page
373
+ if (event.key === ' ' ||
374
+ event.key === 'w' ||
375
+ event.key === 'a' ||
376
+ event.key === 's' ||
377
+ event.key === 'd') {
378
+ event.preventDefault();
379
+ }
380
+
381
+ // Interact with E
382
+ if (event.key === 'e' && gameActive) {
383
+ interact();
384
+ }
385
+ }
386
+ }
387
+
388
+ function onKeyUp(event) {
389
+ keys[event.key] = false;
390
+ }
391
+
392
+ // Sound effects
393
+ const sounds = {
394
+ collect: new Audio('https://assets.mixkit.co/sfx/preview/mixkit-positive-interface-beep-221.mp3'),
395
+ restore: new Audio('https://assets.mixkit.co/sfx/preview/mixkit-unlock-game-notification-253.mp3'),
396
+ win: new Audio('https://assets.mixkit.co/sfx/preview/mixkit-achievement-bell-600.mp3')
397
+ };
398
+
399
+ function interact() {
400
+ if (!gameActive) return;
401
+
402
+ // Check for nearby oxygen spheres
403
+ for (let i = 0; i < oxygenSpheres.length; i++) {
404
+ const sphere = oxygenSpheres[i];
405
+ const distance = player.position.distanceTo(sphere.position);
406
+
407
+ if (distance < 2) {
408
+ // Enhanced visual effect
409
+ const flash = new THREE.PointLight(0x00BFFF, 5, 5);
410
+ flash.position.copy(sphere.position);
411
+ scene.add(flash);
412
+
413
+ // Add particle burst
414
+ const particles = new THREE.Group();
415
+ for (let i = 0; i < 20; i++) {
416
+ const particle = new THREE.Mesh(
417
+ new THREE.SphereGeometry(0.1),
418
+ new THREE.MeshBasicMaterial({ color: 0x00BFFF })
419
+ );
420
+ particle.position.copy(sphere.position);
421
+ particle.userData = {
422
+ velocity: new THREE.Vector3(
423
+ (Math.random() - 0.5) * 0.5,
424
+ Math.random() * 0.5,
425
+ (Math.random() - 0.5) * 0.5
426
+ ),
427
+ lifetime: 0
428
+ };
429
+ particles.add(particle);
430
+ }
431
+ scene.add(particles);
432
+
433
+ // Animate and remove effects
434
+ setTimeout(() => {
435
+ scene.remove(flash);
436
+ scene.remove(particles);
437
+ }, 500);
438
+
439
+ // Collect sphere
440
+ scene.remove(sphere);
441
+ oxygenSpheres.splice(i, 1);
442
+ collectedSpheres++;
443
+
444
+ // Add oxygen
445
+ oxygenLevel = Math.min(100, oxygenLevel + 10);
446
+ updateOxygenDisplay();
447
+
448
+ // Play sound and show message
449
+ sounds.collect.play();
450
+ showMessage("Oxygen collected!", 1500);
451
+ return;
452
+ }
453
+ }
454
+
455
+ // Check for green zones to restore
456
+ for (let i = 0; i < greenZones.length; i++) {
457
+ const zone = greenZones[i];
458
+
459
+ if (!zone.visible) {
460
+ const distance = player.position.distanceTo(zone.position);
461
+
462
+ if (distance < 3 && collectedSpheres > 0) {
463
+ // Restore zone
464
+ zone.visible = true;
465
+ collectedSpheres--;
466
+ restoredZones++;
467
+ updateGreenZonesDisplay();
468
+
469
+ // Show message
470
+ showMessage("Green zone restored!", 1500);
471
+
472
+ // Check win condition
473
+ if (restoredZones >= totalZones) {
474
+ endGame(true);
475
+ }
476
+ return;
477
+ }
478
+ }
479
+ }
480
+ }
481
+
482
+ function startGame() {
483
+ document.getElementById('start-screen').classList.add('hidden');
484
+ gameActive = true;
485
+ bgMusic.play();
486
+
487
+ // Start oxygen depletion
488
+ setInterval(() => {
489
+ if (gameActive) {
490
+ oxygenTime--;
491
+ oxygenLevel = (oxygenTime / 150) * 100;
492
+ updateOxygenDisplay();
493
+
494
+ if (oxygenTime <= 0) {
495
+ endGame(false);
496
+ }
497
+ }
498
+ }, 1000);
499
+ }
500
+
501
+ function endGame(win) {
502
+ gameActive = false;
503
+ const gameOverScreen = document.getElementById('game-over-screen');
504
+ const title = document.getElementById('game-over-title');
505
+ const message = document.getElementById('game-over-message');
506
+
507
+ gameOverScreen.classList.remove('hidden');
508
+
509
+ if (win) {
510
+ title.textContent = "VOCÊ SALVOU O PLANETA!";
511
+ message.textContent = `Você restaurou todas as ${totalZones} zonas verdes com ${oxygenTime} segundos restantes!`;
512
+
513
+ // Confetti effect
514
+ setTimeout(() => {
515
+ for (let i = 0; i < 100; i++) {
516
+ const confetti = new THREE.Mesh(
517
+ new THREE.SphereGeometry(0.1),
518
+ new THREE.MeshBasicMaterial({
519
+ color: Math.random() * 0xffffff
520
+ })
521
+ );
522
+ confetti.position.set(
523
+ player.position.x + (Math.random() - 0.5) * 10,
524
+ player.position.y + Math.random() * 10,
525
+ player.position.z + (Math.random() - 0.5) * 10
526
+ );
527
+ confetti.userData = {
528
+ velocity: new THREE.Vector3(
529
+ (Math.random() - 0.5) * 0.1,
530
+ Math.random() * 0.1,
531
+ (Math.random() - 0.5) * 0.1
532
+ )
533
+ };
534
+ scene.add(confetti);
535
+ }
536
+ }, 500);
537
+
538
+ // Auto-restart after 10 seconds
539
+ setTimeout(restartGame, 10000);
540
+ } else {
541
+ title.textContent = "MISSION FAILED";
542
+ message.textContent = `You ran out of oxygen after restoring ${restoredZones} of ${totalZones} green zones.`;
543
+ }
544
+
545
+ // Pause background music
546
+ bgMusic.pause();
547
+ }
548
+
549
+ function restartGame() {
550
+ document.getElementById('game-over-screen').classList.add('hidden');
551
+
552
+ // Reset game state
553
+ oxygenLevel = 100;
554
+ oxygenTime = 150;
555
+ collectedSpheres = 0;
556
+ restoredZones = 0;
557
+ gameActive = false;
558
+
559
+ // Reset displays
560
+ updateOxygenDisplay();
561
+ updateGreenZonesDisplay();
562
+
563
+ // Clear existing objects
564
+ oxygenSpheres.forEach(sphere => scene.remove(sphere));
565
+ greenZones.forEach(zone => {
566
+ zone.visible = false;
567
+ scene.remove(zone);
568
+ });
569
+
570
+ oxygenSpheres = [];
571
+ greenZones = [];
572
+
573
+ // Recreate objects
574
+ createOxygenSpheres();
575
+ createGreenZones();
576
+
577
+ // Reset player position
578
+ player.position.set(0, 1, 0);
579
+
580
+ // Show start screen
581
+ document.getElementById('start-screen').classList.remove('hidden');
582
+ }
583
+
584
+ function updateOxygenDisplay() {
585
+ const oxygenBar = document.getElementById('oxygen-bar');
586
+ oxygenBar.style.width = `${oxygenLevel}%`;
587
+
588
+ // Change color based on oxygen level
589
+ if (oxygenLevel < 30) {
590
+ oxygenBar.classList.remove('bg-blue-500');
591
+ oxygenBar.classList.add('bg-red-500');
592
+ } else {
593
+ oxygenBar.classList.remove('bg-red-500');
594
+ oxygenBar.classList.add('bg-blue-500');
595
+ }
596
+
597
+ // Update time display
598
+ const minutes = Math.floor(oxygenTime / 60);
599
+ const seconds = oxygenTime % 60;
600
+ document.getElementById('oxygen-time').textContent =
601
+ `${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`;
602
+ }
603
+
604
+ function updateGreenZonesDisplay() {
605
+ document.getElementById('green-zones').textContent =
606
+ `${restoredZones}/${totalZones}`;
607
+ }
608
+
609
+ function showMessage(text, duration) {
610
+ const messageElement = document.getElementById('game-message');
611
+ messageElement.textContent = text;
612
+ messageElement.classList.remove('hidden');
613
+
614
+ setTimeout(() => {
615
+ messageElement.classList.add('hidden');
616
+ }, duration);
617
+ }
618
+
619
+ function animate() {
620
+ requestAnimationFrame(animate);
621
+
622
+ const delta = clock.getDelta();
623
+
624
+ if (gameActive) {
625
+ // Player movement
626
+ const moveSpeed = keys['Shift'] ? playerSpeed * 1.5 : playerSpeed;
627
+
628
+ if (keys['w']) {
629
+ player.position.z -= moveSpeed;
630
+ camera.position.z -= moveSpeed;
631
+ }
632
+ if (keys['s']) {
633
+ player.position.z += moveSpeed;
634
+ camera.position.z += moveSpeed;
635
+ }
636
+ if (keys['a']) {
637
+ player.position.x -= moveSpeed;
638
+ camera.position.x -= moveSpeed;
639
+ }
640
+ if (keys['d']) {
641
+ player.position.x += moveSpeed;
642
+ camera.position.x += moveSpeed;
643
+ }
644
+ if (keys[' '] && player.position.y <= 1.1) {
645
+ player.position.y += 0.5;
646
+ }
647
+
648
+ // Improved gravity and jumping
649
+ if (player.position.y > 0.8) {
650
+ player.position.y -= 0.1;
651
+ } else {
652
+ player.position.y = 0.8;
653
+ }
654
+
655
+ // Character animation
656
+ const isMoving = keys['w'] || keys['a'] || keys['s'] || keys['d'];
657
+ player.userData.isMoving = isMoving;
658
+
659
+ if (isMoving) {
660
+ // Arm swing animation
661
+ player.userData.armSwing += delta * 10;
662
+ const leftArm = player.children[2];
663
+ const rightArm = player.children[3];
664
+ leftArm.rotation.z = Math.sin(player.userData.armSwing) * 0.5;
665
+ rightArm.rotation.z = Math.sin(player.userData.armSwing + Math.PI) * 0.5;
666
+
667
+ // Leg swing animation
668
+ player.userData.legSwing += delta * 10;
669
+ const leftLeg = player.children[4];
670
+ const rightLeg = player.children[5];
671
+ leftLeg.rotation.z = Math.sin(player.userData.legSwing + Math.PI) * 0.3;
672
+ rightLeg.rotation.z = Math.sin(player.userData.legSwing) * 0.3;
673
+ } else {
674
+ // Reset to idle position
675
+ player.children[2].rotation.z = THREE.MathUtils.lerp(
676
+ player.children[2].rotation.z, 0, delta * 5
677
+ );
678
+ player.children[3].rotation.z = THREE.MathUtils.lerp(
679
+ player.children[3].rotation.z, 0, delta * 5
680
+ );
681
+ player.children[4].rotation.z = THREE.MathUtils.lerp(
682
+ player.children[4].rotation.z, 0, delta * 5
683
+ );
684
+ player.children[5].rotation.z = THREE.MathUtils.lerp(
685
+ player.children[5].rotation.z, 0, delta * 5
686
+ );
687
+ }
688
+
689
+ // Keep camera following player in third-person view
690
+ const cameraOffset = new THREE.Vector3(0, 5, 10);
691
+ const targetPosition = new THREE.Vector3();
692
+ targetPosition.copy(player.position).add(cameraOffset);
693
+ camera.position.lerp(targetPosition, delta * 5);
694
+ camera.lookAt(player.position.x, player.position.y + 1, player.position.z);
695
+
696
+ // Update oxygen spheres physics
697
+ oxygenSpheres.forEach(sphere => {
698
+ if (!sphere.userData.onGround) {
699
+ sphere.userData.velocity.y -= 0.01; // Gravity
700
+ sphere.position.add(sphere.userData.velocity);
701
+
702
+ // Simple ground collision
703
+ if (sphere.position.y <= 0.5) {
704
+ sphere.position.y = 0.5;
705
+ sphere.userData.onGround = true;
706
+ }
707
+ }
708
+
709
+ // Pulsing animation when on ground
710
+ if (sphere.userData.onGround) {
711
+ sphere.userData.time += delta;
712
+ sphere.position.y = 0.5 + Math.sin(sphere.userData.time) * 0.1;
713
+ }
714
+
715
+ sphere.rotation.y += delta * 0.5;
716
+ });
717
+ }
718
+
719
+ renderer.render(scene, camera);
720
+ }
721
+
722
+ // Ensure game container has focus
723
+ document.getElementById('game-container').focus();
724
+
725
+ // Handle focus when clicking anywhere in the game
726
+ document.addEventListener('click', () => {
727
+ document.getElementById('game-container').focus();
728
+ });
729
+
730
+ // Start the game
731
+ init();
732
+ </script>
733
+ <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=yefem16191/erer" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
734
+ </html>