aicoding101 commited on
Commit
4216bef
·
verified ·
1 Parent(s): 244ea6f

Add 3 files

Browse files
Files changed (3) hide show
  1. README.md +7 -5
  2. index.html +418 -19
  3. prompts.txt +0 -0
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
- title: My1
3
- emoji: 🐢
4
- colorFrom: gray
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: my1
3
+ emoji: 🐳
4
+ colorFrom: pink
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,418 @@
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>Simple SimCity</title>
7
+ <script src="https://cdn.tailwindcss.com"></script>
8
+ <script src="https://cdn.jsdelivr.net/npm/three@0.132.2/build/three.min.js"></script>
9
+ <script src="https://cdn.jsdelivr.net/npm/three@0.132.2/examples/js/controls/OrbitControls.js"></script>
10
+ <style>
11
+ #game-container {
12
+ position: relative;
13
+ width: 100%;
14
+ height: 100vh;
15
+ overflow: hidden;
16
+ }
17
+ #ui-overlay {
18
+ position: absolute;
19
+ top: 0;
20
+ left: 0;
21
+ width: 100%;
22
+ pointer-events: none;
23
+ z-index: 10;
24
+ }
25
+ .building-option {
26
+ pointer-events: all;
27
+ transition: all 0.2s;
28
+ }
29
+ .building-option:hover {
30
+ transform: scale(1.05);
31
+ box-shadow: 0 0 15px rgba(255, 255, 255, 0.5);
32
+ }
33
+ .selected {
34
+ border: 2px solid white;
35
+ box-shadow: 0 0 15px rgba(255, 255, 255, 0.8);
36
+ }
37
+ #grid-highlight {
38
+ position: absolute;
39
+ background-color: rgba(255, 255, 255, 0.3);
40
+ border: 1px dashed white;
41
+ pointer-events: none;
42
+ z-index: 5;
43
+ }
44
+ </style>
45
+ </head>
46
+ <body class="bg-gray-900 text-white">
47
+ <div id="game-container">
48
+ <div id="ui-overlay" class="p-4">
49
+ <div class="flex justify-between items-start">
50
+ <!-- Building selection panel -->
51
+ <div class="bg-gray-800 bg-opacity-80 rounded-lg p-4 shadow-lg">
52
+ <h2 class="text-xl font-bold mb-3">Buildings</h2>
53
+ <div class="grid grid-cols-3 gap-3">
54
+ <div class="building-option bg-blue-600 rounded p-2 cursor-pointer text-center" data-type="house">
55
+ <div class="h-12 w-12 bg-blue-400 mx-auto mb-1"></div>
56
+ <span>House</span>
57
+ </div>
58
+ <div class="building-option bg-green-600 rounded p-2 cursor-pointer text-center" data-type="office">
59
+ <div class="h-12 w-12 bg-green-400 mx-auto mb-1"></div>
60
+ <span>Office</span>
61
+ </div>
62
+ <div class="building-option bg-yellow-600 rounded p-2 cursor-pointer text-center" data-type="park">
63
+ <div class="h-12 w-12 bg-yellow-400 mx-auto mb-1"></div>
64
+ <span>Park</span>
65
+ </div>
66
+ <div class="building-option bg-red-600 rounded p-2 cursor-pointer text-center" data-type="hospital">
67
+ <div class="h-12 w-12 bg-red-400 mx-auto mb-1"></div>
68
+ <span>Hospital</span>
69
+ </div>
70
+ <div class="building-option bg-purple-600 rounded p-2 cursor-pointer text-center" data-type="school">
71
+ <div class="h-12 w-12 bg-purple-400 mx-auto mb-1"></div>
72
+ <span>School</span>
73
+ </div>
74
+ <div class="building-option bg-gray-600 rounded p-2 cursor-pointer text-center" data-type="road">
75
+ <div class="h-12 w-12 bg-gray-400 mx-auto mb-1"></div>
76
+ <span>Road</span>
77
+ </div>
78
+ </div>
79
+ </div>
80
+
81
+ <!-- Stats panel -->
82
+ <div class="bg-gray-800 bg-opacity-80 rounded-lg p-4 shadow-lg">
83
+ <h2 class="text-xl font-bold mb-3">City Stats</h2>
84
+ <div class="space-y-2">
85
+ <div>Population: <span id="population">0</span></div>
86
+ <div>Buildings: <span id="building-count">0</span></div>
87
+ <div>Money: $<span id="money">10000</span></div>
88
+ </div>
89
+ <button id="demolish-btn" class="mt-4 bg-red-600 hover:bg-red-700 text-white py-2 px-4 rounded pointer-events-all">
90
+ Demolish Mode
91
+ </button>
92
+ </div>
93
+ </div>
94
+
95
+ <!-- Bottom panel -->
96
+ <div class="absolute bottom-4 left-0 w-full flex justify-center">
97
+ <div class="bg-gray-800 bg-opacity-80 rounded-lg p-3 shadow-lg">
98
+ <div id="message" class="text-center">Select a building to place</div>
99
+ </div>
100
+ </div>
101
+ </div>
102
+
103
+ <div id="grid-highlight"></div>
104
+ </div>
105
+
106
+ <script>
107
+ // Game variables
108
+ let selectedBuildingType = null;
109
+ let demolishMode = false;
110
+ let money = 10000;
111
+ let population = 0;
112
+ let buildingCount = 0;
113
+
114
+ // Building costs
115
+ const buildingCosts = {
116
+ house: 500,
117
+ office: 1000,
118
+ park: 300,
119
+ hospital: 1500,
120
+ school: 1200,
121
+ road: 100
122
+ };
123
+
124
+ // Building population values
125
+ const buildingPopulation = {
126
+ house: 10,
127
+ office: -5, // Offices reduce population (workers come from houses)
128
+ park: 0,
129
+ hospital: 0,
130
+ school: 0,
131
+ road: 0
132
+ };
133
+
134
+ // Three.js variables
135
+ let scene, camera, renderer, controls;
136
+ let grid = [];
137
+ const gridSize = 20;
138
+ const cellSize = 2;
139
+ const buildings = [];
140
+
141
+ // Initialize the game
142
+ init();
143
+
144
+ function init() {
145
+ // Set up Three.js scene
146
+ scene = new THREE.Scene();
147
+ scene.background = new THREE.Color(0x87CEEB); // Sky blue
148
+
149
+ // Set up camera
150
+ camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
151
+ camera.position.set(20, 30, 20);
152
+ camera.lookAt(0, 0, 0);
153
+
154
+ // Set up renderer
155
+ renderer = new THREE.WebGLRenderer({ antialias: true });
156
+ renderer.setSize(window.innerWidth, window.innerHeight);
157
+ document.getElementById('game-container').appendChild(renderer.domElement);
158
+
159
+ // Add orbit controls
160
+ controls = new THREE.OrbitControls(camera, renderer.domElement);
161
+ controls.enableDamping = true;
162
+ controls.dampingFactor = 0.05;
163
+
164
+ // Add lights
165
+ const ambientLight = new THREE.AmbientLight(0x404040);
166
+ scene.add(ambientLight);
167
+
168
+ const directionalLight = new THREE.DirectionalLight(0xffffff, 1);
169
+ directionalLight.position.set(1, 1, 1);
170
+ scene.add(directionalLight);
171
+
172
+ // Create ground grid
173
+ createGround();
174
+
175
+ // Handle window resize
176
+ window.addEventListener('resize', onWindowResize);
177
+
178
+ // Set up UI event listeners
179
+ setupUI();
180
+
181
+ // Start animation loop
182
+ animate();
183
+ }
184
+
185
+ function createGround() {
186
+ // Create ground plane
187
+ const groundGeometry = new THREE.PlaneGeometry(gridSize * cellSize, gridSize * cellSize);
188
+ const groundMaterial = new THREE.MeshStandardMaterial({
189
+ color: 0x3a5f0b,
190
+ side: THREE.DoubleSide
191
+ });
192
+ const ground = new THREE.Mesh(groundGeometry, groundMaterial);
193
+ ground.rotation.x = -Math.PI / 2;
194
+ scene.add(ground);
195
+
196
+ // Create grid lines
197
+ const gridHelper = new THREE.GridHelper(gridSize * cellSize, gridSize);
198
+ scene.add(gridHelper);
199
+
200
+ // Initialize grid array
201
+ for (let i = 0; i < gridSize; i++) {
202
+ grid[i] = [];
203
+ for (let j = 0; j < gridSize; j++) {
204
+ grid[i][j] = null; // null means empty cell
205
+ }
206
+ }
207
+ }
208
+
209
+ function setupUI() {
210
+ // Building selection
211
+ document.querySelectorAll('.building-option').forEach(option => {
212
+ option.addEventListener('click', function() {
213
+ selectedBuildingType = this.getAttribute('data-type');
214
+ demolishMode = false;
215
+
216
+ // Update UI
217
+ document.querySelectorAll('.building-option').forEach(el => el.classList.remove('selected'));
218
+ this.classList.add('selected');
219
+ document.getElementById('demolish-btn').classList.remove('bg-red-700');
220
+ document.getElementById('demolish-btn').classList.add('bg-red-600');
221
+
222
+ document.getElementById('message').textContent = `Selected: ${selectedBuildingType.charAt(0).toUpperCase() + selectedBuildingType.slice(1)} (Cost: $${buildingCosts[selectedBuildingType]})`;
223
+ });
224
+ });
225
+
226
+ // Demolish mode button
227
+ document.getElementById('demolish-btn').addEventListener('click', function() {
228
+ demolishMode = !demolishMode;
229
+ selectedBuildingType = null;
230
+
231
+ // Update UI
232
+ document.querySelectorAll('.building-option').forEach(el => el.classList.remove('selected'));
233
+ if (demolishMode) {
234
+ this.classList.remove('bg-red-600');
235
+ this.classList.add('bg-red-700');
236
+ document.getElementById('message').textContent = 'Demolish mode active - Click buildings to remove them';
237
+ } else {
238
+ this.classList.remove('bg-red-700');
239
+ this.classList.add('bg-red-600');
240
+ document.getElementById('message').textContent = 'Select a building to place';
241
+ }
242
+ });
243
+
244
+ // Mouse move for grid highlight
245
+ document.addEventListener('mousemove', onMouseMove);
246
+
247
+ // Click to place building
248
+ document.addEventListener('click', onClick);
249
+ }
250
+
251
+ function onMouseMove(event) {
252
+ if (!selectedBuildingType && !demolishMode) {
253
+ document.getElementById('grid-highlight').style.display = 'none';
254
+ return;
255
+ }
256
+
257
+ // Get mouse position in normalized device coordinates (-1 to +1)
258
+ const mouse = new THREE.Vector2();
259
+ mouse.x = (event.clientX / window.innerWidth) * 2 - 1;
260
+ mouse.y = -(event.clientY / window.innerHeight) * 2 + 1;
261
+
262
+ // Raycast to find intersection with ground
263
+ const raycaster = new THREE.Raycaster();
264
+ raycaster.setFromCamera(mouse, camera);
265
+
266
+ const intersects = raycaster.intersectObjects(scene.children);
267
+
268
+ if (intersects.length > 0) {
269
+ const point = intersects[0].point;
270
+
271
+ // Snap to grid
272
+ const gridX = Math.round(point.x / cellSize) * cellSize;
273
+ const gridZ = Math.round(point.z / cellSize) * cellSize;
274
+
275
+ // Convert to grid coordinates
276
+ const gridI = Math.round(point.x / cellSize) + gridSize / 2;
277
+ const gridJ = Math.round(point.z / cellSize) + gridSize / 2;
278
+
279
+ // Check if within grid bounds
280
+ if (gridI >= 0 && gridI < gridSize && gridJ >= 0 && gridJ < gridSize) {
281
+ // Show highlight
282
+ const highlight = document.getElementById('grid-highlight');
283
+ highlight.style.width = `${cellSize * 50}px`;
284
+ highlight.style.height = `${cellSize * 50}px`;
285
+ highlight.style.left = `${event.clientX - cellSize * 25}px`;
286
+ highlight.style.top = `${event.clientY - cellSize * 25}px`;
287
+ highlight.style.display = 'block';
288
+
289
+ // Change color based on availability
290
+ if (grid[gridI][gridJ] === null || demolishMode) {
291
+ highlight.style.backgroundColor = 'rgba(255, 255, 255, 0.3)';
292
+ } else {
293
+ highlight.style.backgroundColor = 'rgba(255, 0, 0, 0.3)';
294
+ }
295
+ } else {
296
+ document.getElementById('grid-highlight').style.display = 'none';
297
+ }
298
+ } else {
299
+ document.getElementById('grid-highlight').style.display = 'none';
300
+ }
301
+ }
302
+
303
+ function onClick(event) {
304
+ if (!selectedBuildingType && !demolishMode) return;
305
+
306
+ // Get mouse position in normalized device coordinates (-1 to +1)
307
+ const mouse = new THREE.Vector2();
308
+ mouse.x = (event.clientX / window.innerWidth) * 2 - 1;
309
+ mouse.y = -(event.clientY / window.innerHeight) * 2 + 1;
310
+
311
+ // Raycast to find intersection with ground
312
+ const raycaster = new THREE.Raycaster();
313
+ raycaster.setFromCamera(mouse, camera);
314
+
315
+ const intersects = raycaster.intersectObjects(scene.children);
316
+
317
+ if (intersects.length > 0) {
318
+ const point = intersects[0].point;
319
+
320
+ // Convert to grid coordinates
321
+ const gridI = Math.round(point.x / cellSize) + gridSize / 2;
322
+ const gridJ = Math.round(point.z / cellSize) + gridSize / 2;
323
+
324
+ // Check if within grid bounds
325
+ if (gridI >= 0 && gridI < gridSize && gridJ >= 0 && gridJ < gridSize) {
326
+ if (demolishMode) {
327
+ // Demolish building
328
+ if (grid[gridI][gridJ] !== null) {
329
+ removeBuilding(gridI, gridJ);
330
+ }
331
+ } else {
332
+ // Place building
333
+ if (grid[gridI][gridJ] === null) {
334
+ if (money >= buildingCosts[selectedBuildingType]) {
335
+ placeBuilding(selectedBuildingType, gridI, gridJ);
336
+ } else {
337
+ document.getElementById('message').textContent = `Not enough money! Need $${buildingCosts[selectedBuildingType]}`;
338
+ }
339
+ }
340
+ }
341
+ }
342
+ }
343
+ }
344
+
345
+ function placeBuilding(type, gridI, gridJ) {
346
+ // Calculate world position
347
+ const x = (gridI - gridSize / 2) * cellSize;
348
+ const z = (gridJ - gridSize / 2) * cellSize;
349
+
350
+ let buildingMesh;
351
+ let height = 1;
352
+
353
+ // Create different building types
354
+ switch (type) {
355
+ case 'house':
356
+ height = 1.5;
357
+ const houseGeometry = new THREE.BoxGeometry(1.8, height, 1.8);
358
+ const houseMaterial = new THREE.MeshStandardMaterial({ color: 0x4682B4 });
359
+ buildingMesh = new THREE.Mesh(houseGeometry, houseMaterial);
360
+ break;
361
+
362
+ case 'office':
363
+ height = 3;
364
+ const officeGeometry = new THREE.BoxGeometry(1.8, height, 1.8);
365
+ const officeMaterial = new THREE.MeshStandardMaterial({ color: 0x708090 });
366
+ buildingMesh = new THREE.Mesh(officeGeometry, officeMaterial);
367
+ break;
368
+
369
+ case 'park':
370
+ height = 0.2;
371
+ const parkGeometry = new THREE.BoxGeometry(1.8, height, 1.8);
372
+ const parkMaterial = new THREE.MeshStandardMaterial({ color: 0x32CD32 });
373
+ buildingMesh = new THREE.Mesh(parkGeometry, parkMaterial);
374
+ break;
375
+
376
+ case 'hospital':
377
+ height = 2.5;
378
+ const hospitalGeometry = new THREE.BoxGeometry(1.8, height, 1.8);
379
+ const hospitalMaterial = new THREE.MeshStandardMaterial({ color: 0xFFFAFA });
380
+ buildingMesh = new THREE.Mesh(hospitalGeometry, hospitalMaterial);
381
+
382
+ // Add red cross
383
+ const crossGeometry = new THREE.BoxGeometry(1.8, 0.2, 0.2);
384
+ const crossMaterial = new THREE.MeshStandardMaterial({ color: 0xFF0000 });
385
+ const cross1 = new THREE.Mesh(crossGeometry, crossMaterial);
386
+ cross1.position.y = height + 0.1;
387
+
388
+ const cross2 = new THREE.Mesh(crossGeometry, crossMaterial);
389
+ cross2.position.y = height + 0.1;
390
+ cross2.rotation.y = Math.PI / 2;
391
+
392
+ scene.add(cross1);
393
+ scene.add(cross2);
394
+ break;
395
+
396
+ case 'school':
397
+ height = 2;
398
+ const schoolGeometry = new THREE.BoxGeometry(1.8, height, 1.8);
399
+ const schoolMaterial = new THREE.MeshStandardMaterial({ color: 0xF5DEB3 });
400
+ buildingMesh = new THREE.Mesh(schoolGeometry, schoolMaterial);
401
+ break;
402
+
403
+ case 'road':
404
+ height = 0.1;
405
+ const roadGeometry = new THREE.BoxGeometry(1.8, height, 1.8);
406
+ const roadMaterial = new THREE.MeshStandardMaterial({ color: 0x696969 });
407
+ buildingMesh = new THREE.Mesh(roadGeometry, roadMaterial);
408
+ break;
409
+ }
410
+
411
+ // Position the building
412
+ buildingMesh.position.set(x, height / 2, z);
413
+ scene.add(buildingMesh);
414
+
415
+ // Add to grid
416
+ grid[gridI][gridJ] = { type, mesh: buildingMesh };
417
+
418
+ </html>
prompts.txt ADDED
File without changes