User prompt
Ekrana Bir tuş ekle
User prompt
Bir tuş ekle ve basınca mermilerimiz tüm polisleri öldürsün
User prompt
Bir tuş ekle ve basınca tüm polisler ölsün
User prompt
Ekranda bir tuş olsun ve basınca tüm polisler ölsün
User prompt
Eğer 300 cash olursak ekranda 2 saniyeliğine combo yazsın
User prompt
Joystick birazdaha yukarıda olsun
User prompt
Oyunda bir tuş olsun ve bastığımızda 2 saniyeliğine karakterimiz her yere ateş etsin
User prompt
Hadi hemen yap
User prompt
Engellerin hepsini sil
User prompt
Bir de silah yap polisleri öldürebilelim
User prompt
Bir joystick yap
User prompt
Tuşları sil
User prompt
Telefon için ekrana İki tuş koy
User prompt
Hareket etmemi sağla
User prompt
polisler çok yavaş olsun
User prompt
Hareket Etmemi Sağla
Code edit (1 edits merged)
Please save this source code
User prompt
Mini Grand City: Getaway Rush
Initial prompt
Gta V Yap
/**** * Classes ****/ // Bullet class var Bullet = Container.expand(function () { var self = Container.call(this); var bulletSprite = self.attachAsset('bullet', { anchorX: 0.5, anchorY: 0.5 }); self.speed = -15; self.update = function () { self.y += self.speed; }; return self; }); // Cash class var Cash = Container.expand(function () { var self = Container.call(this); var cashSprite = self.attachAsset('cash', { anchorX: 0.5, anchorY: 0.5 }); self.radius = cashSprite.width * 0.5; self.speed = 7; self.update = function () { self.y += self.speed; }; return self; }); var Joystick = Container.expand(function () { var self = Container.call(this); var base = self.attachAsset('joystick_base', { anchorX: 0.5, anchorY: 0.5 }); var handle = self.attachAsset('joystick_handle', { anchorX: 0.5, anchorY: 0.5 }); var startX = 0; var startY = 0; var isDragging = false; var maxDist = base.width * 0.3; // Max distance handle can move self.on('down', function (x, y) { isDragging = true; var pos = self.toLocal({ x: x, y: y }); startX = pos.x; startY = pos.y; }); self.on('move', function (x, y) { if (isDragging) { var pos = self.toLocal({ x: x, y: y }); var dx = pos.x - startX; var dy = pos.y - startY; var dist = Math.sqrt(dx * dx + dy * dy); if (dist > maxDist) { dx = dx / dist * maxDist; dy = dy / dist * maxDist; } handle.x = startX + dx; handle.y = startY + dy; self.directionX = dx / maxDist; self.directionY = dy / maxDist; } }); self.on('up', function () { isDragging = false; handle.x = startX; handle.y = startY; self.directionX = 0; self.directionY = 0; }); self.directionX = 0; self.directionY = 0; return self; }); // Obstacle class var Obstacle = Container.expand(function () { var self = Container.call(this); var obsSprite = self.attachAsset('obstacle', { anchorX: 0.5, anchorY: 0.5 }); self.radius = obsSprite.width * 0.5; self.speed = 7 + Math.random() * 3; self.direction = Math.random() < 0.5 ? 1 : -1; self.update = function () { // Move vertically down, with a little horizontal drift self.y += self.speed; self.x += self.direction * 2; }; return self; }); // Player class var Player = Container.expand(function () { var self = Container.call(this); var playerSprite = self.attachAsset('player', { anchorX: 0.5, anchorY: 0.5 }); self.radius = playerSprite.width * 0.5; self.speed = 0; // Not used, but can be for future upgrades // For future: self.invincible = false; return self; }); // Police car class var Police = Container.expand(function () { var self = Container.call(this); var policeSprite = self.attachAsset('police', { anchorX: 0.5, anchorY: 0.5 }); self.radius = policeSprite.width * 0.5; self.speed = 2 + Math.random() * 1.5; // Much slower base speed for police self.update = function () { // Move towards player var dx = player.x - self.x; var dy = player.y - self.y; var dist = Math.sqrt(dx * dx + dy * dy); if (dist > 0) { self.x += dx / dist * self.speed; self.y += dy / dist * self.speed; } }; return self; }); // Powerup class var Powerup = Container.expand(function () { var self = Container.call(this); var powerSprite = self.attachAsset('powerup', { anchorX: 0.5, anchorY: 0.5 }); self.radius = powerSprite.width * 0.5; self.speed = 7; self.update = function () { self.y += self.speed; }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x222222 }); /**** * Game Code ****/ // Power-up: yellow ellipse // Cash: green ellipse // Obstacle: gray box // Police car: blue box // Player character: red box // Game area var GAME_W = 2048; var GAME_H = 2732; // Player instance var player = new Player(); game.addChild(player); player.x = GAME_W / 2; player.y = GAME_H - 400; // Arrays for game objects var policeCars = []; var obstacles = []; var cashItems = []; var powerups = []; var bullets = []; // Array to hold bullets // Score and wanted level var score = 0; var wantedLevel = 1; var timeSurvived = 0; // in ticks // GUI: Score var scoreTxt = new Text2('0', { size: 120, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // GUI: Wanted Level var wantedTxt = new Text2('Wanted: 1', { size: 80, fill: 0xFF4444 }); wantedTxt.anchor.set(0.5, 0); LK.gui.top.addChild(wantedTxt); wantedTxt.y = 130; // GUI: Cash var cashTxt = new Text2('$0', { size: 80, fill: 0x2ECC40 }); cashTxt.anchor.set(0.5, 0); LK.gui.top.addChild(cashTxt); cashTxt.y = 220; // Dragging var dragNode = null; // Powerup state var powerupActive = false; var powerupTimer = 0; // Helper: Clamp function clamp(val, min, max) { return Math.max(min, Math.min(max, val)); } ; // Joystick var joystick = new Joystick(); LK.gui.bottomLeft.addChild(joystick); joystick.x = 200; joystick.y = -200; // Position slightly up from bottom // Spawning logic // Spawning logic var policeSpawnTimer = 0; var obstacleSpawnTimer = 0; var cashSpawnTimer = 0; var powerupSpawnTimer = 0; var shootTimer = 0; // Timer for player shooting // Main update loop game.update = function () { // Move player with joystick player.x += joystick.directionX * 20; // Adjust multiplier for speed player.y += joystick.directionY * 20; // Adjust multiplier for speed // Clamp player to game area player.x = clamp(player.x, 80, GAME_W - 80); player.y = clamp(player.y, 80, GAME_H - 80); // Increase time survived timeSurvived++; if (timeSurvived % 60 === 0) { score++; scoreTxt.setText(score + ''); } // Increase wanted level every 20 seconds if (timeSurvived % (60 * 20) === 0 && wantedLevel < 5) { wantedLevel++; wantedTxt.setText('Wanted: ' + wantedLevel); } // Spawn police cars policeSpawnTimer--; var policeLimit = Math.min(1 + wantedLevel, 6); if (policeCars.length < policeLimit && policeSpawnTimer <= 0) { var p = new Police(); // Spawn at random edge var edge = Math.floor(Math.random() * 4); if (edge === 0) { // Top p.x = Math.random() * (GAME_W - 200) + 100; p.y = -100; } else if (edge === 1) { // Bottom p.x = Math.random() * (GAME_W - 200) + 100; p.y = GAME_H + 100; } else if (edge === 2) { // Left p.x = -100; p.y = Math.random() * (GAME_H - 800) + 400; } else { // Right p.x = GAME_W + 100; p.y = Math.random() * (GAME_H - 800) + 400; } // Increase speed with wanted level (much slower scaling) p.speed = 2 + wantedLevel * 0.7 + Math.random() * 1.5; policeCars.push(p); game.addChild(p); policeSpawnTimer = 90 - wantedLevel * 10 + Math.floor(Math.random() * 30); } cashSpawnTimer--; if (cashItems.length < 2 && cashSpawnTimer <= 0) { var c = new Cash(); c.x = Math.random() * (GAME_W - 200) + 100; c.y = -100; cashItems.push(c); game.addChild(c); cashSpawnTimer = 180 + Math.floor(Math.random() * 120); } // Spawn powerup powerupSpawnTimer--; if (!powerupActive && powerups.length < 1 && powerupSpawnTimer <= 0) { var pu = new Powerup(); pu.x = Math.random() * (GAME_W - 200) + 100; pu.y = -100; powerups.push(pu); game.addChild(pu); powerupSpawnTimer = 900 + Math.floor(Math.random() * 600); } // Update police cars for (var i = policeCars.length - 1; i >= 0; i--) { var p = policeCars[i]; p.update(); // Remove if off screen if (p.x < -200 || p.x > GAME_W + 200 || p.y < -200 || p.y > GAME_H + 200) { p.destroy(); policeCars.splice(i, 1); continue; } // Collision with player if (!powerupActive && p.intersects(player)) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); return; } ; // Player shooting shootTimer--; if (joystick.directionY < -0.5 && shootTimer <= 0) { // Shoot when pushing joystick up var bullet = new Bullet(); bullet.x = player.x; bullet.y = player.y; bullets.push(bullet); game.addChild(bullet); shootTimer = 20; // Shoot every 20 ticks (approx 3 times per second) } // Update bullets for (var b = bullets.length - 1; b >= 0; b--) { var bullet = bullets[b]; bullet.update(); // Remove if off screen if (bullet.y < -100) { bullet.destroy(); bullets.splice(b, 1); continue; } // Collision with police cars for (var i = policeCars.length - 1; i >= 0; i--) { var p = policeCars[i]; if (bullet.intersects(p)) { p.destroy(); policeCars.splice(i, 1); bullet.destroy(); bullets.splice(b, 1); score += 50; // Score for hitting police cashTxt.setText('$' + score); // Don't break inner loop, continue checking other police cars break; } } } } ; // Update obstacles // Update cash for (var k = cashItems.length - 1; k >= 0; k--) { var c = cashItems[k]; c.update(); if (c.y > GAME_H + 100) { c.destroy(); cashItems.splice(k, 1); continue; } // Collect cash if (c.intersects(player)) { score += 10; scoreTxt.setText(score + ''); cashTxt.setText('$' + score); c.destroy(); cashItems.splice(k, 1); continue; } } // Update powerups for (var m = powerups.length - 1; m >= 0; m--) { var pu = powerups[m]; pu.update(); if (pu.y > GAME_H + 100) { pu.destroy(); powerups.splice(m, 1); continue; } // Collect powerup if (pu.intersects(player)) { powerupActive = true; powerupTimer = 360; // 6 seconds // Flash player yellow LK.effects.flashObject(player, 0xffe066, 600); pu.destroy(); powerups.splice(m, 1); continue; } } // Powerup timer if (powerupActive) { powerupTimer--; if (powerupTimer <= 0) { powerupActive = false; } } };
===================================================================
--- original.js
+++ change.js
@@ -155,14 +155,14 @@
/****
* Game Code
****/
-// Game area
-// Player character: red box
-// Police car: blue box
-// Obstacle: gray box
-// Cash: green ellipse
// Power-up: yellow ellipse
+// Cash: green ellipse
+// Obstacle: gray box
+// Police car: blue box
+// Player character: red box
+// Game area
var GAME_W = 2048;
var GAME_H = 2732;
// Player instance
var player = new Player();
@@ -272,19 +272,8 @@
policeCars.push(p);
game.addChild(p);
policeSpawnTimer = 90 - wantedLevel * 10 + Math.floor(Math.random() * 30);
}
- // Spawn obstacles
- obstacleSpawnTimer--;
- if (obstacles.length < 2 + wantedLevel && obstacleSpawnTimer <= 0) {
- var o = new Obstacle();
- o.x = Math.random() * (GAME_W - 200) + 100;
- o.y = -100;
- obstacles.push(o);
- game.addChild(o);
- obstacleSpawnTimer = 60 + Math.floor(Math.random() * 60);
- }
- // Spawn cash
cashSpawnTimer--;
if (cashItems.length < 2 && cashSpawnTimer <= 0) {
var c = new Cash();
c.x = Math.random() * (GAME_W - 200) + 100;
@@ -358,23 +347,8 @@
}
}
;
// Update obstacles
- for (var j = obstacles.length - 1; j >= 0; j--) {
- var o = obstacles[j];
- o.update();
- if (o.y > GAME_H + 200) {
- o.destroy();
- obstacles.splice(j, 1);
- continue;
- }
- // Collision with player
- if (!powerupActive && o.intersects(player)) {
- LK.effects.flashScreen(0xff0000, 1000);
- LK.showGameOver();
- return;
- }
- }
// Update cash
for (var k = cashItems.length - 1; k >= 0; k--) {
var c = cashItems[k];
c.update();