User prompt
add player2
User prompt
when the character moves to the left - show player and hide player2. when the character moves to the right - show player2 and hide player.
User prompt
add player2 who is at the same place as the player and moves synchronously with him.
User prompt
when the character moves to the left - use player and hide player2, when the character moves to the right - change to player2 and hide the player
User prompt
Fix Bug: 'ReferenceError: player2 is not defined' in this line: 'if (apples[i].isCaught(player, player2)) {' Line Number: 85
User prompt
and is at one point
User prompt
player and player 2 must move in sync
User prompt
when the character moves to the left - use player and hide player2, when the character moves to the right - change to player2 and hide the player
User prompt
when the character moves to the left - use player and hide player2, when the character moves to the right - change to player2 and hide the player
User prompt
Fix Bug: 'ReferenceError: player2 is not defined' in this line: 'if (player2.x < player2.targetX) {' Line Number: 105
User prompt
Fix Bug: 'ReferenceError: player2 is not defined' in this line: 'player2.visible = false;' Line Number: 13
User prompt
redo it.
User prompt
when the character moves to the left - use player and hide player2, when the character moves to the right - change to player2 and hide the player
User prompt
when the character moves to the left - use player, when the character moves to the right - change to player2
User prompt
when the character moves left - use player, when the character moves left - change to player2
User prompt
when the character moves to the left, it's player, when the character moves to the left, it's player2
User prompt
add player2
User prompt
Fix Bug: 'TypeError: LK.gui.topRight.contains is not a function' in this line: 'if (!LK.gui.topRight.contains(assetA)) {' Line Number: 33
User prompt
Fix Bug: 'TypeError: LK.gui.topRight.contains is not a function' in this line: 'if (!LK.gui.topRight.contains(assetA)) {' Line Number: 33
User prompt
display the "a" assembly in the upper right corner the first time a red apple hits a player
User prompt
display the "a" assembly in the upper right corner the first time a red apple hits a player
User prompt
put in the upper right corner the asset "a" when the red apple hits the player for the first time, next to "a" put the asset "b" when the red apple hits the player for the second time.
User prompt
put in the upper right corner the asset "a" when the red apple hits the player for the first time, next to "a" put the asset "b" when the red apple hits the player for the second time.
User prompt
print in the upper right corner "a" for the first time a red apple hits the player, next to "a" print "b" for the second time a red apple hits the player.
User prompt
add to assets "a", "b", "c", "d", "e", "f", "s", "l", "j", "k". "e," "f," "s," "l," "j," "k."
/**** * Classes ****/ // Player class var Player = Container.expand(function () { var self = Container.call(this); var playerGraphics = self.createAsset('player', 'Player character', 0.5, 1); self.speed = 5; self.targetX = self.x; self.moveLeft = function () { if (self.x > self.targetX && self.x > playerGraphics.width / 2) { self.x -= self.speed; } }; self.moveRight = function () { if (self.x < self.targetX && self.x < 2048 - playerGraphics.width / 2) { self.x += self.speed; } }; }); // Apple class var Apple = Container.expand(function () { var self = Container.call(this); var appleGraphics = self.createAsset('apple', 'Falling apple', 0.5, 0.5); self.speed = 3; self.move = function () { self.y += self.speed; }; self.isCaught = function (player) { var playerHeadY = player.y - player.height / 2; var appleBottomY = self.y + self.height / 2; if (self.intersects(player) && appleBottomY < playerHeadY) { assetA.x = 2048 - assetA.width / 2; assetA.y = assetA.height / 2; LK.gui.topRight.addChild(assetA); return true; } return false; }; }); // GreenApple class var GreenApple = Container.expand(function () { var self = Container.call(this); var appleGraphics = self.createAsset('greenApple', 'Falling green apple', 0.5, 0.5); self.speed = 5; self.move = function () { self.y += self.speed; }; self.isCaught = function (player) { var playerHeadY = player.y - player.height / 2; var appleBottomY = self.y + self.height / 2; return self.intersects(player) && appleBottomY < playerHeadY; }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 // Init game with black background }); /**** * Game Code ****/ // Initialize second background var background2 = game.addChild(LK.getAsset('background2', 'Second background', 0, 0)); // Initialize new assets var assetA = game.addChild(LK.getAsset('a', 'Asset A', 0.5, 0.5)); var assetB = game.addChild(LK.getAsset('b', 'Asset B', 0.5, 0.5)); var assetC = game.addChild(LK.getAsset('c', 'Asset C', 0.5, 0.5)); var assetD = game.addChild(LK.getAsset('d', 'Asset D', 0.5, 0.5)); var assetE = game.addChild(LK.getAsset('e', 'Asset E', 0.5, 0.5)); var assetF = game.addChild(LK.getAsset('f', 'Asset F', 0.5, 0.5)); var assetS = game.addChild(LK.getAsset('s', 'Asset S', 0.5, 0.5)); var assetL = game.addChild(LK.getAsset('l', 'Asset L', 0.5, 0.5)); var assetJ = game.addChild(LK.getAsset('j', 'Asset J', 0.5, 0.5)); var assetK = game.addChild(LK.getAsset('k', 'Asset K', 0.5, 0.5)); background2.width = 2048; background2.height = 2732; background2.x = 0; background2.y = 0; background2.anchor.set(0, 0); // Initialize backgrounds var background = game.addChild(LK.getAsset('background', 'Game background', 0, 0)); background.width = 2048; background.height = 2732; background.x = 0; background.y = 0; background.anchor.set(0, 0); // Initialize player var player = game.addChild(new Player()); player.x = 2048 / 2; player.y = 2732 - 50; // Positioned at the bottom of the screen // Initialize apples array var apples = []; // Handle touch movement function handleTouchMove(obj) { var touchPos = obj.event.getLocalPosition(game); player.targetX = touchPos.x; } // Attach touch move event to the game game.on('move', handleTouchMove); // Game tick event LK.on('tick', function () { // Move player towards targetX if (player.x < player.targetX) { player.moveRight(); } else if (player.x > player.targetX) { player.moveLeft(); } // Move apples for (var i = apples.length - 1; i >= 0; i--) { apples[i].move(); // Check if apple is caught by the player if (apples[i].isCaught(player)) { // Increase score LK.setScore(LK.getScore() + 1); // Remove caught apple apples[i].destroy(); apples.splice(i, 1); } else if (apples[i].y > 2732) { // Remove apple if it falls off the screen apples[i].destroy(); apples.splice(i, 1); } } // Spawn apples less frequently if (LK.ticks % 120 == 0) { // Every two seconds var newApple = Math.random() < 0.5 ? new Apple() : new GreenApple(); newApple.x = Math.random() * 2048; newApple.y = -50; // Start off-screen apples.push(newApple); game.addChild(newApple); } });
===================================================================
--- original.js
+++ change.js
@@ -29,13 +29,11 @@
self.isCaught = function (player) {
var playerHeadY = player.y - player.height / 2;
var appleBottomY = self.y + self.height / 2;
if (self.intersects(player) && appleBottomY < playerHeadY) {
- if (!LK.gui.topRight.contains(assetA)) {
- assetA.x = 2048 - assetA.width / 2;
- assetA.y = assetA.height / 2;
- LK.gui.topRight.addChild(assetA);
- }
+ assetA.x = 2048 - assetA.width / 2;
+ assetA.y = assetA.height / 2;
+ LK.gui.topRight.addChild(assetA);
return true;
}
return false;
};
grass
the fields of Britain, cartoon style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
green apple. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
red apple. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
eureka moment, cartoon style, light, no people. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
heart. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
stars flying on an ellipse, cartoon style, side view , no people. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
white "=" on a green apple.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a white "F" on a red apple.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
the "G" sign on the red apple. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
white " (M" on a red apple. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a white sign with a small "m" on a red apple.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
white " /" on a green apple. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a white "R" on a red apple.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
green
a white " 2" on a red apple.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.