User prompt
противник преследует игрока
User prompt
противник может поворачивать
User prompt
противник движется в направлении игрока
Code edit (1 edits merged)
Please save this source code
User prompt
добавить плавное перемещение на 200 пикселей при пересечении машин
User prompt
при пересечении машины плавно отталкиваются друг от друга
User prompt
при пересечении машин, обе машины перемещаются на 200 пикселей назад относительно той точки, где она пересеклись и продолжают движение по направлению
User prompt
при пересечении машин, обе машины перемещаются на 200 пикселей назад и продолжают движение по направлению
User prompt
при пересечении машин, обе машины перемещаются на 200 пикселей назад и продолжают движение по направлению
User prompt
при пересечении машин, обе машины перемещаются на 200 назад и продолжают движение по направлениию
User prompt
убрать game over при столкновении с противником
User prompt
при столкновении с противником, такая же механика как и при столкновении со стенами
User prompt
при столкновении с противником, обе машины отскакивают на 200 на 0.2 секунды и продолжают движение по направлению
User prompt
добавить противника в верхнюю часть круга
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
если игрок пересек радиус 1900 от центра, то game over
User prompt
добавить задний фон
Code edit (5 edits merged)
Please save this source code
User prompt
при повороте машина скользит только 0,5 секунду, затем перестает скользить и продолжает движение по направлению
User prompt
определить движение машины только по одному положению машины
User prompt
при повороте машина скользит только 1 секунду, затем перестает скользить и продолжает движение по направлению
User prompt
при повороте машина скользит только 1 секунду, затем перестает скользить
User prompt
направление движение машины всегда с верхей части картинки машины
User prompt
скорость скольжения уменьшается на поворотах
/****
* Classes
****/
// Assets will be automatically created based on usage in the code.
// Car class
var Car = Container.expand(function () {
var self = Container.call(this);
// Attach a car asset
var carGraphics = self.attachAsset('car', {
anchorX: 0.5,
anchorY: 0.5
});
self.previousTouchPosition = null;
self.speedX = 0;
self.speedY = 0;
// Move car based on its speed
self.move = function () {
self.x += self.speedX;
self.y += self.speedY;
};
// Prevent the car from moving in the opposite direction when it hits the wall
self.checkBounds = function () {
if (self.x < 0) {
self.x += 200;
} else if (self.x > 2048) {
self.x -= 200;
}
if (self.y < 0) {
self.y += 200;
} else if (self.y > 2732) {
self.y -= 200;
}
};
self.setDirection = function (direction) {
if (direction === 'left') {
self.rotation -= 0.05;
self.speedX += Math.sin(self.rotation) * 0.05;
self.speedY += -Math.cos(self.rotation) * 0.05;
} else if (direction === 'right') {
self.rotation += 0.05;
self.speedX += Math.sin(self.rotation) * 0.1;
self.speedY += -Math.cos(self.rotation) * 0.1;
}
// Limit the speed to prevent the car from sliding too much
self.speedX = Math.min(Math.max(self.speedX, -7), 7);
self.speedY = Math.min(Math.max(self.speedY, -7), 7);
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0xFFFFFF // Init game with white background
});
/****
* Game Code
****/
// Global variables
var cars = [];
// Create a single car
var car = new Car();
car.x = 2048 / 2; // Center of the screen
car.y = 2280; // Bottom of the screen
car.speedX = 0;
car.speedY = -7;
cars.push(car);
game.addChildAt(car, game.children.length);
// Create a circle in the center of the screen
var centerCircle = LK.getAsset('Circle', {
anchorX: 0.5,
// Center anchor x-coordinate
anchorY: 0.5,
// Center anchor y-coordinate
x: 2048 / 2,
// Center of the screen
y: 2732 / 2 // Center of the screen
});
game.addChildAt(centerCircle, 0);
// Handle game logic on each tick
LK.on('tick', function () {
cars.forEach(function (car) {
car.move();
car.checkBounds();
// Check for collisions with other cars
cars.forEach(function (otherCar) {
if (car !== otherCar && car.intersects(otherCar)) {
// Simple collision response by swapping speeds
var tempSpeedX = car.speedX;
var tempSpeedY = car.speedY;
car.speedX = otherCar.speedX;
car.speedY = otherCar.speedY;
otherCar.speedX = tempSpeedX;
otherCar.speedY = tempSpeedY;
}
});
});
});
// Add touch event listener to the game
var turnInterval;
var lastTouchPosition;
var isTouching = false; // Add a flag to check if the screen is being touched
var isOutside = false; // Add a flag to check if the mouse is outside the game
game.on('down', function (obj) {
// Get the position of the touch
var touchPosition = obj.event.getLocalPosition(game);
// Store the initial touch position
car.initialTouchPosition = touchPosition;
// Store the last touch position
lastTouchPosition = touchPosition;
isTouching = true; // Set the flag to true when the screen is being touched
isOutside = false; // Set the flag to false when the mouse enters the game
});
game.on('move', function (obj) {
// Get the position of the touch
var touchPosition = obj.event.getLocalPosition(game);
// Update the last touch position
lastTouchPosition = touchPosition;
// If there is a touch event and the last touch position is to the left of the initial touch position, turn the car to the left
if (!isOutside && isTouching && lastTouchPosition && car.initialTouchPosition) {
if (lastTouchPosition.x < car.initialTouchPosition.x) {
car.setDirection('left');
} else if (lastTouchPosition.x > car.initialTouchPosition.x) {
car.setDirection('right');
}
// Update the initial touch position
car.initialTouchPosition = lastTouchPosition;
} else if (isTouching && !isOutside) {
// If there is no touch event, the car moves straight
car.setDirection('straight');
}
});
game.on('up', function (obj) {
// Reset the last touch position when the touch is released
lastTouchPosition = null;
isTouching = false; // Set the flag to false when the touch is released
isOutside = true; // Set the flag to true when the mouse leaves the game
});
Лава мультяшная вид сверху плоская. Single Game Texture. In-Game asset. Blank background. High contrast. No shadows.
Плоский лед, круглый, мультяшный. Вид сверху. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
мультяшный палец нажатие по экрану. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
шины на асфальте после торможения для игры. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.