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 Destination = Container.expand(function () {
var self = Container.call(this);
var destGraphics = self.attachAsset('destination', {
anchorX: 0.5,
anchorY: 0.5
});
// Make it flash to be noticeable
tween(destGraphics, {
alpha: 0.3
}, {
duration: 500,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(destGraphics, {
alpha: 1
}, {
duration: 500,
easing: tween.easeInOut,
onFinish: function onFinish() {
if (self.parent) {
self.update = arguments.callee.caller;
}
}
});
}
});
return self;
});
var Passenger = Container.expand(function () {
var self = Container.call(this);
var passengerGraphics = self.attachAsset('passenger', {
anchorX: 0.5,
anchorY: 1
});
self.timeLimit = 15 + Math.random() * 20; // 15-35 seconds
self.fare = 20 + Math.random() * 30; // $20-50
self.picked = false;
self.down = function (x, y, obj) {
if (!self.picked && !taxi.hasPassenger) {
self.picked = true;
taxi.hasPassenger = true;
taxi.passenger = self;
self.visible = false;
// Create destination
createDestination();
LK.getSound('pickup').play();
updatePassengerDisplay();
}
};
return self;
});
var Taxi = Container.expand(function () {
var self = Container.call(this);
var taxiGraphics = self.attachAsset('taxi', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 0;
self.maxSpeed = 8;
self.hasPassenger = false;
self.passenger = null;
self.invulnerable = false;
self.update = function () {
// Apply speed
self.y += self.speed;
// Keep taxi in bounds
if (self.x < 60) self.x = 60;
if (self.x > 1988) self.x = 1988;
// Gradual deceleration
if (self.speed > 3) {
self.speed -= 0.1;
}
};
return self;
});
var TrafficCar = Container.expand(function () {
var self = Container.call(this);
var carType = Math.random() > 0.5 ? 'car1' : 'car2';
var carGraphics = self.attachAsset(carType, {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 2 + Math.random() * 4;
self.update = function () {
self.y += self.speed;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x2C5F2D
});
/****
* Game Code
****/
// Game variables
var taxi;
var trafficCars = [];
var passengers = [];
var currentDestination = null;
var money = 0;
var gameTime = 0;
var passengerTimer = 0;
var spawnTimer = 0;
// UI elements
var moneyText;
var passengerText;
var timerText;
// Create road system
var topSidewalk = game.addChild(LK.getAsset('sidewalk', {
x: 0,
y: 0
}));
var road = game.addChild(LK.getAsset('road', {
x: 0,
y: 100
}));
var bottomSidewalk = game.addChild(LK.getAsset('sidewalk', {
x: 0,
y: 400
}));
// Create taxi
taxi = game.addChild(new Taxi());
taxi.x = 1024;
taxi.y = 250;
// Create UI
moneyText = new Text2('$' + money, {
size: 80,
fill: 0x00FF00
});
moneyText.anchor.set(0, 0);
LK.gui.topRight.addChild(moneyText);
moneyText.x = -200;
moneyText.y = 20;
passengerText = new Text2('No Passenger', {
size: 60,
fill: 0xFFFFFF
});
passengerText.anchor.set(0.5, 0);
LK.gui.top.addChild(passengerText);
passengerText.y = 120;
timerText = new Text2('', {
size: 70,
fill: 0xFF0000
});
timerText.anchor.set(0.5, 0);
LK.gui.top.addChild(timerText);
timerText.y = 200;
// 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 * 0.8;
dragStartX = x;
// Increase speed when moving
if (taxi.speed < taxi.maxSpeed) {
taxi.speed += 0.5;
}
}
};
game.up = function (x, y, obj) {
isDragging = false;
};
function spawnTrafficCar() {
var car = new TrafficCar();
car.x = 200 + Math.random() * 1648; // Random lane
car.y = -50;
trafficCars.push(car);
game.addChild(car);
}
function spawnPassenger() {
if (passengers.length < 3 && !taxi.hasPassenger) {
var passenger = new Passenger();
passenger.x = 100 + Math.random() * 1848;
passenger.y = Math.random() > 0.5 ? 90 : 500; // Top or bottom sidewalk
passengers.push(passenger);
game.addChild(passenger);
}
}
function createDestination() {
if (currentDestination) {
currentDestination.destroy();
currentDestination = null;
}
currentDestination = new Destination();
currentDestination.x = 200 + Math.random() * 1648;
currentDestination.y = taxi.passenger.y > 300 ? 90 : 500; // Opposite side of pickup
game.addChild(currentDestination);
}
function updatePassengerDisplay() {
if (taxi.hasPassenger) {
passengerText.setText('Passenger: $' + Math.round(taxi.passenger.fare));
timerText.setText(Math.round(taxi.passenger.timeLimit) + 's');
} else {
passengerText.setText('No Passenger');
timerText.setText('');
}
}
game.update = function () {
gameTime++;
spawnTimer++;
// Spawn traffic cars
if (spawnTimer % 90 === 0) {
spawnTrafficCar();
}
// Spawn passengers
if (spawnTimer % 240 === 0) {
spawnPassenger();
}
// Update traffic cars
for (var i = trafficCars.length - 1; i >= 0; i--) {
var car = trafficCars[i];
if (car.y > 2800) {
car.destroy();
trafficCars.splice(i, 1);
continue;
}
// Check collision with taxi
if (taxi.intersects(car) && !taxi.invulnerable) {
LK.getSound('crash').play();
LK.effects.flashObject(taxi, 0xFF0000, 500);
// Slow down and make invulnerable briefly
taxi.speed = Math.max(1, taxi.speed - 3);
taxi.invulnerable = true;
LK.setTimeout(function () {
taxi.invulnerable = false;
}, 1000);
// Lose some money
money = Math.max(0, money - 10);
moneyText.setText('$' + money);
}
}
// Update passengers
for (var i = passengers.length - 1; i >= 0; i--) {
var passenger = passengers[i];
if (passenger.picked) {
passengers.splice(i, 1);
continue;
}
}
// Handle passenger timer and destination
if (taxi.hasPassenger && taxi.passenger) {
taxi.passenger.timeLimit -= 1 / 60; // Decrease by 1/60th of a second each frame
if (taxi.passenger.timeLimit <= 0) {
// Time's up! Lose the passenger
taxi.hasPassenger = false;
taxi.passenger = null;
if (currentDestination) {
currentDestination.destroy();
currentDestination = null;
}
money = Math.max(0, money - 20);
moneyText.setText('$' + money);
updatePassengerDisplay();
} else {
// Check if reached destination
if (currentDestination && taxi.intersects(currentDestination)) {
LK.getSound('dropoff').play();
// Calculate fare based on time remaining
var timeBonus = taxi.passenger.timeLimit > 10 ? 1.5 : 1.0;
var earnedMoney = Math.round(taxi.passenger.fare * timeBonus);
money += earnedMoney;
// Add to score
LK.setScore(LK.getScore() + earnedMoney);
moneyText.setText('$' + money);
taxi.hasPassenger = false;
taxi.passenger = null;
currentDestination.destroy();
currentDestination = null;
updatePassengerDisplay();
// Check win condition
if (money >= 500) {
LK.showYouWin();
}
}
}
updatePassengerDisplay();
}
// Game over if too much time passes without earning money
if (gameTime > 3600 && money === 0) {
// 1 minute with no money
LK.showGameOver();
}
}; ===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,302 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+
+/****
+* Classes
+****/
+var Destination = Container.expand(function () {
+ var self = Container.call(this);
+ var destGraphics = self.attachAsset('destination', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ // Make it flash to be noticeable
+ tween(destGraphics, {
+ alpha: 0.3
+ }, {
+ duration: 500,
+ easing: tween.easeInOut,
+ onFinish: function onFinish() {
+ tween(destGraphics, {
+ alpha: 1
+ }, {
+ duration: 500,
+ easing: tween.easeInOut,
+ onFinish: function onFinish() {
+ if (self.parent) {
+ self.update = arguments.callee.caller;
+ }
+ }
+ });
+ }
+ });
+ return self;
+});
+var Passenger = Container.expand(function () {
+ var self = Container.call(this);
+ var passengerGraphics = self.attachAsset('passenger', {
+ anchorX: 0.5,
+ anchorY: 1
+ });
+ self.timeLimit = 15 + Math.random() * 20; // 15-35 seconds
+ self.fare = 20 + Math.random() * 30; // $20-50
+ self.picked = false;
+ self.down = function (x, y, obj) {
+ if (!self.picked && !taxi.hasPassenger) {
+ self.picked = true;
+ taxi.hasPassenger = true;
+ taxi.passenger = self;
+ self.visible = false;
+ // Create destination
+ createDestination();
+ LK.getSound('pickup').play();
+ updatePassengerDisplay();
+ }
+ };
+ return self;
+});
+var Taxi = Container.expand(function () {
+ var self = Container.call(this);
+ var taxiGraphics = self.attachAsset('taxi', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = 0;
+ self.maxSpeed = 8;
+ self.hasPassenger = false;
+ self.passenger = null;
+ self.invulnerable = false;
+ self.update = function () {
+ // Apply speed
+ self.y += self.speed;
+ // Keep taxi in bounds
+ if (self.x < 60) self.x = 60;
+ if (self.x > 1988) self.x = 1988;
+ // Gradual deceleration
+ if (self.speed > 3) {
+ self.speed -= 0.1;
+ }
+ };
+ return self;
+});
+var TrafficCar = Container.expand(function () {
+ var self = Container.call(this);
+ var carType = Math.random() > 0.5 ? 'car1' : 'car2';
+ var carGraphics = self.attachAsset(carType, {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = 2 + Math.random() * 4;
+ self.update = function () {
+ self.y += self.speed;
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x2C5F2D
+});
+
+/****
+* Game Code
+****/
+// Game variables
+var taxi;
+var trafficCars = [];
+var passengers = [];
+var currentDestination = null;
+var money = 0;
+var gameTime = 0;
+var passengerTimer = 0;
+var spawnTimer = 0;
+// UI elements
+var moneyText;
+var passengerText;
+var timerText;
+// Create road system
+var topSidewalk = game.addChild(LK.getAsset('sidewalk', {
+ x: 0,
+ y: 0
+}));
+var road = game.addChild(LK.getAsset('road', {
+ x: 0,
+ y: 100
+}));
+var bottomSidewalk = game.addChild(LK.getAsset('sidewalk', {
+ x: 0,
+ y: 400
+}));
+// Create taxi
+taxi = game.addChild(new Taxi());
+taxi.x = 1024;
+taxi.y = 250;
+// Create UI
+moneyText = new Text2('$' + money, {
+ size: 80,
+ fill: 0x00FF00
+});
+moneyText.anchor.set(0, 0);
+LK.gui.topRight.addChild(moneyText);
+moneyText.x = -200;
+moneyText.y = 20;
+passengerText = new Text2('No Passenger', {
+ size: 60,
+ fill: 0xFFFFFF
+});
+passengerText.anchor.set(0.5, 0);
+LK.gui.top.addChild(passengerText);
+passengerText.y = 120;
+timerText = new Text2('', {
+ size: 70,
+ fill: 0xFF0000
+});
+timerText.anchor.set(0.5, 0);
+LK.gui.top.addChild(timerText);
+timerText.y = 200;
+// 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 * 0.8;
+ dragStartX = x;
+ // Increase speed when moving
+ if (taxi.speed < taxi.maxSpeed) {
+ taxi.speed += 0.5;
+ }
+ }
+};
+game.up = function (x, y, obj) {
+ isDragging = false;
+};
+function spawnTrafficCar() {
+ var car = new TrafficCar();
+ car.x = 200 + Math.random() * 1648; // Random lane
+ car.y = -50;
+ trafficCars.push(car);
+ game.addChild(car);
+}
+function spawnPassenger() {
+ if (passengers.length < 3 && !taxi.hasPassenger) {
+ var passenger = new Passenger();
+ passenger.x = 100 + Math.random() * 1848;
+ passenger.y = Math.random() > 0.5 ? 90 : 500; // Top or bottom sidewalk
+ passengers.push(passenger);
+ game.addChild(passenger);
+ }
+}
+function createDestination() {
+ if (currentDestination) {
+ currentDestination.destroy();
+ currentDestination = null;
+ }
+ currentDestination = new Destination();
+ currentDestination.x = 200 + Math.random() * 1648;
+ currentDestination.y = taxi.passenger.y > 300 ? 90 : 500; // Opposite side of pickup
+ game.addChild(currentDestination);
+}
+function updatePassengerDisplay() {
+ if (taxi.hasPassenger) {
+ passengerText.setText('Passenger: $' + Math.round(taxi.passenger.fare));
+ timerText.setText(Math.round(taxi.passenger.timeLimit) + 's');
+ } else {
+ passengerText.setText('No Passenger');
+ timerText.setText('');
+ }
+}
+game.update = function () {
+ gameTime++;
+ spawnTimer++;
+ // Spawn traffic cars
+ if (spawnTimer % 90 === 0) {
+ spawnTrafficCar();
+ }
+ // Spawn passengers
+ if (spawnTimer % 240 === 0) {
+ spawnPassenger();
+ }
+ // Update traffic cars
+ for (var i = trafficCars.length - 1; i >= 0; i--) {
+ var car = trafficCars[i];
+ if (car.y > 2800) {
+ car.destroy();
+ trafficCars.splice(i, 1);
+ continue;
+ }
+ // Check collision with taxi
+ if (taxi.intersects(car) && !taxi.invulnerable) {
+ LK.getSound('crash').play();
+ LK.effects.flashObject(taxi, 0xFF0000, 500);
+ // Slow down and make invulnerable briefly
+ taxi.speed = Math.max(1, taxi.speed - 3);
+ taxi.invulnerable = true;
+ LK.setTimeout(function () {
+ taxi.invulnerable = false;
+ }, 1000);
+ // Lose some money
+ money = Math.max(0, money - 10);
+ moneyText.setText('$' + money);
+ }
+ }
+ // Update passengers
+ for (var i = passengers.length - 1; i >= 0; i--) {
+ var passenger = passengers[i];
+ if (passenger.picked) {
+ passengers.splice(i, 1);
+ continue;
+ }
+ }
+ // Handle passenger timer and destination
+ if (taxi.hasPassenger && taxi.passenger) {
+ taxi.passenger.timeLimit -= 1 / 60; // Decrease by 1/60th of a second each frame
+ if (taxi.passenger.timeLimit <= 0) {
+ // Time's up! Lose the passenger
+ taxi.hasPassenger = false;
+ taxi.passenger = null;
+ if (currentDestination) {
+ currentDestination.destroy();
+ currentDestination = null;
+ }
+ money = Math.max(0, money - 20);
+ moneyText.setText('$' + money);
+ updatePassengerDisplay();
+ } else {
+ // Check if reached destination
+ if (currentDestination && taxi.intersects(currentDestination)) {
+ LK.getSound('dropoff').play();
+ // Calculate fare based on time remaining
+ var timeBonus = taxi.passenger.timeLimit > 10 ? 1.5 : 1.0;
+ var earnedMoney = Math.round(taxi.passenger.fare * timeBonus);
+ money += earnedMoney;
+ // Add to score
+ LK.setScore(LK.getScore() + earnedMoney);
+ moneyText.setText('$' + money);
+ taxi.hasPassenger = false;
+ taxi.passenger = null;
+ currentDestination.destroy();
+ currentDestination = null;
+ updatePassengerDisplay();
+ // Check win condition
+ if (money >= 500) {
+ LK.showYouWin();
+ }
+ }
+ }
+ updatePassengerDisplay();
+ }
+ // Game over if too much time passes without earning money
+ if (gameTime > 3600 && money === 0) {
+ // 1 minute with no money
+ LK.showGameOver();
+ }
+};
\ No newline at end of file