User prompt
remove the particles
User prompt
make the particles render before the bus is rendered
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'update')' in this line: 'bus.update();' Line Number: 176
User prompt
Fix Bug: 'Uncaught ReferenceError: bus is not defined' in this line: 'bus.x = 2048 / 2;' Line Number: 148
User prompt
render the bus on top of everything else
User prompt
Fix Bug: 'Uncaught ReferenceError: bus is not defined' in this line: 'self.addChild(bus);' Line Number: 132
User prompt
render the bus last
User prompt
render the particles first
User prompt
render the particles underneath everything else
User prompt
destroy particles that are dead
User prompt
make the particles disappear after 3 seconds
User prompt
make a particle trail behind the bus
User prompt
set the countdown timer to 15 every time
User prompt
only add one bomb with every point
User prompt
reduce the collision size of the bus
Code edit (2 edits merged)
Please save this source code
User prompt
set the start amount of bombs to 1
User prompt
make one more bomb appear with every point that is collected
User prompt
make the obstacles collision areas a lot smaller
Code edit (1 edits merged)
Please save this source code
User prompt
reduce the collision padding of the obstacless
User prompt
Fix Bug: 'TypeError: busBounds.intersects is not a function' in this line: 'if (busBounds.intersects(obstacleBounds)) {' Line Number: 89
User prompt
Fix Bug: 'TypeError: obstacles[i].getBounds(...).pad is not a function' in this line: 'var obstacleBounds = obstacles[i].getBounds().pad(-10);' Line Number: 84
var Obstacle = Container.expand(function () {
var self = Container.call(this);
var obstacleGraphics = self.createAsset('obstacle', 'Obstacle Graphics', 0.5, 0.5);
self.setPosition = function (x, y) {
self.x = x;
self.y = y;
};
});
var RoadBlock = Container.expand(function () {
var self = Container.call(this);
var roadBlockGraphics = self.createAsset('roadBlock', 'Road Block Graphics', 0.5, 0.5);
self.setPosition = function (x, y) {
self.x = x;
self.y = y;
};
});
var Objective = Container.expand(function () {
var self = Container.call(this);
var objectiveGraphics = self.createAsset('objective', 'Objective Graphics', 0.5, 0.5);
self.setPosition = function (x, y) {
self.x = x;
self.y = y;
};
});
var SteeringWheel = Container.expand(function () {
var self = Container.call(this);
var wheelGraphics = self.createAsset('steeringWheel', 'Steering Wheel Graphics', 0.5, 0.5);
wheelGraphics.scale.set(wheelGraphics.scale.x * 0.995, wheelGraphics.scale.y * 0.995);
self.rotation = 0;
self.interactive = true;
self.on('move', function (obj) {
var event = obj.event;
var pos = event.getLocalPosition(LK.stage);
self.rotation = (pos.x - self.x) / self.width * Math.PI * 0.2;
});
});
var Bus = Container.expand(function () {
var self = Container.call(this);
self.recoil = function () {
self.speed = -10;
LK.setTimeout(function () {
self.stop();
}, 100);
};
var busGraphics = self.createAsset('bus', 'Bus Graphics', .5, .5);
busGraphics.scale.set(1.5);
busGraphics.rotation = -Math.PI / 2;
self.speed = 0;
self.accelerating = false;
self.accelerate = function () {
self.accelerating = true;
};
self.stop = function () {
self.accelerating = false;
};
self.update = function () {
if (self.accelerating) {
self.speed = Math.min(self.speed + 0.2, 10);
} else {
self.speed = Math.max(self.speed - 0.1, 0);
}
};
self.move = function (wheelRotation) {
var forwardX = Math.cos(self.rotation) * self.speed;
var forwardY = Math.sin(self.rotation) * self.speed;
var newX = self.x + forwardX;
var newY = self.y + forwardY;
if (newX < 0 || newX > LK.stage.width || newY < 0 || newY > LK.stage.height) {
LK.showGameOver();
} else {
self.x = newX;
self.y = newY;
}
var maxRotationSpeed = 0.02;
if (self.speed > 0) {
var rotationChange = wheelRotation;
var rotationSpeed = maxRotationSpeed * Math.abs(wheelRotation) / (Math.PI * 0.2);
self.rotation += Math.max(Math.min(rotationChange, rotationSpeed), -rotationSpeed);
}
};
self.checkCollision = function (obstacles) {
for (var i = 0; i < obstacles.length; i++) {
var busBounds = this.getBounds();
var obstacleBounds = obstacles[i].getBounds();
obstacleBounds.x -= 10;
obstacleBounds.y -= 10;
obstacleBounds.width += 20;
obstacleBounds.height += 20;
if (busBounds.intersects(obstacleBounds)) {
LK.showGameOver();
break;
}
}
};
});
var Game = Container.expand(function () {
stage.on('up', function (obj) {
bus.stop();
});
var self = Container.call(this);
var obstacles = [];
for (var i = 0; i < 5; i++) {
var obstacle = new Obstacle();
var posX = Math.random() * LK.stage.width;
var posY = Math.random() * LK.stage.height;
obstacle.setPosition(posX, posY);
obstacles.push(obstacle);
}
var roadBlocks = [];
var roadLength = 10;
var roadBlockWidth = 200;
var roadBlockHeight = 100;
var background = self.createAsset('background', 'Game Background', 0, 0);
self.addChild(background);
var score = 0;
var background = self.createAsset('background', 'Game Background', 0, 0);
self.addChild(background);
var bus = self.addChild(new Bus());
var objective = self.addChild(new Objective());
objective.setPosition(2048 / 2, 2732 / 4);
var steeringWheel = self.addChild(new SteeringWheel());
steeringWheel.x = 2048 / 2;
steeringWheel.y = 2732 - 100 - steeringWheel.height / 2;
var swipeText = new Text2('Hold, then swipe left and right', {
size: 50,
fill: "#ffffff",
align: 'center'
});
swipeText.anchor.set(0.5, 0.5);
swipeText.x = LK.stage.width / 3;
swipeText.y = 50;
LK.gui.addChild(swipeText);
var passengers = [];
var traffic = [];
bus.x = 2048 / 2;
bus.y = 2732 / 2;
var scoreTxt = new Text2('0', {
size: 75,
fill: "#ffff00"
});
scoreTxt.anchor.set(.5, 0);
scoreTxt.y = 50;
scoreTxt.x = -600;
LK.gui.topCenter.addChild(scoreTxt);
var timerText = new Text2('10', {
size: 75,
fill: "#ff0000"
});
timerText.anchor.set(.5, 0);
timerText.y = scoreTxt.y + 100;
timerText.x = -600;
LK.gui.topCenter.addChild(timerText);
scoreTxt.anchor.set(.5, 0);
LK.gui.topCenter.addChild(scoreTxt);
stage.on('down', function (obj) {
bus.accelerate();
});
LK.on('tick', function () {
obstacles.forEach(function (obstacle) {
self.addChild(obstacle);
});
bus.update();
bus.move(steeringWheel.rotation);
bus.checkCollision(obstacles);
for (var i = 0; i < passengers.length; i++) {
passengers[i].pickUp();
}
for (var i = 0; i < traffic.length; i++) {
traffic[i].move();
}
if (bus.intersects(objective)) {
score += 1;
scoreTxt.setText(score.toString());
var newObjectiveX, newObjectiveY;
do {
newObjectiveX = 100 + Math.random() * (LK.stage.width - 200);
newObjectiveY = 100 + Math.random() * (LK.stage.height - 200);
} while (Math.abs(newObjectiveY - bus.y) < LK.stage.height / 2);
objective.setPosition(newObjectiveX, newObjectiveY);
timerText.setText('10');
var countdown = 10;
var countdownInterval = LK.setInterval(function () {
countdown--;
timerText.setText(countdown.toString());
if (countdown <= 0) {
LK.clearInterval(countdownInterval);
LK.showGameOver();
}
}, 1000);
LK.clearInterval(self.countdownInterval);
self.countdownInterval = countdownInterval;
}
});
});
Simple Car Steering Wheel. In-Game asset. 2d. Blank background. Svg
bomb Single Game Texture. In-Game asset. 2d. No shadows. flat. detailed
yellow bus stop symbol svg Single Game Texture. In-Game asset. 2d. No shadows. flat. detailed
yellow bus symbol svg. roof. top down. Single Game Texture. In-Game asset. 2d. No shadows. flat. detailed
dark transparent dust particle Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.