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 = 5;
self.update = function () {
// Keep taxi in bounds (road width)
if (self.x < 200) self.x = 200;
if (self.x > 1848) self.x = 1848;
};
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 = 3 + Math.random() * 3;
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 roadLines = [];
var spawnTimer = 0;
var roadSpeed = 5;
// 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 = 300 + Math.random() * 1448; // Random position on road
car.y = -50;
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
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
@@ -5,91 +5,29 @@
/****
* 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.speed = 5;
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;
- }
+ // Keep taxi in bounds (road width)
+ if (self.x < 200) self.x = 200;
+ if (self.x > 1848) self.x = 1848;
};
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, {
+ var carGraphics = self.attachAsset('trafficCar', {
anchorX: 0.5,
anchorY: 0.5
});
- self.speed = 2 + Math.random() * 4;
+ self.speed = 3 + Math.random() * 3;
self.update = function () {
self.y += self.speed;
};
return self;
@@ -107,58 +45,38 @@
****/
// Game variables
var taxi;
var trafficCars = [];
-var passengers = [];
-var currentDestination = null;
-var money = 0;
-var gameTime = 0;
-var passengerTimer = 0;
+var roadLines = [];
var spawnTimer = 0;
-// UI elements
-var moneyText;
-var passengerText;
-var timerText;
-// Create road system
-var topSidewalk = game.addChild(LK.getAsset('sidewalk', {
+var roadSpeed = 5;
+// Create road background
+var road = game.addChild(LK.getAsset('road', {
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 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 = 250;
-// Create UI
-moneyText = new Text2('$' + money, {
+taxi.y = 2200;
+// Create score display
+var scoreText = new Text2('Score: ' + LK.getScore(), {
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;
+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) {
@@ -167,136 +85,56 @@
};
game.move = function (x, y, obj) {
if (isDragging) {
var deltaX = x - dragStartX;
- taxi.x += deltaX * 0.8;
+ taxi.x += deltaX;
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.x = 300 + Math.random() * 1448; // Random position on road
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++;
+ // 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
- if (spawnTimer % 90 === 0) {
+ if (spawnTimer % 60 === 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) {
+ 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
- if (taxi.intersects(car) && !taxi.invulnerable) {
+ // Check collision with taxi - GAME OVER if collision
+ if (taxi.intersects(car)) {
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);
+ LK.effects.flashScreen(0xFF0000, 1000);
+ LK.showGameOver();
+ return;
}
}
- // Update passengers
- for (var i = passengers.length - 1; i >= 0; i--) {
- var passenger = passengers[i];
- if (passenger.picked) {
- passengers.splice(i, 1);
- continue;
- }
+ // Increase difficulty over time
+ if (spawnTimer % 600 === 0 && roadSpeed < 10) {
+ roadSpeed += 0.5;
}
- // 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