Add 2 files
Browse files- index.html +73 -755
- prompts.txt +2 -1
index.html
CHANGED
@@ -3,37 +3,26 @@
|
|
3 |
<head>
|
4 |
<meta charset="UTF-8">
|
5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
-
<title>GTA
|
7 |
<style>
|
8 |
body {
|
9 |
margin: 0;
|
10 |
-
padding: 0;
|
11 |
overflow: hidden;
|
12 |
background-color: #222;
|
13 |
font-family: Arial, sans-serif;
|
14 |
}
|
15 |
-
|
16 |
-
#gameContainer {
|
17 |
-
position: relative;
|
18 |
-
width: 100vw;
|
19 |
-
height: 100vh;
|
20 |
-
}
|
21 |
-
|
22 |
#gameCanvas {
|
23 |
display: block;
|
24 |
background-color: #87CEEB;
|
25 |
}
|
26 |
-
|
27 |
-
#uiContainer {
|
28 |
position: absolute;
|
29 |
top: 10px;
|
30 |
left: 10px;
|
31 |
color: white;
|
32 |
font-size: 16px;
|
33 |
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.7);
|
34 |
-
pointer-events: none;
|
35 |
}
|
36 |
-
|
37 |
#startScreen {
|
38 |
position: absolute;
|
39 |
top: 0;
|
@@ -46,111 +35,39 @@
|
|
46 |
justify-content: center;
|
47 |
align-items: center;
|
48 |
color: white;
|
49 |
-
z-index: 100;
|
50 |
-
}
|
51 |
-
|
52 |
-
#startScreen h1 {
|
53 |
-
font-size: 48px;
|
54 |
-
color: #FF4500;
|
55 |
-
margin-bottom: 30px;
|
56 |
-
text-shadow: 0 0 10px rgba(255, 69, 0, 0.7);
|
57 |
}
|
58 |
-
|
59 |
#startButton {
|
60 |
padding: 15px 30px;
|
61 |
-
font-size:
|
62 |
background-color: #FF4500;
|
63 |
color: white;
|
64 |
border: none;
|
65 |
border-radius: 5px;
|
66 |
cursor: pointer;
|
67 |
-
|
68 |
-
}
|
69 |
-
|
70 |
-
#startButton:hover {
|
71 |
-
background-color: #FF6347;
|
72 |
-
transform: scale(1.05);
|
73 |
-
}
|
74 |
-
|
75 |
-
#wantedLevel {
|
76 |
-
position: absolute;
|
77 |
-
top: 10px;
|
78 |
-
right: 10px;
|
79 |
-
color: white;
|
80 |
-
font-size: 24px;
|
81 |
-
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.7);
|
82 |
-
}
|
83 |
-
|
84 |
-
.wanted-star {
|
85 |
-
color: yellow;
|
86 |
-
margin-left: 5px;
|
87 |
-
}
|
88 |
-
|
89 |
-
#missionText {
|
90 |
-
position: absolute;
|
91 |
-
bottom: 20px;
|
92 |
-
left: 0;
|
93 |
-
width: 100%;
|
94 |
-
text-align: center;
|
95 |
-
color: white;
|
96 |
-
font-size: 24px;
|
97 |
-
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.7);
|
98 |
-
opacity: 0;
|
99 |
-
transition: opacity 0.5s;
|
100 |
-
}
|
101 |
-
|
102 |
-
#radio {
|
103 |
-
position: absolute;
|
104 |
-
bottom: 60px;
|
105 |
-
left: 10px;
|
106 |
-
color: white;
|
107 |
-
font-size: 14px;
|
108 |
-
font-style: italic;
|
109 |
}
|
110 |
</style>
|
111 |
</head>
|
112 |
<body>
|
113 |
-
<
|
114 |
-
|
115 |
-
|
116 |
-
<div id="
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
</
|
122 |
-
|
123 |
-
<div id="wantedLevel">
|
124 |
-
Wanted: <span id="wantedStars"></span>
|
125 |
-
</div>
|
126 |
-
|
127 |
-
<div id="missionText"></div>
|
128 |
-
|
129 |
-
<div id="radio">
|
130 |
-
Radio: <span id="radioStation">Off</span>
|
131 |
-
</div>
|
132 |
-
|
133 |
-
<div id="startScreen">
|
134 |
-
<h1>GTA 5 Online Clone</h1>
|
135 |
-
<p>Drive around the city, complete missions, and avoid the police!</p>
|
136 |
-
<p>Controls: Arrow keys to drive, Space to handbrake, H to honk</p>
|
137 |
-
<button id="startButton">START GAME</button>
|
138 |
-
</div>
|
139 |
</div>
|
140 |
|
141 |
<script>
|
142 |
-
// Game
|
143 |
const canvas = document.getElementById('gameCanvas');
|
144 |
const ctx = canvas.getContext('2d');
|
145 |
const startScreen = document.getElementById('startScreen');
|
146 |
const startButton = document.getElementById('startButton');
|
147 |
const moneyDisplay = document.getElementById('money');
|
148 |
-
const scoreDisplay = document.getElementById('score');
|
149 |
const healthDisplay = document.getElementById('health');
|
150 |
-
const speedDisplay = document.getElementById('speed');
|
151 |
-
const wantedStarsDisplay = document.getElementById('wantedStars');
|
152 |
-
const missionText = document.getElementById('missionText');
|
153 |
-
const radioStation = document.getElementById('radioStation');
|
154 |
|
155 |
// Set canvas size
|
156 |
canvas.width = window.innerWidth;
|
@@ -158,25 +75,8 @@
|
|
158 |
|
159 |
// Game state
|
160 |
let gameRunning = false;
|
161 |
-
let lastTime = 0;
|
162 |
-
let score = 0;
|
163 |
let money = 0;
|
164 |
-
let
|
165 |
-
let wantedLevel = 0;
|
166 |
-
let currentMission = null;
|
167 |
-
let missionCompleteTimeout = null;
|
168 |
-
|
169 |
-
// Radio stations
|
170 |
-
const radioStations = [
|
171 |
-
"Off",
|
172 |
-
"Los Santos Rock Radio",
|
173 |
-
"Space 103.2",
|
174 |
-
"West Coast Classics",
|
175 |
-
"FlyLo FM",
|
176 |
-
"The Lowdown 91.1",
|
177 |
-
"Radio Mirror Park"
|
178 |
-
];
|
179 |
-
let currentRadioIndex = 0;
|
180 |
|
181 |
// Player car
|
182 |
const player = {
|
@@ -184,329 +84,62 @@
|
|
184 |
y: canvas.height / 2,
|
185 |
width: 40,
|
186 |
height: 70,
|
187 |
-
color: '#FF4500',
|
188 |
speed: 0,
|
189 |
-
maxSpeed:
|
190 |
-
acceleration: 0.1,
|
191 |
-
deceleration: 0.05,
|
192 |
rotation: 0,
|
193 |
-
|
194 |
-
health: 100,
|
195 |
-
lastCollisionTime: 0
|
196 |
};
|
197 |
|
198 |
-
//
|
199 |
const roads = [];
|
200 |
-
const buildings = [];
|
201 |
-
const trees = [];
|
202 |
-
const npcCars = [];
|
203 |
-
const policeCars = [];
|
204 |
-
const collectibles = [];
|
205 |
-
const explosions = [];
|
206 |
|
207 |
-
// Generate city
|
208 |
function generateCity() {
|
209 |
-
// Clear existing elements
|
210 |
roads.length = 0;
|
211 |
-
buildings.length = 0;
|
212 |
-
trees.length = 0;
|
213 |
-
|
214 |
-
// Generate roads
|
215 |
-
const roadWidth = 200;
|
216 |
-
const horizontalRoadCount = Math.ceil(canvas.height / 300);
|
217 |
-
const verticalRoadCount = Math.ceil(canvas.width / 300);
|
218 |
|
219 |
-
|
|
|
220 |
roads.push({
|
221 |
x: 0,
|
222 |
-
y:
|
223 |
width: canvas.width,
|
224 |
-
height:
|
225 |
-
horizontal: true
|
226 |
});
|
227 |
}
|
228 |
|
229 |
-
|
|
|
230 |
roads.push({
|
231 |
-
x:
|
232 |
y: 0,
|
233 |
-
width:
|
234 |
-
height: canvas.height
|
235 |
-
horizontal: false
|
236 |
-
});
|
237 |
-
}
|
238 |
-
|
239 |
-
// Generate buildings
|
240 |
-
for (let i = 0; i < 50; i++) {
|
241 |
-
const size = 50 + Math.random() * 100;
|
242 |
-
buildings.push({
|
243 |
-
x: Math.random() * canvas.width,
|
244 |
-
y: Math.random() * canvas.height,
|
245 |
-
width: size,
|
246 |
-
height: size,
|
247 |
-
color: `rgb(${100 + Math.random() * 155}, ${100 + Math.random() * 155}, ${100 + Math.random() * 155})`
|
248 |
-
});
|
249 |
-
}
|
250 |
-
|
251 |
-
// Generate trees
|
252 |
-
for (let i = 0; i < 100; i++) {
|
253 |
-
trees.push({
|
254 |
-
x: Math.random() * canvas.width,
|
255 |
-
y: Math.random() * canvas.height,
|
256 |
-
size: 20 + Math.random() * 30,
|
257 |
-
color: '#228B22'
|
258 |
});
|
259 |
}
|
260 |
|
261 |
-
// Position player at
|
262 |
-
|
263 |
-
player.
|
264 |
-
player.y = road.y + road.height / 2;
|
265 |
}
|
266 |
|
267 |
-
//
|
268 |
-
function generateNPC() {
|
269 |
-
npcCars.length = 0;
|
270 |
-
|
271 |
-
for (let i = 0; i < 10; i++) {
|
272 |
-
const road = roads[Math.floor(Math.random() * roads.length)];
|
273 |
-
|
274 |
-
npcCars.push({
|
275 |
-
x: road.horizontal ?
|
276 |
-
Math.random() * canvas.width :
|
277 |
-
road.x + road.width / 2,
|
278 |
-
y: road.horizontal ?
|
279 |
-
road.y + road.height / 2 :
|
280 |
-
Math.random() * canvas.height,
|
281 |
-
width: 30,
|
282 |
-
height: 50,
|
283 |
-
color: `hsl(${Math.random() * 360}, 70%, 50%)`,
|
284 |
-
speed: 2 + Math.random() * 3,
|
285 |
-
direction: road.horizontal ? (Math.random() > 0.5 ? 0 : Math.PI) : (Math.random() > 0.5 ? Math.PI/2 : 3*Math.PI/2),
|
286 |
-
road: road
|
287 |
-
});
|
288 |
-
}
|
289 |
-
}
|
290 |
-
|
291 |
-
// Generate collectibles
|
292 |
-
function generateCollectibles() {
|
293 |
-
collectibles.length = 0;
|
294 |
-
|
295 |
-
for (let i = 0; i < 15; i++) {
|
296 |
-
collectibles.push({
|
297 |
-
x: Math.random() * canvas.width,
|
298 |
-
y: Math.random() * canvas.height,
|
299 |
-
radius: 15,
|
300 |
-
type: Math.random() > 0.5 ? 'money' : 'health',
|
301 |
-
value: Math.random() > 0.7 ? 100 : 50,
|
302 |
-
collected: false
|
303 |
-
});
|
304 |
-
}
|
305 |
-
}
|
306 |
-
|
307 |
-
// Draw rotated rectangle (for cars)
|
308 |
function drawRotatedRect(x, y, width, height, rotation, color) {
|
309 |
ctx.save();
|
310 |
ctx.translate(x, y);
|
311 |
ctx.rotate(rotation);
|
312 |
ctx.fillStyle = color;
|
313 |
-
ctx.fillRect(-width
|
314 |
|
315 |
-
// Add
|
316 |
-
ctx.fillStyle = '#
|
317 |
-
ctx.fillRect(-width
|
318 |
ctx.restore();
|
319 |
}
|
320 |
|
321 |
-
// Check collision between two rectangles
|
322 |
-
function checkCollision(rect1, rect2) {
|
323 |
-
return rect1.x < rect2.x + rect2.width &&
|
324 |
-
rect1.x + rect1.width > rect2.x &&
|
325 |
-
rect1.y < rect2.y + rect2.height &&
|
326 |
-
rect1.y + rect1.height > rect2.y;
|
327 |
-
}
|
328 |
-
|
329 |
-
// Check if point is in rectangle
|
330 |
-
function pointInRect(x, y, rect) {
|
331 |
-
return x > rect.x && x < rect.x + rect.width &&
|
332 |
-
y > rect.y && y < rect.y + rect.height;
|
333 |
-
}
|
334 |
-
|
335 |
-
// Get distance between two points
|
336 |
-
function getDistance(x1, y1, x2, y2) {
|
337 |
-
return Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));
|
338 |
-
}
|
339 |
-
|
340 |
-
// Create explosion effect
|
341 |
-
function createExplosion(x, y) {
|
342 |
-
explosions.push({
|
343 |
-
x: x,
|
344 |
-
y: y,
|
345 |
-
radius: 5,
|
346 |
-
maxRadius: 50,
|
347 |
-
alpha: 1,
|
348 |
-
color: `hsl(${Math.random() * 60}, 100%, 50%)`
|
349 |
-
});
|
350 |
-
}
|
351 |
-
|
352 |
-
// Spawn police cars
|
353 |
-
function spawnPolice() {
|
354 |
-
const count = wantedLevel;
|
355 |
-
|
356 |
-
for (let i = 0; i < count; i++) {
|
357 |
-
// Don't spawn more than 5 police cars
|
358 |
-
if (policeCars.length >= 5) break;
|
359 |
-
|
360 |
-
// Spawn police car at edge of screen
|
361 |
-
let x, y;
|
362 |
-
const side = Math.floor(Math.random() * 4);
|
363 |
-
|
364 |
-
switch (side) {
|
365 |
-
case 0: // top
|
366 |
-
x = Math.random() * canvas.width;
|
367 |
-
y = -50;
|
368 |
-
break;
|
369 |
-
case 1: // right
|
370 |
-
x = canvas.width + 50;
|
371 |
-
y = Math.random() * canvas.height;
|
372 |
-
break;
|
373 |
-
case 2: // bottom
|
374 |
-
x = Math.random() * canvas.width;
|
375 |
-
y = canvas.height + 50;
|
376 |
-
break;
|
377 |
-
case 3: // left
|
378 |
-
x = -50;
|
379 |
-
y = Math.random() * canvas.height;
|
380 |
-
break;
|
381 |
-
}
|
382 |
-
|
383 |
-
policeCars.push({
|
384 |
-
x: x,
|
385 |
-
y: y,
|
386 |
-
width: 35,
|
387 |
-
height: 60,
|
388 |
-
color: '#4169E1',
|
389 |
-
speed: 4 + wantedLevel,
|
390 |
-
rotation: Math.atan2(player.y - y, player.x - x),
|
391 |
-
health: 100,
|
392 |
-
lastShotTime: 0
|
393 |
-
});
|
394 |
-
}
|
395 |
-
}
|
396 |
-
|
397 |
-
// Update wanted level
|
398 |
-
function updateWantedLevel(level) {
|
399 |
-
wantedLevel = Math.min(Math.max(level, 0), 5);
|
400 |
-
|
401 |
-
// Update display
|
402 |
-
wantedStarsDisplay.innerHTML = '';
|
403 |
-
for (let i = 0; i < wantedLevel; i++) {
|
404 |
-
wantedStarsDisplay.innerHTML += '<span class="wanted-star">★</span>';
|
405 |
-
}
|
406 |
-
|
407 |
-
// Spawn police if needed
|
408 |
-
if (wantedLevel > 0 && policeCars.length < wantedLevel) {
|
409 |
-
spawnPolice();
|
410 |
-
}
|
411 |
-
}
|
412 |
-
|
413 |
-
// Show mission text
|
414 |
-
function showMission(text) {
|
415 |
-
missionText.textContent = text;
|
416 |
-
missionText.style.opacity = 1;
|
417 |
-
|
418 |
-
if (missionCompleteTimeout) {
|
419 |
-
clearTimeout(missionCompleteTimeout);
|
420 |
-
}
|
421 |
-
|
422 |
-
missionCompleteTimeout = setTimeout(() => {
|
423 |
-
missionText.style.opacity = 0;
|
424 |
-
}, 3000);
|
425 |
-
}
|
426 |
-
|
427 |
-
// Start a random mission
|
428 |
-
function startRandomMission() {
|
429 |
-
const missions = [
|
430 |
-
{
|
431 |
-
name: "Collect Cash",
|
432 |
-
description: "Collect $500 in cash",
|
433 |
-
target: 500,
|
434 |
-
current: 0,
|
435 |
-
type: "money"
|
436 |
-
},
|
437 |
-
{
|
438 |
-
name: "Avoid Police",
|
439 |
-
description: "Avoid police for 30 seconds",
|
440 |
-
target: 30,
|
441 |
-
current: 0,
|
442 |
-
type: "avoid"
|
443 |
-
},
|
444 |
-
{
|
445 |
-
name: "Destroy Police",
|
446 |
-
description: "Destroy 3 police cars",
|
447 |
-
target: 3,
|
448 |
-
current: 0,
|
449 |
-
type: "destroy"
|
450 |
-
},
|
451 |
-
{
|
452 |
-
name: "Speed Demon",
|
453 |
-
description: "Drive over 100 mph for 5 seconds",
|
454 |
-
target: 5,
|
455 |
-
current: 0,
|
456 |
-
type: "speed"
|
457 |
-
}
|
458 |
-
];
|
459 |
-
|
460 |
-
currentMission = missions[Math.floor(Math.random() * missions.length)];
|
461 |
-
showMission(`MISSION: ${currentMission.name} - ${currentMission.description}`);
|
462 |
-
}
|
463 |
-
|
464 |
-
// Check mission progress
|
465 |
-
function checkMissionProgress() {
|
466 |
-
if (!currentMission) return;
|
467 |
-
|
468 |
-
switch (currentMission.type) {
|
469 |
-
case "money":
|
470 |
-
currentMission.current = money;
|
471 |
-
break;
|
472 |
-
case "avoid":
|
473 |
-
if (wantedLevel === 0) {
|
474 |
-
currentMission.current += 1/60; // Assuming 60 FPS
|
475 |
-
}
|
476 |
-
break;
|
477 |
-
case "destroy":
|
478 |
-
// Handled in collision detection
|
479 |
-
break;
|
480 |
-
case "speed":
|
481 |
-
const speedMph = Math.abs(player.speed) * 10;
|
482 |
-
if (speedMph > 100) {
|
483 |
-
currentMission.current += 1/60;
|
484 |
-
}
|
485 |
-
break;
|
486 |
-
}
|
487 |
-
|
488 |
-
// Check if mission is complete
|
489 |
-
if (currentMission.current >= currentMission.target) {
|
490 |
-
const reward = currentMission.target * 10;
|
491 |
-
money += reward;
|
492 |
-
moneyDisplay.textContent = money;
|
493 |
-
|
494 |
-
showMission(`MISSION COMPLETE! +$${reward}`);
|
495 |
-
currentMission = null;
|
496 |
-
|
497 |
-
// Start new mission after delay
|
498 |
-
setTimeout(startRandomMission, 5000);
|
499 |
-
}
|
500 |
-
}
|
501 |
-
|
502 |
// Game loop
|
503 |
-
function gameLoop(
|
504 |
if (!gameRunning) return;
|
505 |
|
506 |
-
// Calculate delta time
|
507 |
-
const deltaTime = timestamp - lastTime;
|
508 |
-
lastTime = timestamp;
|
509 |
-
|
510 |
// Clear canvas
|
511 |
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
512 |
|
@@ -515,312 +148,52 @@
|
|
515 |
roads.forEach(road => {
|
516 |
ctx.fillRect(road.x, road.y, road.width, road.height);
|
517 |
|
518 |
-
//
|
519 |
ctx.fillStyle = 'white';
|
520 |
-
if (road.
|
521 |
-
|
522 |
-
|
523 |
-
const centerY = road.y + road.height / 2 - 2;
|
524 |
-
|
525 |
-
for (let x = 0; x < road.width; x += dashLength + gapLength) {
|
526 |
-
ctx.fillRect(road.x + x, centerY, dashLength, 4);
|
527 |
}
|
528 |
-
} else {
|
529 |
-
|
530 |
-
|
531 |
-
const centerX = road.x + road.width / 2 - 2;
|
532 |
-
|
533 |
-
for (let y = 0; y < road.height; y += dashLength + gapLength) {
|
534 |
-
ctx.fillRect(centerX, road.y + y, 4, dashLength);
|
535 |
}
|
536 |
}
|
537 |
ctx.fillStyle = '#333';
|
538 |
});
|
539 |
|
540 |
-
//
|
541 |
-
|
542 |
-
|
543 |
-
ctx.fillRect(building.x, building.y, building.width, building.height);
|
544 |
-
|
545 |
-
// Add windows
|
546 |
-
const windowSize = 8;
|
547 |
-
const windowMargin = 10;
|
548 |
-
ctx.fillStyle = '#ADD8E6';
|
549 |
-
|
550 |
-
for (let y = building.y + windowMargin; y < building.y + building.height - windowMargin; y += windowSize + windowMargin) {
|
551 |
-
for (let x = building.x + windowMargin; x < building.x + building.width - windowMargin; x += windowSize + windowMargin) {
|
552 |
-
// Randomly turn some windows off
|
553 |
-
if (Math.random() > 0.3) {
|
554 |
-
ctx.fillRect(x, y, windowSize, windowSize);
|
555 |
-
}
|
556 |
-
}
|
557 |
-
}
|
558 |
-
});
|
559 |
-
|
560 |
-
// Draw trees
|
561 |
-
trees.forEach(tree => {
|
562 |
-
// Trunk
|
563 |
-
ctx.fillStyle = '#8B4513';
|
564 |
-
ctx.fillRect(tree.x - 3, tree.y - tree.size/2, 6, tree.size/2);
|
565 |
-
|
566 |
-
// Leaves
|
567 |
-
ctx.fillStyle = tree.color;
|
568 |
-
ctx.beginPath();
|
569 |
-
ctx.arc(tree.x, tree.y - tree.size/2, tree.size/2, 0, Math.PI * 2);
|
570 |
-
ctx.fill();
|
571 |
-
});
|
572 |
-
|
573 |
-
// Update and draw NPC cars
|
574 |
-
npcCars.forEach((car, index) => {
|
575 |
-
// Move car along road
|
576 |
-
if (car.road.horizontal) {
|
577 |
-
car.x += Math.cos(car.direction) * car.speed;
|
578 |
-
|
579 |
-
// If car goes off screen, reset to other side
|
580 |
-
if (car.direction === 0 && car.x > canvas.width + car.width/2) {
|
581 |
-
car.x = -car.width/2;
|
582 |
-
} else if (car.direction === Math.PI && car.x < -car.width/2) {
|
583 |
-
car.x = canvas.width + car.width/2;
|
584 |
-
}
|
585 |
-
} else {
|
586 |
-
car.y += Math.sin(car.direction) * car.speed;
|
587 |
-
|
588 |
-
// If car goes off screen, reset to other side
|
589 |
-
if (car.direction === Math.PI/2 && car.y > canvas.height + car.height/2) {
|
590 |
-
car.y = -car.height/2;
|
591 |
-
} else if (car.direction === 3*Math.PI/2 && car.y < -car.height/2) {
|
592 |
-
car.y = canvas.height + car.height/2;
|
593 |
-
}
|
594 |
-
}
|
595 |
-
|
596 |
-
// Draw NPC car
|
597 |
-
drawRotatedRect(car.x, car.y, car.width, car.height, car.direction, car.color);
|
598 |
-
|
599 |
-
// Check collision with player
|
600 |
-
const now = Date.now();
|
601 |
-
if (checkCollision(
|
602 |
-
{x: player.x - player.width/2, y: player.y - player.height/2, width: player.width, height: player.height},
|
603 |
-
{x: car.x - car.width/2, y: car.y - car.height/2, width: car.width, height: car.height}
|
604 |
-
) && now - player.lastCollisionTime > 1000) {
|
605 |
-
player.speed *= -0.5;
|
606 |
-
player.health -= 10;
|
607 |
-
healthDisplay.textContent = player.health;
|
608 |
-
player.lastCollisionTime = now;
|
609 |
-
|
610 |
-
// Increase wanted level for reckless driving
|
611 |
-
updateWantedLevel(wantedLevel + 1);
|
612 |
-
|
613 |
-
// Create explosion effect
|
614 |
-
createExplosion((player.x + car.x) / 2, (player.y + car.y) / 2);
|
615 |
-
|
616 |
-
// Check if this was a police car for mission
|
617 |
-
if (currentMission && currentMission.type === "destroy") {
|
618 |
-
currentMission.current++;
|
619 |
-
showMission(`MISSION: ${currentMission.name} - ${currentMission.current}/${currentMission.target}`);
|
620 |
-
}
|
621 |
-
}
|
622 |
-
});
|
623 |
-
|
624 |
-
// Update and draw police cars
|
625 |
-
policeCars.forEach((police, index) => {
|
626 |
-
// Move police toward player
|
627 |
-
const angle = Math.atan2(player.y - police.y, player.x - police.x);
|
628 |
-
police.rotation = angle;
|
629 |
-
|
630 |
-
police.x += Math.cos(angle) * police.speed;
|
631 |
-
police.y += Math.sin(angle) * police.speed;
|
632 |
-
|
633 |
-
// Draw police car with siren
|
634 |
-
drawRotatedRect(police.x, police.y, police.width, police.height, police.rotation, police.color);
|
635 |
-
|
636 |
-
// Draw siren lights
|
637 |
-
const now = Date.now();
|
638 |
-
if (now % 500 < 250) {
|
639 |
-
// Left light (red)
|
640 |
-
ctx.fillStyle = 'red';
|
641 |
-
ctx.beginPath();
|
642 |
-
ctx.arc(
|
643 |
-
police.x + Math.cos(police.rotation - Math.PI/2) * 20,
|
644 |
-
police.y + Math.sin(police.rotation - Math.PI/2) * 20,
|
645 |
-
5, 0, Math.PI * 2
|
646 |
-
);
|
647 |
-
ctx.fill();
|
648 |
-
|
649 |
-
// Right light (blue)
|
650 |
-
ctx.fillStyle = 'blue';
|
651 |
-
ctx.beginPath();
|
652 |
-
ctx.arc(
|
653 |
-
police.x + Math.cos(police.rotation + Math.PI/2) * 20,
|
654 |
-
police.y + Math.sin(police.rotation + Math.PI/2) * 20,
|
655 |
-
5, 0, Math.PI * 2
|
656 |
-
);
|
657 |
-
ctx.fill();
|
658 |
-
}
|
659 |
-
|
660 |
-
// Check collision with player
|
661 |
-
const now = Date.now();
|
662 |
-
if (checkCollision(
|
663 |
-
{x: player.x - player.width/2, y: player.y - player.height/2, width: player.width, height: player.height},
|
664 |
-
{x: police.x - police.width/2, y: police.y - police.height/2, width: police.width, height: police.height}
|
665 |
-
) && now - player.lastCollisionTime > 1000) {
|
666 |
-
player.speed *= -0.5;
|
667 |
-
player.health -= 20;
|
668 |
-
healthDisplay.textContent = player.health;
|
669 |
-
player.lastCollisionTime = now;
|
670 |
-
|
671 |
-
// Create explosion effect
|
672 |
-
createExplosion((player.x + police.x) / 2, (player.y + police.y) / 2);
|
673 |
-
|
674 |
-
// Check if this was a police car for mission
|
675 |
-
if (currentMission && currentMission.type === "destroy") {
|
676 |
-
currentMission.current++;
|
677 |
-
showMission(`MISSION: ${currentMission.name} - ${currentMission.current}/${currentMission.target}`);
|
678 |
-
}
|
679 |
-
}
|
680 |
-
|
681 |
-
// Remove police if too far away (and wanted level is 0)
|
682 |
-
if (wantedLevel === 0 && getDistance(police.x, police.y, player.x, player.y) > 1000) {
|
683 |
-
policeCars.splice(index, 1);
|
684 |
-
}
|
685 |
-
});
|
686 |
-
|
687 |
-
// Draw collectibles
|
688 |
-
collectibles.forEach((item, index) => {
|
689 |
-
if (item.collected) return;
|
690 |
-
|
691 |
-
ctx.beginPath();
|
692 |
-
ctx.arc(item.x, item.y, item.radius, 0, Math.PI * 2);
|
693 |
-
|
694 |
-
if (item.type === 'money') {
|
695 |
-
ctx.fillStyle = 'gold';
|
696 |
-
ctx.fill();
|
697 |
-
|
698 |
-
// Draw dollar sign
|
699 |
-
ctx.fillStyle = '#333';
|
700 |
-
ctx.font = `${item.radius}px Arial`;
|
701 |
-
ctx.textAlign = 'center';
|
702 |
-
ctx.textBaseline = 'middle';
|
703 |
-
ctx.fillText('$', item.x, item.y);
|
704 |
-
} else {
|
705 |
-
ctx.fillStyle = 'red';
|
706 |
-
ctx.fill();
|
707 |
-
|
708 |
-
// Draw plus sign
|
709 |
-
ctx.fillStyle = 'white';
|
710 |
-
ctx.font = `${item.radius}px Arial`;
|
711 |
-
ctx.textAlign = 'center';
|
712 |
-
ctx.textBaseline = 'middle';
|
713 |
-
ctx.fillText('+', item.x, item.y);
|
714 |
-
}
|
715 |
-
|
716 |
-
// Check collision with player
|
717 |
-
if (getDistance(item.x, item.y, player.x, player.y) < item.radius + player.width/2) {
|
718 |
-
item.collected = true;
|
719 |
-
|
720 |
-
if (item.type === 'money') {
|
721 |
-
money += item.value;
|
722 |
-
moneyDisplay.textContent = money;
|
723 |
-
showMission(`+$${item.value}`);
|
724 |
-
} else {
|
725 |
-
player.health = Math.min(player.health + item.value, 100);
|
726 |
-
healthDisplay.textContent = player.health;
|
727 |
-
showMission(`+${item.value}% Health`);
|
728 |
-
}
|
729 |
-
|
730 |
-
// Check mission progress
|
731 |
-
checkMissionProgress();
|
732 |
-
}
|
733 |
-
});
|
734 |
|
735 |
-
//
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
ctx.globalAlpha = explosion.alpha;
|
741 |
-
ctx.fillStyle = explosion.color;
|
742 |
-
ctx.beginPath();
|
743 |
-
ctx.arc(explosion.x, explosion.y, explosion.radius, 0, Math.PI * 2);
|
744 |
-
ctx.fill();
|
745 |
-
|
746 |
-
ctx.globalAlpha = 1;
|
747 |
-
|
748 |
-
if (explosion.alpha <= 0) {
|
749 |
-
explosions.splice(index, 1);
|
750 |
-
}
|
751 |
-
});
|
752 |
|
753 |
-
// Draw player
|
754 |
drawRotatedRect(player.x, player.y, player.width, player.height, player.rotation, player.color);
|
755 |
|
756 |
-
// Draw player health bar
|
757 |
-
ctx.fillStyle = 'red';
|
758 |
-
ctx.fillRect(10, canvas.height - 30, 200 * (player.health / 100), 20);
|
759 |
-
ctx.strokeStyle = 'white';
|
760 |
-
ctx.strokeRect(10, canvas.height - 30, 200, 20);
|
761 |
-
|
762 |
-
// Update UI
|
763 |
-
speedDisplay.textContent = Math.floor(Math.abs(player.speed) * 10);
|
764 |
-
|
765 |
-
// Check if player is dead
|
766 |
-
if (player.health <= 0) {
|
767 |
-
showMission("WASTED");
|
768 |
-
setTimeout(resetGame, 3000);
|
769 |
-
gameRunning = false;
|
770 |
-
return;
|
771 |
-
}
|
772 |
-
|
773 |
-
// Check mission progress
|
774 |
-
checkMissionProgress();
|
775 |
-
|
776 |
-
// Randomly decrease wanted level if no crimes are being committed
|
777 |
-
if (wantedLevel > 0 && Math.random() < 0.005) {
|
778 |
-
updateWantedLevel(wantedLevel - 1);
|
779 |
-
}
|
780 |
-
|
781 |
// Request next frame
|
782 |
requestAnimationFrame(gameLoop);
|
783 |
}
|
784 |
|
785 |
-
//
|
786 |
const keys = {
|
787 |
ArrowUp: false,
|
788 |
ArrowDown: false,
|
789 |
ArrowLeft: false,
|
790 |
ArrowRight: false,
|
791 |
-
' ': false
|
792 |
-
h: false // h for honk
|
793 |
};
|
794 |
|
795 |
-
let lastHonkTime = 0;
|
796 |
-
|
797 |
document.addEventListener('keydown', (e) => {
|
798 |
-
if (e.key in keys)
|
799 |
-
keys[e.key] = true;
|
800 |
-
|
801 |
-
// Honk horn
|
802 |
-
if (e.key === 'h' && Date.now() - lastHonkTime > 1000) {
|
803 |
-
lastHonkTime = Date.now();
|
804 |
-
showMission("HONK!");
|
805 |
-
|
806 |
-
// Increase wanted level for disturbing the peace
|
807 |
-
if (wantedLevel < 1) {
|
808 |
-
updateWantedLevel(1);
|
809 |
-
}
|
810 |
-
}
|
811 |
-
|
812 |
-
// Change radio station
|
813 |
-
if (e.key === 'r') {
|
814 |
-
currentRadioIndex = (currentRadioIndex + 1) % radioStations.length;
|
815 |
-
radioStation.textContent = radioStations[currentRadioIndex];
|
816 |
-
}
|
817 |
-
}
|
818 |
});
|
819 |
|
820 |
document.addEventListener('keyup', (e) => {
|
821 |
-
if (e.key in keys)
|
822 |
-
keys[e.key] = false;
|
823 |
-
}
|
824 |
});
|
825 |
|
826 |
// Update player based on input
|
@@ -829,59 +202,26 @@
|
|
829 |
|
830 |
// Acceleration
|
831 |
if (keys.ArrowUp) {
|
832 |
-
player.speed
|
833 |
} else if (keys.ArrowDown) {
|
834 |
-
player.speed
|
835 |
} else {
|
836 |
-
//
|
837 |
-
|
838 |
-
|
839 |
-
} else if (player.speed < 0) {
|
840 |
-
player.speed = Math.min(player.speed + player.deceleration, 0);
|
841 |
-
}
|
842 |
}
|
843 |
|
844 |
-
//
|
845 |
if (keys[' ']) {
|
846 |
-
player.speed *= 0.
|
847 |
}
|
848 |
|
849 |
// Steering
|
850 |
-
if (keys.ArrowLeft) {
|
851 |
-
player.rotation -=
|
852 |
-
}
|
853 |
-
if (keys.ArrowRight) {
|
854 |
-
player.rotation += player.rotationSpeed * Math.abs(player.speed) / player.maxSpeed;
|
855 |
-
}
|
856 |
-
|
857 |
-
// Limit speed
|
858 |
-
if (player.speed > player.maxSpeed) {
|
859 |
-
player.speed = player.maxSpeed;
|
860 |
-
} else if (player.speed < -player.maxSpeed / 2) {
|
861 |
-
player.speed = -player.maxSpeed / 2;
|
862 |
-
}
|
863 |
-
|
864 |
-
// Move player
|
865 |
-
player.x += Math.cos(player.rotation) * player.speed;
|
866 |
-
player.y += Math.sin(player.rotation) * player.speed;
|
867 |
-
|
868 |
-
// Wrap around screen edges
|
869 |
-
if (player.x < -player.width) player.x = canvas.width + player.width;
|
870 |
-
if (player.x > canvas.width + player.width) player.x = -player.width;
|
871 |
-
if (player.y < -player.height) player.y = canvas.height + player.height;
|
872 |
-
if (player.y > canvas.height + player.height) player.y = -player.height;
|
873 |
-
|
874 |
-
// Check if player is off-road (increase wanted level)
|
875 |
-
let onRoad = false;
|
876 |
-
for (const road of roads) {
|
877 |
-
if (pointInRect(player.x, player.y, road)) {
|
878 |
-
onRoad = true;
|
879 |
-
break;
|
880 |
-
}
|
881 |
}
|
882 |
-
|
883 |
-
|
884 |
-
updateWantedLevel(wantedLevel + 1);
|
885 |
}
|
886 |
}
|
887 |
|
@@ -889,39 +229,23 @@
|
|
889 |
function startGame() {
|
890 |
startScreen.style.display = 'none';
|
891 |
gameRunning = true;
|
892 |
-
lastTime = performance.now();
|
893 |
|
894 |
// Reset game state
|
895 |
-
score = 0;
|
896 |
money = 0;
|
897 |
-
|
898 |
-
|
|
|
899 |
|
900 |
// Generate city
|
901 |
generateCity();
|
902 |
-
generateNPC();
|
903 |
-
generateCollectibles();
|
904 |
-
|
905 |
-
// Start first mission
|
906 |
-
setTimeout(startRandomMission, 2000);
|
907 |
|
908 |
// Start game loop
|
909 |
-
|
910 |
|
911 |
// Start input update loop
|
912 |
setInterval(updatePlayer, 1000/60);
|
913 |
}
|
914 |
|
915 |
-
// Reset game
|
916 |
-
function resetGame() {
|
917 |
-
startScreen.style.display = 'flex';
|
918 |
-
gameRunning = false;
|
919 |
-
|
920 |
-
// Clear all game objects
|
921 |
-
policeCars.length = 0;
|
922 |
-
explosions.length = 0;
|
923 |
-
}
|
924 |
-
|
925 |
// Start button event
|
926 |
startButton.addEventListener('click', startGame);
|
927 |
|
@@ -929,13 +253,7 @@
|
|
929 |
window.addEventListener('resize', () => {
|
930 |
canvas.width = window.innerWidth;
|
931 |
canvas.height = window.innerHeight;
|
932 |
-
|
933 |
-
if (gameRunning) {
|
934 |
-
// Regenerate city if game is running
|
935 |
-
generateCity();
|
936 |
-
generateNPC();
|
937 |
-
generateCollectibles();
|
938 |
-
}
|
939 |
});
|
940 |
</script>
|
941 |
<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=Greats/clone" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
|
|
|
3 |
<head>
|
4 |
<meta charset="UTF-8">
|
5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
+
<title>GTA Style Game</title>
|
7 |
<style>
|
8 |
body {
|
9 |
margin: 0;
|
|
|
10 |
overflow: hidden;
|
11 |
background-color: #222;
|
12 |
font-family: Arial, sans-serif;
|
13 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
#gameCanvas {
|
15 |
display: block;
|
16 |
background-color: #87CEEB;
|
17 |
}
|
18 |
+
#ui {
|
|
|
19 |
position: absolute;
|
20 |
top: 10px;
|
21 |
left: 10px;
|
22 |
color: white;
|
23 |
font-size: 16px;
|
24 |
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.7);
|
|
|
25 |
}
|
|
|
26 |
#startScreen {
|
27 |
position: absolute;
|
28 |
top: 0;
|
|
|
35 |
justify-content: center;
|
36 |
align-items: center;
|
37 |
color: white;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
}
|
|
|
39 |
#startButton {
|
40 |
padding: 15px 30px;
|
41 |
+
font-size: 20px;
|
42 |
background-color: #FF4500;
|
43 |
color: white;
|
44 |
border: none;
|
45 |
border-radius: 5px;
|
46 |
cursor: pointer;
|
47 |
+
margin-top: 20px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
}
|
49 |
</style>
|
50 |
</head>
|
51 |
<body>
|
52 |
+
<canvas id="gameCanvas"></canvas>
|
53 |
+
<div id="ui">
|
54 |
+
<div>Money: $<span id="money">0</span></div>
|
55 |
+
<div>Health: <span id="health">100</span>%</div>
|
56 |
+
</div>
|
57 |
+
<div id="startScreen">
|
58 |
+
<h1>GTA Style Game</h1>
|
59 |
+
<p>Use arrow keys to drive, space to brake</p>
|
60 |
+
<button id="startButton">START GAME</button>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
</div>
|
62 |
|
63 |
<script>
|
64 |
+
// Game setup
|
65 |
const canvas = document.getElementById('gameCanvas');
|
66 |
const ctx = canvas.getContext('2d');
|
67 |
const startScreen = document.getElementById('startScreen');
|
68 |
const startButton = document.getElementById('startButton');
|
69 |
const moneyDisplay = document.getElementById('money');
|
|
|
70 |
const healthDisplay = document.getElementById('health');
|
|
|
|
|
|
|
|
|
71 |
|
72 |
// Set canvas size
|
73 |
canvas.width = window.innerWidth;
|
|
|
75 |
|
76 |
// Game state
|
77 |
let gameRunning = false;
|
|
|
|
|
78 |
let money = 0;
|
79 |
+
let health = 100;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
|
81 |
// Player car
|
82 |
const player = {
|
|
|
84 |
y: canvas.height / 2,
|
85 |
width: 40,
|
86 |
height: 70,
|
|
|
87 |
speed: 0,
|
88 |
+
maxSpeed: 5,
|
|
|
|
|
89 |
rotation: 0,
|
90 |
+
color: '#FF4500'
|
|
|
|
|
91 |
};
|
92 |
|
93 |
+
// Roads
|
94 |
const roads = [];
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
|
96 |
+
// Generate simple city
|
97 |
function generateCity() {
|
|
|
98 |
roads.length = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
|
100 |
+
// Horizontal roads
|
101 |
+
for (let y = 100; y < canvas.height; y += 200) {
|
102 |
roads.push({
|
103 |
x: 0,
|
104 |
+
y: y,
|
105 |
width: canvas.width,
|
106 |
+
height: 60
|
|
|
107 |
});
|
108 |
}
|
109 |
|
110 |
+
// Vertical roads
|
111 |
+
for (let x = 100; x < canvas.width; x += 200) {
|
112 |
roads.push({
|
113 |
+
x: x,
|
114 |
y: 0,
|
115 |
+
width: 60,
|
116 |
+
height: canvas.height
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
117 |
});
|
118 |
}
|
119 |
|
120 |
+
// Position player at intersection
|
121 |
+
player.x = 200;
|
122 |
+
player.y = 200;
|
|
|
123 |
}
|
124 |
|
125 |
+
// Draw rotated rectangle
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
126 |
function drawRotatedRect(x, y, width, height, rotation, color) {
|
127 |
ctx.save();
|
128 |
ctx.translate(x, y);
|
129 |
ctx.rotate(rotation);
|
130 |
ctx.fillStyle = color;
|
131 |
+
ctx.fillRect(-width/2, -height/2, width, height);
|
132 |
|
133 |
+
// Add windows
|
134 |
+
ctx.fillStyle = '#333';
|
135 |
+
ctx.fillRect(-width/2 + 5, -height/2 + 5, width - 10, height/3);
|
136 |
ctx.restore();
|
137 |
}
|
138 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
139 |
// Game loop
|
140 |
+
function gameLoop() {
|
141 |
if (!gameRunning) return;
|
142 |
|
|
|
|
|
|
|
|
|
143 |
// Clear canvas
|
144 |
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
145 |
|
|
|
148 |
roads.forEach(road => {
|
149 |
ctx.fillRect(road.x, road.y, road.width, road.height);
|
150 |
|
151 |
+
// Road markings
|
152 |
ctx.fillStyle = 'white';
|
153 |
+
if (road.width > road.height) { // horizontal road
|
154 |
+
for (let x = 0; x < road.width; x += 40) {
|
155 |
+
ctx.fillRect(road.x + x, road.y + road.height/2 - 2, 20, 4);
|
|
|
|
|
|
|
|
|
156 |
}
|
157 |
+
} else { // vertical road
|
158 |
+
for (let y = 0; y < road.height; y += 40) {
|
159 |
+
ctx.fillRect(road.x + road.width/2 - 2, road.y + y, 4, 20);
|
|
|
|
|
|
|
|
|
160 |
}
|
161 |
}
|
162 |
ctx.fillStyle = '#333';
|
163 |
});
|
164 |
|
165 |
+
// Update player position
|
166 |
+
player.x += Math.cos(player.rotation) * player.speed;
|
167 |
+
player.y += Math.sin(player.rotation) * player.speed;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
168 |
|
169 |
+
// Wrap around screen
|
170 |
+
if (player.x < 0) player.x = canvas.width;
|
171 |
+
if (player.x > canvas.width) player.x = 0;
|
172 |
+
if (player.y < 0) player.y = canvas.height;
|
173 |
+
if (player.y > canvas.height) player.y = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
174 |
|
175 |
+
// Draw player
|
176 |
drawRotatedRect(player.x, player.y, player.width, player.height, player.rotation, player.color);
|
177 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
178 |
// Request next frame
|
179 |
requestAnimationFrame(gameLoop);
|
180 |
}
|
181 |
|
182 |
+
// Keyboard controls
|
183 |
const keys = {
|
184 |
ArrowUp: false,
|
185 |
ArrowDown: false,
|
186 |
ArrowLeft: false,
|
187 |
ArrowRight: false,
|
188 |
+
' ': false
|
|
|
189 |
};
|
190 |
|
|
|
|
|
191 |
document.addEventListener('keydown', (e) => {
|
192 |
+
if (e.key in keys) keys[e.key] = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
193 |
});
|
194 |
|
195 |
document.addEventListener('keyup', (e) => {
|
196 |
+
if (e.key in keys) keys[e.key] = false;
|
|
|
|
|
197 |
});
|
198 |
|
199 |
// Update player based on input
|
|
|
202 |
|
203 |
// Acceleration
|
204 |
if (keys.ArrowUp) {
|
205 |
+
player.speed = Math.min(player.speed + 0.05, player.maxSpeed);
|
206 |
} else if (keys.ArrowDown) {
|
207 |
+
player.speed = Math.max(player.speed - 0.05, -player.maxSpeed/2);
|
208 |
} else {
|
209 |
+
// Friction
|
210 |
+
player.speed *= 0.95;
|
211 |
+
if (Math.abs(player.speed) < 0.1) player.speed = 0;
|
|
|
|
|
|
|
212 |
}
|
213 |
|
214 |
+
// Brake
|
215 |
if (keys[' ']) {
|
216 |
+
player.speed *= 0.9;
|
217 |
}
|
218 |
|
219 |
// Steering
|
220 |
+
if (keys.ArrowLeft && player.speed !== 0) {
|
221 |
+
player.rotation -= 0.05 * (player.speed / player.maxSpeed);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
222 |
}
|
223 |
+
if (keys.ArrowRight && player.speed !== 0) {
|
224 |
+
player.rotation += 0.05 * (player.speed / player.maxSpeed);
|
|
|
225 |
}
|
226 |
}
|
227 |
|
|
|
229 |
function startGame() {
|
230 |
startScreen.style.display = 'none';
|
231 |
gameRunning = true;
|
|
|
232 |
|
233 |
// Reset game state
|
|
|
234 |
money = 0;
|
235 |
+
health = 100;
|
236 |
+
moneyDisplay.textContent = money;
|
237 |
+
healthDisplay.textContent = health;
|
238 |
|
239 |
// Generate city
|
240 |
generateCity();
|
|
|
|
|
|
|
|
|
|
|
241 |
|
242 |
// Start game loop
|
243 |
+
gameLoop();
|
244 |
|
245 |
// Start input update loop
|
246 |
setInterval(updatePlayer, 1000/60);
|
247 |
}
|
248 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
249 |
// Start button event
|
250 |
startButton.addEventListener('click', startGame);
|
251 |
|
|
|
253 |
window.addEventListener('resize', () => {
|
254 |
canvas.width = window.innerWidth;
|
255 |
canvas.height = window.innerHeight;
|
256 |
+
if (gameRunning) generateCity();
|
|
|
|
|
|
|
|
|
|
|
|
|
257 |
});
|
258 |
</script>
|
259 |
<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=Greats/clone" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
|
prompts.txt
CHANGED
@@ -1,3 +1,4 @@
|
|
1 |
создай чудо
|
2 |
сделай огромный проект ссобой полностью законченный и рабочий
|
3 |
-
сделай сайт онлайн игру на подобе гта5
|
|
|
|
1 |
создай чудо
|
2 |
сделай огромный проект ссобой полностью законченный и рабочий
|
3 |
+
сделай сайт онлайн игру на подобе гта5
|
4 |
+
не работает
|