User prompt
Change the background color to beige green
User prompt
Change the SCREEN color to DRAPP GREEN
User prompt
MOVE UP THE SCREEN BY 200 UNITS
User prompt
MOVE UP THE SCREEN BY 300 UNITS
User prompt
MOVE THE PHONE ASSET DOWN BY 900 UNITS
User prompt
MOVE THE PHONE ASSET DOWN BY 1000 UNITS
User prompt
MOVE THE PHONE ASSET DOWN BY 900 UNITS
User prompt
MOVE THE PHONE ASSET DOWN BY 800 UNITS
User prompt
MOVE THE PHONE ASSET DOWN BY 777 UNITS
User prompt
MOVE THE PHONE ASSET DOWN BY 1000 UNITS
User prompt
ADD PHONE ASSET TO THE MAP
User prompt
I DIDN'T SAY TO REPLACE THE SCREEN WITH THE PHONE DEVICE, BUT PUT IT IN THE MIDDLE!
User prompt
add phon asset to the center of the map
User prompt
Add phone asset to the center of the map
User prompt
Add phone asset to the center of the map
User prompt
Add screen asset to the center of the map
User prompt
remove mobile asset from the game
User prompt
Add screen asset to the center of the map
User prompt
set background colour to black
User prompt
resize the screen sides to the mobile asset sides
User prompt
set colour green to black
User prompt
Resize the screen width to the mobile asset width
User prompt
Ensure that the mobilie asset sides reach the background left and right sides
User prompt
change this colour to black
User prompt
Change the background colour to beige green
/**** * Classes ****/ // Food class for items the snake can eat var Food = Container.expand(function () { var self = Container.call(this); var foodGraphics = self.attachAsset('food', { anchorX: 0.5, anchorY: 0.5 }); // Randomly position the food on the screen self.randomizePosition = function () { self.x = Math.floor(Math.random() * 2048); self.y = Math.floor(Math.random() * 2732); }; return self; }); //<Assets used in the game will automatically appear here> //<Write imports for supported plugins here> // Snake class for both player and computer-controlled snakes var Snake = Container.expand(function () { var self = Container.call(this); self.segments = []; self.direction = { x: 1, y: 0 }; // Initial direction to the right self.speed = 5; // Speed of the snake // Initialize snake with a given length self.init = function (length, startX, startY) { for (var i = 0; i < length; i++) { var segment = self.attachAsset('snakeSegment', { anchorX: 0.5, anchorY: 0.5, x: startX - i * 20, y: startY }); self.segments.push(segment); } }; // Update snake position self.update = function () { // Move each segment to the position of the previous one for (var i = self.segments.length - 1; i > 0; i--) { self.segments[i].x = self.segments[i - 1].x; self.segments[i].y = self.segments[i - 1].y; } // Move the head in the current direction self.segments[0].x += self.direction.x * self.speed; self.segments[0].y += self.direction.y * self.speed; }; // Grow the snake by adding a new segment self.grow = function () { var lastSegment = self.segments[self.segments.length - 1]; var newSegment = self.attachAsset('snakeSegment', { anchorX: 0.5, anchorY: 0.5, x: lastSegment.x, y: lastSegment.y }); self.segments.push(newSegment); }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 //Change background color to black }); /**** * Game Code ****/ // Initialize screen var screen = game.attachAsset('screen', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 - 300 }); game.addChild(screen); // Initialize phone var phone = game.attachAsset('phone', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 + 900 }); game.addChild(phone); // Initialize player and computer snakes var playerSnake = new Snake(); playerSnake.init(5, 500, 500); game.addChild(playerSnake); var computerSnake = new Snake(); computerSnake.init(5, 1500, 1500); game.addChild(computerSnake); // Initialize food var food = new Food(); food.randomizePosition(); game.addChild(food); // Handle game updates game.update = function () { playerSnake.update(); computerSnake.update(); // Check for collision with food if (playerSnake.segments[0].intersects(food)) { playerSnake.grow(); playerSnake.grow(); // Grow the player's snake by an additional segment food.randomizePosition(); } if (computerSnake.segments[0].intersects(food)) { computerSnake.grow(); computerSnake.grow(); // Grow the computer's snake by an additional segment food.randomizePosition(); } // Check for collision between player and computer snakes if (playerSnake.segments[0].intersects(computerSnake.segments[0])) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } }; // Handle player input for snake direction game.down = function (x, y, obj) { var head = playerSnake.segments[0]; if (Math.abs(x - head.x) > Math.abs(y - head.y)) { if (x > head.x) { playerSnake.direction = { x: 1, y: 0 }; } else if (x < head.x) { playerSnake.direction = { x: -1, y: 0 }; } } else { if (y > head.y) { playerSnake.direction = { x: 0, y: 1 }; } else if (y < head.y) { playerSnake.direction = { x: 0, y: -1 }; } } console.log("Game was clicked at", x, y); }; // Simple AI for computer snake function updateComputerSnakeDirection() { var head = computerSnake.segments[0]; var targetX = food.x; var targetY = food.y; if (head.x < targetX) { computerSnake.direction = { x: 0.5, y: 0 }; } else if (head.x > targetX) { computerSnake.direction = { x: -0.5, y: 0 }; } else if (head.y < targetY) { computerSnake.direction = { x: 0, y: 0.5 }; } else if (head.y > targetY) { computerSnake.direction = { x: 0, y: -0.5 }; } } // Update computer snake direction periodically LK.setInterval(updateComputerSnakeDirection, 500); ;
===================================================================
--- original.js
+++ change.js
@@ -77,9 +77,9 @@
var screen = game.attachAsset('screen', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
- y: 2732 / 2
+ y: 2732 / 2 - 300
});
game.addChild(screen);
// Initialize phone
var phone = game.attachAsset('phone', {