User prompt
Let's make the game a bit more agar.io-style, with the courier in the center and the map scrolling. And arrows indicate the pickup and delivery points. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Let's make the game a bit more agar.io-style, with the courier in the center and the map scrolling. And arrows indicate the pickup and delivery points. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
fill all screen with shops and buildings. And change colours orders and customers. Customers colors match the their order color ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
delete gray bars on screen
User prompt
please add another ai couriers and at the start may be more than 1 customer order different foods. And fix the building and shops locations. emptied first row because player cant reach there ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Connect building entrances with buildings. Have couriers pick up and deliver packages. If couriers intersect with each other or the player, they can change their path or turn back and take an alternative route.
User prompt
Please direct the couriers' paths so they don't intersect. They also can't pick up or deliver packages. Please also adjust the height of building entrances to 1px.
User prompt
Other AI couriers are frozen. Could you please take a look at them? They are not doing their job.
User prompt
The neighborhood should be infinite, like going to the far left of the screen and reaching the far right. Like in the game Snake. Packages should keep appearing. Each time a package is completed, a new one is created.
User prompt
At the beginning of the game, there can be multiple packages at the same time, for example, 5 packages. Match the colors of these packages and the customer. Other couriers should not be chasing the same package.
User prompt
Cars should be able to enter the neighborhood. Buildings and shops should have entrances. Couriers should be required to come to the asphalt in front of the entrance to pick up and make deliveries. The red dot representing customers should be located exactly in the middle of the building.
User prompt
Other couriers can only move vertically or horizontally between buildings. They cannot travel diagonally. Their speeds also vary. They can create traffic congestion. Add cars based on the money earned outside of the couriers. Start with 10 cars and increase to 20 cars until you reach $200. Cars, couriers, and the player cannot drive over each other.
User prompt
The size of the buildings should be smaller and the roads should be wider.
User prompt
The order is completed when it arrives at the customer's premises.
User prompt
Buildings should be arranged in an orderly manner. All buildings should have roads around them and these roads should be connected to each other.
User prompt
The neighborhood layout should consist of a 4-block park in the middle and buildings arranged in a non-circular pattern around it.
User prompt
To avoid couriers getting stuck in buildings, designate wider routes and have couriers follow them to reach the customer. They should choose which route to use. However, they must be able to reach the customer. Furthermore, if a package arrives anywhere in the store, it should be picked up and delivered to the customer's location within the building.
User prompt
Couriers do not wander around randomly, they just follow the routes and pick up and deliver the package.
User prompt
The purpose of other couriers is to pick up the order and deliver it to the customer.
User prompt
Customers should only be visible when the order arrives. If the courier doesn't pick up the order, it should disappear after a while. And then there will be new orders and new customers at different locations. Other couriers will be randomly passing through the streets, and they will be competing with us.
User prompt
The package's time starts when the courier receives the package.
User prompt
Please have buildings and shops line up in a circle. Layer by layer, covering the entire screen, with these circles gradually taking on more of the screen shape with each layer. Roads should be asphalt-colored, with no buildings overlapping. Shops and houses should change with each new game.
User prompt
the shops are need to be in a row as circular. And every new game will be changed shops and houses randomly.
User prompt
okay, we need to change the map. I want to make a neighbourhood. Middle of the screen have a park. And houses like a circular plan. and 1 outer layer is circular and have another houses and shops randomly. And i dont want to see gray squares on the screen.
User prompt
please show buildings are with dark blue, shops are orange, order is yellow. And customers must be in buildings. And please allow minimum 25 seconds per order completing.
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var AICourier = Container.expand(function () {
var self = Container.call(this);
var courierGraphics = self.attachAsset('courier', {
anchorX: 0.5,
anchorY: 0.5
});
courierGraphics.tint = 0xff4444; // Red tint to distinguish from player
self.speed = 6;
self.targetX = 1024;
self.targetY = 1366;
self.changeTargetTimer = 0;
self.hasOrder = false;
self.targetRestaurant = null;
self.targetCustomer = null;
self.currentWaypoint = 0;
self.routeWaypoints = [];
self.update = function () {
// Check for orders to pick up if not carrying one
if (!self.hasOrder && currentOrder && !courier.hasOrder && gameState === 'pickup') {
// AI courier tries to pick up the current order
var orderDistance = Math.sqrt(Math.pow(currentOrder.x - self.x, 2) + Math.pow(currentOrder.y - self.y, 2));
if (orderDistance < 50) {
// Pick up the order
self.hasOrder = true;
self.targetCustomer = currentOrder.customer;
self.targetRestaurant = currentOrder.restaurant;
// Start the package timer
currentOrder.timerStarted = true;
// Move order with AI courier
currentOrder.x = self.x;
currentOrder.y = self.y - 40;
gameState = 'delivery';
} else {
// Move toward the order
self.targetX = currentOrder.x;
self.targetY = currentOrder.y;
}
} else if (self.hasOrder && self.targetCustomer && currentOrder) {
// AI courier is delivering - move toward customer
var customerDistance = Math.sqrt(Math.pow(self.targetCustomer.x - self.x, 2) + Math.pow(self.targetCustomer.y - self.y, 2));
if (customerDistance < 50) {
// Deliver the order
self.hasOrder = false;
self.targetCustomer = null;
self.targetRestaurant = null;
// Complete the delivery (similar to player delivery)
if (currentOrder) {
currentOrder.restaurant.hasOrder = false;
currentOrder.customer.waitingForOrder = false;
currentOrder.customer.visible = false;
if (currentOrder.customer.deliveryTarget) {
tween.stop(currentOrder.customer.deliveryTarget);
currentOrder.customer.deliveryTarget.destroy();
currentOrder.customer.deliveryTarget = null;
}
currentOrder.destroy();
for (var i = orders.length - 1; i >= 0; i--) {
if (orders[i] === currentOrder) {
orders.splice(i, 1);
break;
}
}
currentOrder = null;
gameState = 'pickup';
// Create new order after delivery
LK.setTimeout(function () {
createNewOrder();
}, 1000);
}
} else {
// Move toward customer
self.targetX = self.targetCustomer.x;
self.targetY = self.targetCustomer.y;
}
} else {
// When not carrying order, follow waypoint route
if (self.routeWaypoints.length > 0) {
var currentWaypoint = self.routeWaypoints[self.currentWaypoint];
self.targetX = currentWaypoint.x;
self.targetY = currentWaypoint.y;
// Check if reached current waypoint
var waypointDistance = Math.sqrt(Math.pow(currentWaypoint.x - self.x, 2) + Math.pow(currentWaypoint.y - self.y, 2));
if (waypointDistance < 80) {
// Move to next waypoint
self.currentWaypoint = (self.currentWaypoint + 1) % self.routeWaypoints.length;
}
} else {
// Fallback: move toward center if no waypoints
self.targetX = 1024;
self.targetY = 1366;
}
}
// Move toward target
var dx = self.targetX - self.x;
var dy = self.targetY - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance > 10) {
var newX = self.x + dx / distance * self.speed;
var newY = self.y + dy / distance * self.speed;
// Check collision with buildings
var canMove = true;
for (var i = 0; i < buildings.length; i++) {
var tempCourier = {
x: newX,
y: newY,
width: 60,
height: 60
};
var building = buildings[i];
if (tempCourier.x < building.x + building.width / 2 && tempCourier.x + tempCourier.width / 2 > building.x - building.width / 2 && tempCourier.y < building.y + building.height / 2 && tempCourier.y + tempCourier.height / 2 > building.y - building.height / 2) {
canMove = false;
break;
}
}
if (canMove) {
self.x = newX;
self.y = newY;
}
}
// Update order position if carrying one
if (self.hasOrder && currentOrder) {
currentOrder.x = self.x;
currentOrder.y = self.y - 40;
}
};
return self;
});
var Courier = Container.expand(function () {
var self = Container.call(this);
var courierGraphics = self.attachAsset('courier', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 8;
self.hasOrder = false;
self.targetRestaurant = null;
self.targetCustomer = null;
self.moveToward = function (targetX, targetY) {
var dx = targetX - self.x;
var dy = targetY - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance > 10) {
var newX = self.x + dx / distance * self.speed;
var newY = self.y + dy / distance * self.speed;
// Check collision with buildings
var canMove = true;
for (var i = 0; i < buildings.length; i++) {
var tempCourier = {
x: newX,
y: newY,
width: 60,
height: 60
};
var building = buildings[i];
if (tempCourier.x < building.x + building.width / 2 && tempCourier.x + tempCourier.width / 2 > building.x - building.width / 2 && tempCourier.y < building.y + building.height / 2 && tempCourier.y + tempCourier.height / 2 > building.y - building.height / 2) {
canMove = false;
break;
}
}
if (canMove) {
self.x = newX;
self.y = newY;
}
}
};
return self;
});
var Customer = Container.expand(function () {
var self = Container.call(this);
var customerGraphics = self.attachAsset('customer', {
anchorX: 0.5,
anchorY: 0.5
});
self.waitingForOrder = false;
self.orderTime = 0;
self.maxWaitTime = 10000; // 10 seconds
self.deliveryTarget = null;
self.visible = false; // Start invisible
self.update = function () {
if (self.waitingForOrder) {
self.orderTime += 16.67; // Approximate ms per frame at 60fps
}
};
return self;
});
var Order = Container.expand(function () {
var self = Container.call(this);
var orderGraphics = self.attachAsset('order', {
anchorX: 0.5,
anchorY: 0.5
});
self.restaurant = null;
self.customer = null;
self.timeLimit = 25000; // 25 seconds
self.timeRemaining = self.timeLimit;
self.timerStarted = false; // Timer doesn't start until courier picks up
self.lifeTime = 0; // Track how long order has existed
self.maxLifeTime = 15000; // Order expires after 15 seconds if not picked up
self.update = function () {
if (self.timerStarted && self.timeRemaining > 0) {
self.timeRemaining -= 16.67;
}
// Track order lifetime for auto-expiry
if (!self.timerStarted) {
self.lifeTime += 16.67;
}
};
return self;
});
var PowerUp = Container.expand(function (type) {
var self = Container.call(this);
var powerupGraphics = self.attachAsset(type === 'health' ? 'healthPowerup' : 'timePowerup', {
anchorX: 0.5,
anchorY: 0.5
});
self.type = type;
self.lifeTime = 0;
self.maxLifeTime = 8000; // 8 seconds
self.update = function () {
self.lifeTime += 16.67;
// Pulse animation
var pulse = 1 + 0.2 * Math.sin(self.lifeTime * 0.01);
powerupGraphics.scaleX = pulse;
powerupGraphics.scaleY = pulse;
};
return self;
});
var Restaurant = Container.expand(function () {
var self = Container.call(this);
var restaurantGraphics = self.attachAsset('restaurant', {
anchorX: 0.5,
anchorY: 0.5
});
self.hasOrder = false;
self.orderReady = false;
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x8BC34A
});
/****
* Game Code
****/
// Game variables
var courier;
var aiCouriers = [];
var restaurants = [];
var customers = [];
var orders = [];
var powerUps = [];
var buildings = [];
var health = 100;
var money = 0;
var currentOrder = null;
var gameState = 'pickup'; // 'pickup', 'delivery'
var timeFreezeActive = false;
var timeFreezeRemaining = 0;
// UI Elements
var healthBar = new Text2('Health: 100', {
size: 60,
fill: 0xFF0000
});
healthBar.anchor.set(0, 0);
LK.gui.topLeft.addChild(healthBar);
healthBar.x = 120;
healthBar.y = 20;
var moneyText = new Text2('$0', {
size: 60,
fill: 0x00FF00
});
moneyText.anchor.set(1, 0);
LK.gui.topRight.addChild(moneyText);
moneyText.x = -20;
moneyText.y = 20;
var orderTimer = new Text2('', {
size: 50,
fill: 0xFFFF00
});
orderTimer.anchor.set(0.5, 0);
LK.gui.top.addChild(orderTimer);
orderTimer.y = 100;
// Create neighborhood layout
function createNeighborhood() {
// Center coordinates
var centerX = 1024;
var centerY = 1366;
// Create central park
var park = game.addChild(LK.getAsset('building', {
anchorX: 0.5,
anchorY: 0.5,
x: centerX,
y: centerY
}));
park.tint = 0x4CAF50; // Green color for park
// Create multiple circular layers
var layers = [{
radius: 280,
count: 8,
type: 'mixed'
},
// Inner layer - mixed buildings
{
radius: 450,
count: 12,
type: 'road'
},
// Road layer
{
radius: 580,
count: 16,
type: 'mixed'
},
// Middle layer - mixed buildings
{
radius: 750,
count: 20,
type: 'road'
},
// Road layer
{
radius: 880,
count: 24,
type: 'mixed'
},
// Outer layer - mixed buildings
{
radius: 1050,
count: 28,
type: 'mixed'
} // Edge layer - mixed buildings
];
// Store all building and restaurant positions for randomization
var allBuildingPositions = [];
var allRestaurantPositions = [];
// Generate positions for each layer
for (var layerIndex = 0; layerIndex < layers.length; layerIndex++) {
var layer = layers[layerIndex];
if (layer.type === 'road') {
// Create asphalt road segments
for (var i = 0; i < layer.count; i++) {
var angle = i / layer.count * Math.PI * 2;
var roadX = centerX + Math.cos(angle) * layer.radius;
var roadY = centerY + Math.sin(angle) * layer.radius;
// Only create roads within bounds
if (roadX > 60 && roadX < 1988 && roadY > 60 && roadY < 2672) {
var roadSegment = game.addChild(LK.getAsset('building', {
anchorX: 0.5,
anchorY: 0.5,
x: roadX,
y: roadY
}));
roadSegment.tint = 0x404040; // Asphalt color
roadSegment.scaleX = 0.8;
roadSegment.scaleY = 0.8;
}
}
} else {
// Generate building positions for this layer
for (var i = 0; i < layer.count; i++) {
var angle = i / layer.count * Math.PI * 2;
var buildingX = centerX + Math.cos(angle) * layer.radius;
var buildingY = centerY + Math.sin(angle) * layer.radius;
// Only add positions within bounds and not overlapping with roads
if (buildingX > 100 && buildingX < 1948 && buildingY > 100 && buildingY < 2632) {
var validPosition = true;
// Check minimum distance from roads
for (var roadLayer = 0; roadLayer < layers.length; roadLayer++) {
if (layers[roadLayer].type === 'road') {
var distanceToRoad = Math.abs(layer.radius - layers[roadLayer].radius);
if (distanceToRoad < 80) {
validPosition = false;
break;
}
}
}
if (validPosition) {
// Randomly assign as building or restaurant position
if (Math.random() < 0.3) {
// 30% chance for restaurant
allRestaurantPositions.push({
x: buildingX,
y: buildingY
});
} else {
// 70% chance for building
allBuildingPositions.push({
x: buildingX,
y: buildingY
});
}
}
}
}
}
}
// Shuffle positions for randomness each game
for (var i = allBuildingPositions.length - 1; i > 0; i--) {
var j = Math.floor(Math.random() * (i + 1));
var temp = allBuildingPositions[i];
allBuildingPositions[i] = allBuildingPositions[j];
allBuildingPositions[j] = temp;
}
for (var i = allRestaurantPositions.length - 1; i > 0; i--) {
var j = Math.floor(Math.random() * (i + 1));
var temp = allRestaurantPositions[i];
allRestaurantPositions[i] = allRestaurantPositions[j];
allRestaurantPositions[j] = temp;
}
// Create buildings at shuffled positions
for (var i = 0; i < Math.min(35, allBuildingPositions.length); i++) {
var building = game.addChild(LK.getAsset('building', {
anchorX: 0.5,
anchorY: 0.5,
x: allBuildingPositions[i].x,
y: allBuildingPositions[i].y
}));
buildings.push(building);
}
// Create restaurants at shuffled positions
for (var i = 0; i < Math.min(8, allRestaurantPositions.length); i++) {
var restaurant = game.addChild(new Restaurant());
restaurant.x = allRestaurantPositions[i].x;
restaurant.y = allRestaurantPositions[i].y;
restaurants.push(restaurant);
}
// Create customers - place them inside buildings
var customerCount = Math.min(12, buildings.length);
for (var i = 0; i < customerCount; i++) {
var customer = game.addChild(new Customer());
// Place customer at same position as building
customer.x = buildings[i].x;
customer.y = buildings[i].y;
customers.push(customer);
}
}
function createNewOrder() {
if (currentOrder) return;
var availableRestaurants = restaurants.filter(function (r) {
return !r.hasOrder;
});
if (availableRestaurants.length === 0) return;
// Select random restaurant and building for new customer
var restaurant = availableRestaurants[Math.floor(Math.random() * availableRestaurants.length)];
var availableBuildings = buildings.filter(function (b) {
// Don't use buildings that already have visible customers
for (var i = 0; i < customers.length; i++) {
if (customers[i].visible && customers[i].x === b.x && customers[i].y === b.y) {
return false;
}
}
return true;
});
if (availableBuildings.length === 0) return;
var selectedBuilding = availableBuildings[Math.floor(Math.random() * availableBuildings.length)];
// Find or create customer at selected building
var customer = null;
for (var i = 0; i < customers.length; i++) {
if (!customers[i].waitingForOrder && customers[i].x === selectedBuilding.x && customers[i].y === selectedBuilding.y) {
customer = customers[i];
break;
}
}
// If no customer at this building, create one
if (!customer) {
customer = game.addChild(new Customer());
customer.x = selectedBuilding.x;
customer.y = selectedBuilding.y;
customers.push(customer);
}
var order = game.addChild(new Order());
order.x = restaurant.x;
order.y = restaurant.y - 60;
order.restaurant = restaurant;
order.customer = customer;
restaurant.hasOrder = true;
restaurant.orderReady = true;
customer.waitingForOrder = true;
customer.visible = true; // Make customer visible when order arrives
customer.orderTime = 0;
// Create delivery target indicator
var deliveryTarget = game.addChild(LK.getAsset('deliveryTarget', {
anchorX: 0.5,
anchorY: 0.5,
x: customer.x,
y: customer.y - 50
}));
customer.deliveryTarget = deliveryTarget;
// Start flashing animation
tween(deliveryTarget, {
alpha: 0.3
}, {
duration: 500,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(deliveryTarget, {
alpha: 1
}, {
duration: 500,
easing: tween.easeInOut,
onFinish: function onFinish() {
if (deliveryTarget.parent) {
tween(deliveryTarget, {
alpha: 0.3
}, {
duration: 500,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(deliveryTarget, {
alpha: 1
}, {
duration: 500,
easing: tween.easeInOut
});
}
});
}
}
});
}
});
currentOrder = order;
orders.push(order);
gameState = 'pickup';
}
function spawnPowerUp() {
if (powerUps.length >= 3) return;
var type = Math.random() < 0.6 ? 'health' : 'time';
var powerUp = game.addChild(new PowerUp(type));
powerUp.x = Math.random() * 1800 + 124;
powerUp.y = Math.random() * 2400 + 166;
powerUps.push(powerUp);
}
function updateUI() {
healthBar.setText('Health: ' + Math.floor(health));
moneyText.setText('$' + money);
if (currentOrder && gameState === 'delivery') {
var timeLeft = Math.max(0, currentOrder.timeRemaining / 1000);
orderTimer.setText('Deliver in: ' + timeLeft.toFixed(1) + 's');
} else {
orderTimer.setText('');
}
}
function checkCollisions() {
// Check courier-restaurant collision for pickup
if (gameState === 'pickup' && currentOrder) {
if (courier.intersects(currentOrder.restaurant)) {
// Pick up order
LK.getSound('pickup').play();
courier.hasOrder = true;
gameState = 'delivery';
currentOrder.x = courier.x;
currentOrder.y = courier.y - 40;
// Start the package timer when courier receives the package
currentOrder.timerStarted = true;
}
}
// Check courier-customer collision for delivery
if (gameState === 'delivery' && currentOrder && courier.hasOrder) {
if (courier.intersects(currentOrder.customer)) {
// Deliver order
LK.getSound('delivery').play();
completeDelivery();
}
}
// Check courier-powerup collisions
for (var i = powerUps.length - 1; i >= 0; i--) {
var powerUp = powerUps[i];
if (courier.intersects(powerUp)) {
LK.getSound('powerup').play();
if (powerUp.type === 'health') {
health = Math.min(100, health + 25);
} else if (powerUp.type === 'time') {
timeFreezeActive = true;
timeFreezeRemaining = 3000; // 3 seconds
}
powerUp.destroy();
powerUps.splice(i, 1);
}
}
}
function completeDelivery() {
if (!currentOrder) return;
var deliveryTime = currentOrder.timeLimit - currentOrder.timeRemaining;
var bonus = 0;
if (currentOrder.timeRemaining > 0) {
// Successful delivery
var timeBonus = Math.floor(currentOrder.timeRemaining / 1000);
bonus = 10 + timeBonus;
money += bonus;
// Flash green for success
LK.effects.flashObject(courier, 0x00ff00, 500);
} else {
// Late delivery - health penalty
health -= 20;
LK.effects.flashObject(courier, 0xff0000, 1000);
if (health <= 0) {
LK.showGameOver();
return;
}
}
// Clean up order
currentOrder.restaurant.hasOrder = false;
currentOrder.customer.waitingForOrder = false;
currentOrder.customer.visible = false; // Hide customer after delivery
// Remove delivery target indicator
if (currentOrder.customer.deliveryTarget) {
tween.stop(currentOrder.customer.deliveryTarget);
currentOrder.customer.deliveryTarget.destroy();
currentOrder.customer.deliveryTarget = null;
}
currentOrder.destroy();
for (var i = orders.length - 1; i >= 0; i--) {
if (orders[i] === currentOrder) {
orders.splice(i, 1);
break;
}
}
currentOrder = null;
courier.hasOrder = false;
gameState = 'pickup';
// Create new order after short delay
LK.setTimeout(function () {
createNewOrder();
}, 1000);
}
// Initialize game elements
createNeighborhood();
// Create courier
courier = game.addChild(new Courier());
courier.x = 1024;
courier.y = 1366;
// Create AI couriers
for (var i = 0; i < 3; i++) {
var aiCourier = game.addChild(new AICourier());
aiCourier.x = Math.random() * 1800 + 124;
aiCourier.y = Math.random() * 2400 + 166;
// Create route waypoints based on restaurant and road positions
aiCourier.routeWaypoints = [];
// Add restaurant positions as waypoints
for (var j = 0; j < restaurants.length; j++) {
aiCourier.routeWaypoints.push({
x: restaurants[j].x,
y: restaurants[j].y
});
}
// Add some road intersection points as additional waypoints
var centerX = 1024;
var centerY = 1366;
var roadRadii = [450, 750]; // Road layer radii
for (var r = 0; r < roadRadii.length; r++) {
for (var angle = 0; angle < Math.PI * 2; angle += Math.PI / 4) {
var roadX = centerX + Math.cos(angle) * roadRadii[r];
var roadY = centerY + Math.sin(angle) * roadRadii[r];
if (roadX > 100 && roadX < 1948 && roadY > 100 && roadY < 2632) {
aiCourier.routeWaypoints.push({
x: roadX,
y: roadY
});
}
}
}
aiCouriers.push(aiCourier);
}
// Touch controls
var targetX = courier.x;
var targetY = courier.y;
game.down = function (x, y, obj) {
targetX = x;
targetY = y;
};
game.move = function (x, y, obj) {
targetX = x;
targetY = y;
};
// Create first order
createNewOrder();
// Spawn initial power-up
LK.setTimeout(function () {
spawnPowerUp();
}, 3000);
game.update = function () {
// Move courier toward target
courier.moveToward(targetX, targetY);
// Update time freeze
if (timeFreezeActive) {
timeFreezeRemaining -= 16.67;
if (timeFreezeRemaining <= 0) {
timeFreezeActive = false;
}
}
// Update current order timer (if not frozen)
if (currentOrder && !timeFreezeActive) {
currentOrder.update();
// Check if order expired before pickup
if (!currentOrder.timerStarted && currentOrder.lifeTime >= currentOrder.maxLifeTime) {
// Order expired - clean up and create new one
currentOrder.restaurant.hasOrder = false;
currentOrder.customer.waitingForOrder = false;
currentOrder.customer.visible = false; // Hide customer
if (currentOrder.customer.deliveryTarget) {
tween.stop(currentOrder.customer.deliveryTarget);
currentOrder.customer.deliveryTarget.destroy();
currentOrder.customer.deliveryTarget = null;
}
currentOrder.destroy();
for (var i = orders.length - 1; i >= 0; i--) {
if (orders[i] === currentOrder) {
orders.splice(i, 1);
break;
}
}
currentOrder = null;
gameState = 'pickup';
// Create new order immediately
LK.setTimeout(function () {
createNewOrder();
}, 500);
} else {
// Move order with courier if picked up
if (courier.hasOrder && gameState === 'delivery') {
currentOrder.x = courier.x;
currentOrder.y = courier.y - 40;
}
// Maintain delivery target flashing
if (gameState === 'delivery' && currentOrder.customer.deliveryTarget) {
var target = currentOrder.customer.deliveryTarget;
if (!target.isFlashing) {
var _flashTarget = function flashTarget() {
if (target.parent) {
tween(target, {
alpha: 0.3
}, {
duration: 500,
easing: tween.easeInOut,
onFinish: function onFinish() {
if (target.parent) {
tween(target, {
alpha: 1
}, {
duration: 500,
easing: tween.easeInOut,
onFinish: _flashTarget
});
}
}
});
}
};
target.isFlashing = true;
_flashTarget();
}
}
// Check for failed delivery
if (currentOrder.timeRemaining <= 0 && gameState === 'delivery') {
completeDelivery();
}
}
}
// Update AI couriers
for (var i = 0; i < aiCouriers.length; i++) {
aiCouriers[i].update();
}
// Update customers
for (var i = 0; i < customers.length; i++) {
customers[i].update();
}
// Update power-ups
for (var i = powerUps.length - 1; i >= 0; i--) {
var powerUp = powerUps[i];
powerUp.update();
if (powerUp.lifeTime >= powerUp.maxLifeTime) {
powerUp.destroy();
powerUps.splice(i, 1);
}
}
// Spawn new power-ups occasionally
if (LK.ticks % 600 === 0) {
// Every 10 seconds
spawnPowerUp();
}
// Check collisions
checkCollisions();
// Update UI
updateUI();
// Win condition (optional - could be score based)
if (money >= 200) {
LK.showYouWin();
}
}; ===================================================================
--- original.js
+++ change.js
@@ -19,8 +19,10 @@
self.changeTargetTimer = 0;
self.hasOrder = false;
self.targetRestaurant = null;
self.targetCustomer = null;
+ self.currentWaypoint = 0;
+ self.routeWaypoints = [];
self.update = function () {
// Check for orders to pick up if not carrying one
if (!self.hasOrder && currentOrder && !courier.hasOrder && gameState === 'pickup') {
// AI courier tries to pick up the current order
@@ -78,14 +80,23 @@
self.targetX = self.targetCustomer.x;
self.targetY = self.targetCustomer.y;
}
} else {
- // Change target every 3 seconds for random movement
- self.changeTargetTimer += 16.67;
- if (self.changeTargetTimer >= 3000) {
- self.targetX = Math.random() * 1800 + 124;
- self.targetY = Math.random() * 2400 + 166;
- self.changeTargetTimer = 0;
+ // When not carrying order, follow waypoint route
+ if (self.routeWaypoints.length > 0) {
+ var currentWaypoint = self.routeWaypoints[self.currentWaypoint];
+ self.targetX = currentWaypoint.x;
+ self.targetY = currentWaypoint.y;
+ // Check if reached current waypoint
+ var waypointDistance = Math.sqrt(Math.pow(currentWaypoint.x - self.x, 2) + Math.pow(currentWaypoint.y - self.y, 2));
+ if (waypointDistance < 80) {
+ // Move to next waypoint
+ self.currentWaypoint = (self.currentWaypoint + 1) % self.routeWaypoints.length;
+ }
+ } else {
+ // Fallback: move toward center if no waypoints
+ self.targetX = 1024;
+ self.targetY = 1366;
}
}
// Move toward target
var dx = self.targetX - self.x;
@@ -635,8 +646,33 @@
for (var i = 0; i < 3; i++) {
var aiCourier = game.addChild(new AICourier());
aiCourier.x = Math.random() * 1800 + 124;
aiCourier.y = Math.random() * 2400 + 166;
+ // Create route waypoints based on restaurant and road positions
+ aiCourier.routeWaypoints = [];
+ // Add restaurant positions as waypoints
+ for (var j = 0; j < restaurants.length; j++) {
+ aiCourier.routeWaypoints.push({
+ x: restaurants[j].x,
+ y: restaurants[j].y
+ });
+ }
+ // Add some road intersection points as additional waypoints
+ var centerX = 1024;
+ var centerY = 1366;
+ var roadRadii = [450, 750]; // Road layer radii
+ for (var r = 0; r < roadRadii.length; r++) {
+ for (var angle = 0; angle < Math.PI * 2; angle += Math.PI / 4) {
+ var roadX = centerX + Math.cos(angle) * roadRadii[r];
+ var roadY = centerY + Math.sin(angle) * roadRadii[r];
+ if (roadX > 100 && roadX < 1948 && roadY > 100 && roadY < 2632) {
+ aiCourier.routeWaypoints.push({
+ x: roadX,
+ y: roadY
+ });
+ }
+ }
+ }
aiCouriers.push(aiCourier);
}
// Touch controls
var targetX = courier.x;
ıts a courier scooter its looking behind . No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
police car with flashing lights. In-Game asset. 2d. High contrast. No shadows
vandal riding dirt bike. In-Game asset. High contrast. No shadows
health powerup. In-Game asset. 2d. High contrast. No shadows
pizza boxes. In-Game asset. 2d. High contrast. No shadows
extra time powerup. In-Game asset. 2d. High contrast. No shadows
restaurant shop. In-Game asset. High contrast. No shadows
town house. In-Game asset. 2d. High contrast. No shadows
a man waiting outside. In-Game asset. 2d. High contrast. No shadows
arrow. In-Game asset. 2d. High contrast. No shadows
fence. In-Game asset. 2d. High contrast. No shadows