User prompt
Oyunu biraz daha hizlandir ve araçlar birbirini. İçine görmesin onu düzelt çok fazla araç spawnlaniyor
User prompt
Oyun Biraz daha hızlı olsun yol biraz daha dar olsun ve diğer araçlarda birbirleriyle temas etmesin bunu duzelt
User prompt
Böyle bir oyun değil bir yol var ve biz de bir taxi göz trafikte diğer araçları sollayarak gidiyoruz eğer araçlarla temas edersek oyun bitiyor
Code edit (1 edits merged)
Please save this source code
User prompt
Crazy Taxi
Initial prompt
1) the game name is crazy taxi
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Taxi = Container.expand(function () {
var self = Container.call(this);
var taxiGraphics = self.attachAsset('taxi', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 12;
self.update = function () {
// Keep taxi in bounds (narrower road width)
if (self.x < 400) self.x = 400;
if (self.x > 1648) self.x = 1648;
};
return self;
});
var TrafficCar = Container.expand(function () {
var self = Container.call(this);
var carGraphics = self.attachAsset('trafficCar', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 8 + Math.random() * 6;
self.lastY = 0;
self.update = function () {
self.lastY = self.y;
self.y += self.speed;
// Check collision with other traffic cars and prevent overlap
for (var i = 0; i < trafficCars.length; i++) {
var otherCar = trafficCars[i];
if (otherCar !== self && self.intersects(otherCar)) {
// Calculate distance and move cars apart more effectively
var distanceX = Math.abs(self.x - otherCar.x);
var distanceY = Math.abs(self.y - otherCar.y);
if (distanceY < 150) {
// Minimum safe distance
if (self.y > otherCar.y) {
self.y = otherCar.y + 150;
} else {
self.y = otherCar.y - 150;
}
}
// Also check horizontal overlap and adjust
if (distanceX < 130 && distanceY < 200) {
if (self.x < 1024) {
self.x -= 50;
} else {
self.x += 50;
}
// Keep within road bounds
if (self.x < 400) self.x = 400;
if (self.x > 1648) self.x = 1648;
}
break;
}
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x2C5F2D
});
/****
* Game Code
****/
// Game variables
var taxi;
var trafficCars = [];
var roadLines = [];
var spawnTimer = 0;
var roadSpeed = 12;
// Create road background
var road = game.addChild(LK.getAsset('road', {
x: 0,
y: 0
}));
// Create road lines for visual effect
for (var i = 0; i < 30; i++) {
var line = game.addChild(LK.getAsset('roadLine', {
anchorX: 0.5,
anchorY: 0.5
}));
line.x = 1024;
line.y = i * 120;
roadLines.push(line);
}
// Create taxi
taxi = game.addChild(new Taxi());
taxi.x = 1024;
taxi.y = 2200;
// Create score display
var scoreText = new Text2('Score: ' + LK.getScore(), {
size: 80,
fill: 0xFFFFFF
});
scoreText.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreText);
scoreText.y = 20;
// Drag controls for taxi
var isDragging = false;
var dragStartX = 0;
game.down = function (x, y, obj) {
isDragging = true;
dragStartX = x;
};
game.move = function (x, y, obj) {
if (isDragging) {
var deltaX = x - dragStartX;
taxi.x += deltaX;
dragStartX = x;
}
};
game.up = function (x, y, obj) {
isDragging = false;
};
function spawnTrafficCar() {
var car = new TrafficCar();
car.x = 450 + Math.random() * 1148; // Random position on narrower road
car.y = -50;
car.lastY = car.y;
trafficCars.push(car);
game.addChild(car);
}
game.update = function () {
spawnTimer++;
// Move road lines for visual effect
for (var i = 0; i < roadLines.length; i++) {
var line = roadLines[i];
line.y += roadSpeed;
if (line.y > 2732 + 50) {
line.y = -50;
}
}
// Spawn traffic cars less frequently
if (spawnTimer % 60 === 0) {
spawnTrafficCar();
}
// Update traffic cars
for (var i = trafficCars.length - 1; i >= 0; i--) {
var car = trafficCars[i];
if (car.y > 2732 + 50) {
car.destroy();
trafficCars.splice(i, 1);
// Increase score for dodging car
LK.setScore(LK.getScore() + 10);
scoreText.setText('Score: ' + LK.getScore());
continue;
}
// Check collision with taxi - GAME OVER if collision
if (taxi.intersects(car)) {
LK.getSound('crash').play();
LK.effects.flashScreen(0xFF0000, 1000);
LK.showGameOver();
return;
}
}
// Increase difficulty over time
if (spawnTimer % 600 === 0 && roadSpeed < 10) {
roadSpeed += 0.5;
}
}; ===================================================================
--- original.js
+++ change.js
@@ -11,9 +11,9 @@
var taxiGraphics = self.attachAsset('taxi', {
anchorX: 0.5,
anchorY: 0.5
});
- self.speed = 8;
+ self.speed = 12;
self.update = function () {
// Keep taxi in bounds (narrower road width)
if (self.x < 400) self.x = 400;
if (self.x > 1648) self.x = 1648;
@@ -25,23 +25,39 @@
var carGraphics = self.attachAsset('trafficCar', {
anchorX: 0.5,
anchorY: 0.5
});
- self.speed = 5 + Math.random() * 4;
+ self.speed = 8 + Math.random() * 6;
self.lastY = 0;
self.update = function () {
self.lastY = self.y;
self.y += self.speed;
- // Check collision with other traffic cars
+ // Check collision with other traffic cars and prevent overlap
for (var i = 0; i < trafficCars.length; i++) {
var otherCar = trafficCars[i];
if (otherCar !== self && self.intersects(otherCar)) {
- // Move cars apart to prevent overlap
- if (self.y > otherCar.y) {
- self.y = otherCar.y + 100;
- } else {
- self.y = otherCar.y - 100;
+ // Calculate distance and move cars apart more effectively
+ var distanceX = Math.abs(self.x - otherCar.x);
+ var distanceY = Math.abs(self.y - otherCar.y);
+ if (distanceY < 150) {
+ // Minimum safe distance
+ if (self.y > otherCar.y) {
+ self.y = otherCar.y + 150;
+ } else {
+ self.y = otherCar.y - 150;
+ }
}
+ // Also check horizontal overlap and adjust
+ if (distanceX < 130 && distanceY < 200) {
+ if (self.x < 1024) {
+ self.x -= 50;
+ } else {
+ self.x += 50;
+ }
+ // Keep within road bounds
+ if (self.x < 400) self.x = 400;
+ if (self.x > 1648) self.x = 1648;
+ }
break;
}
}
};
@@ -62,9 +78,9 @@
var taxi;
var trafficCars = [];
var roadLines = [];
var spawnTimer = 0;
-var roadSpeed = 8;
+var roadSpeed = 12;
// Create road background
var road = game.addChild(LK.getAsset('road', {
x: 0,
y: 0
@@ -125,10 +141,10 @@
if (line.y > 2732 + 50) {
line.y = -50;
}
}
- // Spawn traffic cars more frequently
- if (spawnTimer % 40 === 0) {
+ // Spawn traffic cars less frequently
+ if (spawnTimer % 60 === 0) {
spawnTrafficCar();
}
// Update traffic cars
for (var i = trafficCars.length - 1; i >= 0; i--) {