User prompt
при game over выводить количество набранных секунд белым цветом
User prompt
при game over выводить количество набранных секунд
User prompt
уменьшить размер таймера в 2 раза
User prompt
выводить таймер на экране game over
User prompt
таймер должен содержать сотую разрядность
Code edit (3 edits merged)
Please save this source code
User prompt
добавить таймер в верхнем левом углу
User prompt
выводить количество набранных очков при окончании игры
User prompt
добавить количество очков при game over, очки рассчитываются количеством секунд в разряде до сотых
User prompt
добавить background
Code edit (6 edits merged)
Please save this source code
User prompt
увеличить скорость игрока в 1.5 раза
User prompt
переместить препятсвие4 в правый нижний угол
User prompt
добавить объект препятствие4 с аналогичными параметрами как у препятствия3
User prompt
препятсвие 3 появляется в левом нижнем углу
User prompt
добавить объект препятствие3 с аналогичными параметрами как у препятствия
User prompt
пересечение объектов игрок и препятствий в радиусе изображения, а не объекта
Code edit (1 edits merged)
Please save this source code
User prompt
начальное положение препятствия 2 в левом верхнем углу
User prompt
добавить объект препятствие2 с аналогичными параметрами как у препятствия
Code edit (5 edits merged)
Please save this source code
User prompt
начальное направление перемещения прпятсвия любой угол из 360 градусов
User prompt
скорость перемещения препятвсвия 20
User prompt
скорость перемещения препятсвия 10
User prompt
игрок не может улетать за экран
/**** * Classes ****/ // Obstacle class var Obstacle = Container.expand(function () { var self = Container.call(this); var obstacleGraphics = self.attachAsset('obstacle', { anchorX: 0.5, anchorY: 0.5 }); // Set speed to 20 in a random direction within 360 degrees var angle = Math.random() * Math.PI * 2; // Random angle in radians self.speedX = Math.cos(angle) * 25; self.speedY = Math.sin(angle) * 25; self.move = function () { self.x += self.speedX; self.y += self.speedY; // Bounce off walls if (self.x < 145 || self.x > 1903) { self.speedX *= -1; } if (self.y < 145 || self.y > 2587) { self.speedY *= -1; } }; }); // Obstacle2 class var Obstacle2 = Container.expand(function () { var self = Container.call(this); var obstacleGraphics = self.attachAsset('obstacle2', { anchorX: 0.5, anchorY: 0.5 }); // Set speed to 20 in a random direction within 360 degrees var angle = Math.random() * Math.PI * 2; // Random angle in radians self.speedX = Math.cos(angle) * 25; self.speedY = Math.sin(angle) * 25; self.move = function () { self.x += self.speedX; self.y += self.speedY; // Bounce off walls if (self.x < 145 || self.x > 1903) { self.speedX *= -1; } if (self.y < 145 || self.y > 2587) { self.speedY *= -1; } }; }); // Assets will be automatically created based on usage in the code. // Player class var Player = Container.expand(function () { var self = Container.call(this); var playerGraphics = self.attachAsset('player', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 6 * 2; self.move = function (direction) { if (direction === 'left' && self.x > 145) { self.x -= self.speed; } else if (direction === 'right' && self.x < 1903) { self.x += self.speed; } }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0xFFFFFF // Init game with white background }); /**** * Game Code ****/ LK.on('tick', function () { // Calculate the distance between the player and the target position var dx = targetPosition.x - player.x; var dy = targetPosition.y - player.y; var distance = Math.sqrt(dx * dx + dy * dy); // If the player is not already at the target position if (distance > player.speed) { // Calculate the direction vector var directionX = dx / distance; var directionY = dy / distance; // Move the player towards the target position var newX = player.x + directionX * player.speed; var newY = player.y + directionY * player.speed; // Check if the new position is within the screen boundaries if (newX >= 145 && newX <= 1903) { player.x = newX; } if (newY >= 145 && newY <= 2587) { player.y = newY; } } // Move the obstacles obstacle.move(); obstacle2.move(); // Check if player intersects with any obstacle if (player.intersects(obstacle) || player.intersects(obstacle2)) { // Flash screen red for 1 second (1000ms) to show we are dead. LK.effects.flashScreen(0xff0000, 1000); // Show game over. The game will be automatically paused while game over is showing. LK.showGameOver(); // Calling this will destroy the 'Game' and reset entire game state. } }); var player = game.addChild(new Player()); player.x = 2048 / 2; // Center horizontally player.y = 2732 / 2; // Center vertically var targetPosition = { x: player.x, y: player.y }; // Store the target position for the player game.on('down', function (obj) { targetPosition = obj.event.getLocalPosition(game); // Set the target position to the clicked position }); var obstacle = game.addChild(new Obstacle()); obstacle.x = 2048 - obstacle.width / 2 - 200; // Position at the right edge of the screen, 200 pixels away from the edge obstacle.y = obstacle.height / 2 + 200; // Position at the top edge of the screen, 200 pixels away from the edge; var obstacle2 = game.addChild(new Obstacle2()); obstacle2.x = 2048 - obstacle2.width / 2 - 200; // Position at the right edge of the screen, 200 pixels away from the edge obstacle2.y = obstacle2.height / 2 + 200; // Position at the top edge of the screen, 200 pixels away from the edge;
===================================================================
--- original.js
+++ change.js
@@ -23,8 +23,31 @@
self.speedY *= -1;
}
};
});
+// Obstacle2 class
+var Obstacle2 = Container.expand(function () {
+ var self = Container.call(this);
+ var obstacleGraphics = self.attachAsset('obstacle2', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ // Set speed to 20 in a random direction within 360 degrees
+ var angle = Math.random() * Math.PI * 2; // Random angle in radians
+ self.speedX = Math.cos(angle) * 25;
+ self.speedY = Math.sin(angle) * 25;
+ self.move = function () {
+ self.x += self.speedX;
+ self.y += self.speedY;
+ // Bounce off walls
+ if (self.x < 145 || self.x > 1903) {
+ self.speedX *= -1;
+ }
+ if (self.y < 145 || self.y > 2587) {
+ self.speedY *= -1;
+ }
+ };
+});
// Assets will be automatically created based on usage in the code.
// Player class
var Player = Container.expand(function () {
var self = Container.call(this);
@@ -72,12 +95,13 @@
if (newY >= 145 && newY <= 2587) {
player.y = newY;
}
}
- // Move the obstacle
+ // Move the obstacles
obstacle.move();
- // Check if player intersects with obstacle
- if (player.intersects(obstacle)) {
+ obstacle2.move();
+ // Check if player intersects with any obstacle
+ if (player.intersects(obstacle) || player.intersects(obstacle2)) {
// Flash screen red for 1 second (1000ms) to show we are dead.
LK.effects.flashScreen(0xff0000, 1000);
// Show game over. The game will be automatically paused while game over is showing.
LK.showGameOver(); // Calling this will destroy the 'Game' and reset entire game state.
@@ -94,5 +118,8 @@
targetPosition = obj.event.getLocalPosition(game); // Set the target position to the clicked position
});
var obstacle = game.addChild(new Obstacle());
obstacle.x = 2048 - obstacle.width / 2 - 200; // Position at the right edge of the screen, 200 pixels away from the edge
-obstacle.y = obstacle.height / 2 + 200; // Position at the top edge of the screen, 200 pixels away from the edge
\ No newline at end of file
+obstacle.y = obstacle.height / 2 + 200; // Position at the top edge of the screen, 200 pixels away from the edge;
+var obstacle2 = game.addChild(new Obstacle2());
+obstacle2.x = 2048 - obstacle2.width / 2 - 200; // Position at the right edge of the screen, 200 pixels away from the edge
+obstacle2.y = obstacle2.height / 2 + 200; // Position at the top edge of the screen, 200 pixels away from the edge;
\ No newline at end of file
квадрат со злым лицом.. 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.