Code edit (8 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
oblakoLeft создается рандомной величиной
User prompt
скорость oblakoLeft такая же как у oblako
User prompt
добавить вначале игры такое же облако как и первое, только на 400 левее
Code edit (2 edits merged)
Please save this source code
User prompt
у первого облака случайный размер
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'scaleFactor is not defined' in or related to this line: 'oblako.scale.set(scaleFactor);' Line Number: 397
User prompt
Please fix the bug: 'Oblako is not defined' in or related to this line: 'Oblako.scale.set(scaleFactor);' Line Number: 397
Code edit (4 edits merged)
Please save this source code
User prompt
Добавить звук GO, проигрывается через 2 секунды после начала игры
User prompt
Добавить звук GO, когда отображается картинка vzriv
Code edit (1 edits merged)
Please save this source code
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1", { highScore: 0 }); /**** * Classes ****/ // Import leaderboard plugin var ButtonBot = Container.expand(function () { var self = Container.call(this); var buttonBotGraphics = self.attachAsset('BUTTON_BOT', { anchorX: 0.5, anchorY: 0.5 }); // Add down event to set landing duration to 100 during jump or double jump self.down = function (x, y, obj) { if (self.isPressed || buttonTop.isPressed) { return; } // Debounce: Ignore if already pressed or if buttonTop is pressed self.vnizSound = LK.getSound('vniz'); self.vnizSound.play(); // Play 'vniz' sound when button_bot is pressed self.vnizSound.on('end', function () { if (self.isPressed) { self.vnizSound.play({ loop: true }); // Replay 'vniz' sound if button is still pressed } }); self.isPressed = true; // Set pressed state LK.setTimeout(function () { self.isPressed = false; // Reset pressed state after a short delay }, 20); // 20ms debounce delay self.scale.set(0.9); // Add press effect by scaling down if (!player.inAir && !player.doubleJump) { player.rotation -= Math.PI * (85 / 180); // Rotate 85 degrees counter-clockwise tween(player, { y: player.y + 30 // Move player down by 30 pixels }, { duration: 100, // Smooth transition over 500ms onFinish: function onFinish() { player.inAir = false; player.doubleJump = false; } }); } else if (player.inAir || player.doubleJump) { tween(player, { y: 2732 / 2 - 220 }, { duration: 100, onFinish: function onFinish() { player.inAir = false; player.doubleJump = false; player.y = 2732 / 2 - 220; } }); } if (player.inAir || player.doubleJump) { if (!player.hasRotated) { player.rotation -= Math.PI * (85 / 180); // Rotate 85 degrees counter-clockwise player.hasRotated = true; // Ensure rotation only occurs once } tween(player, { y: 2732 / 2 - 220 }, { duration: 100, onFinish: function onFinish() { player.inAir = false; player.doubleJump = false; player.y = 2732 / 2 - 220; player.hasRotated = false; // Reset rotation flag } }); } else { player.hasRotated = false; // Reset rotation flag if not in air or double jump } }; // Add up event to reset rotation self.up = function (x, y, obj) { self.isPressed = false; // Reset pressed state if (self.vnizSound) { self.vnizSound.stop(); // Stop 'vniz' sound when button_bot is released } self.scale.set(1); // Reset scale to original size if (!player.inAir && !player.doubleJump) { player.rotation += Math.PI * (85 / 180); // Rotate back 85 degrees clockwise tween(player, { y: player.y - 30 // Move player up by 30 pixels }, { duration: 100, // Smooth transition over 100ms onFinish: function onFinish() { player.inAir = false; player.doubleJump = false; } }); } else if (player.inAir || player.doubleJump) { player.rotation += Math.PI * (85 / 180); // Rotate back 85 degrees clockwise } }; }); // Create a button top class var ButtonTop = Container.expand(function () { var self = Container.call(this); var buttonTopGraphics = self.attachAsset('BUTTON_TOP', { anchorX: 0.5, anchorY: 0.5 }); // Add down event to trigger jump self.down = function (x, y, obj) { if (self.isPressed || buttonBot.isPressed) { return; } // Debounce: Ignore if already pressed or if buttonBot is pressed self.isPressed = true; // Set pressed state LK.setTimeout(function () { self.isPressed = false; // Reset pressed state after a short delay }, 200); // 200ms debounce delay self.scale.set(0.9); // Add press effect by scaling down if (!player.doubleJump || player.inAir && !player.doubleJump) { LK.getSound('jump').play(); // Play jump sound if (player.inAir) { player.doubleJump = true; tween(player, { y: player.y - 400, rotation: player.rotation - Math.PI * 2 }, { duration: 230, easing: tween.easeInOut, onFinish: function onFinish() { player.inAir = true; // Allow another jump tween(player, { y: 2732 / 2 - 250 }, { duration: 500, onFinish: function onFinish() { player.inAir = false; player.doubleJump = false; player.y = 2732 / 2 - 250; } }); } }); return; } player.inAir = true; player.doubleJump = false; player.lastY = player.y; // Update lastY immediately after jump initiation player.lastX = player.x; // Update lastX immediately after jump initiation player.lastY = player.y; // Update lastY immediately after jump initiation player.lastX = player.x; // Update lastX immediately after jump initiation tween(player, { y: player.y - 500 }, { duration: 100, // Reduced duration to allow quicker second jump onFinish: function onFinish() { player.inAir = true; // Allow another jump tween(player, { y: 2732 / 2 - 250 }, { duration: 600, onFinish: function onFinish() { player.inAir = false; } }); } }); } }; // Add up event to reset scale self.up = function (x, y, obj) { self.isPressed = false; // Reset pressed state self.scale.set(1); // Reset scale to original size }; }); // Create a player class var Player = Container.expand(function () { var self = Container.call(this); var playerGraphics = self.attachAsset('character', { anchorX: 0.5, anchorY: 0.5 }); // Initialize the inAir flag self.inAir = false; self.doubleJump = false; self.hasRotated = false; // Initialize rotation flag // Initialize lastY and lastX for tracking changes self.lastY = self.y; self.lastX = self.x; }); /**** * Initialize Game ****/ // Add player to the game var game = new LK.Game({ backgroundColor: 0x12243b }); /**** * Game Code ****/ function createSnowImage() { var snowImage = game.addChild(LK.getAsset('snow', { anchorX: 0.5, anchorY: 0.5 })); snowImage.x = Math.random() * 2048; // Random horizontal position snowImage.y = Math.random() * 2732; // Random vertical position snowImage.rotation = Math.PI * ((Math.random() * (340 - 300) + 300) / 180); // Random rotation between 300 and 340 degrees } LK.playMusic('osnova'); // Play background music 'osnova' var snowImageTimer = LK.setInterval(createSnowImage, 1000); var obstacles = []; var obstacleInterval = 105; // Initial interval for obstacle creation var intervalDecreaseTimer = LK.setInterval(function () { if (obstacleInterval > 55) { obstacleInterval -= 20; // Decrease interval by 10 every 10 seconds } }, 9000); function createObstacle(assetId, x, y, rotation) { var obstacle = game.addChild(LK.getAsset(assetId, { anchorX: 0.5, anchorY: 0.5 })); obstacle.x = x; obstacle.y = y; obstacle.rotation = rotation; obstacles.push(obstacle); } var obstaclePositions = [{ assetId: 'obstacle1', x: 2140, y: 2732 / 2 + 430, rotation: Math.PI / 9 }, { assetId: 'obstacle2', x: 2140, y: 2732 / 2 + 455, rotation: Math.PI / 9 }, { assetId: 'obstacle3', x: 2140, y: 2732 / 2 + 420, rotation: Math.PI / 9 }, { assetId: 'obstacle4', x: 2140, y: 2732 / 2 + 445, rotation: Math.PI / 9 }, { assetId: 'obstacle5', x: 2140, y: 2732 / 2 + 440, rotation: Math.PI / 9 }, { assetId: 'obstacle6', x: 2140, y: 2732 / 2 + 455, rotation: Math.PI / 9 }, { assetId: 'obstacle7', x: 2140, y: 2732 / 2 + 130, rotation: Math.PI / 9 }, { assetId: 'obstacle8', x: 2165, y: 2732 / 2 + 108, rotation: Math.PI / 9 }, { assetId: 'obstacle9', x: 2165, y: 2732 / 2 + 108, rotation: Math.PI / 9 }]; function createRandomObstacle() { var randomIndex = Math.floor(Math.random() * obstaclePositions.length); var selectedObstacle = obstaclePositions[randomIndex]; createObstacle(selectedObstacle.assetId, selectedObstacle.x, selectedObstacle.y, selectedObstacle.rotation); } LK.setTimeout(createRandomObstacle, 2000); // Delay first obstacle creation by 2,1 seconds var monetka; // Declare monetka variable // Function to create Monetka image at a random height function createMonetka() { monetka = game.addChild(LK.getAsset('Monetka', { anchorX: 0.5, anchorY: 0.5 })); monetka.x = 2057; // Center image horizontally monetka.y = Math.floor(Math.random() * (1650 - 1300 + 1)) + 1300; // Random height between 300 and 1000 monetka.rotation = Math.PI / 9; // Rotate image by 20 degrees clockwise var scaleDirection = 1; // 1 for increasing, -1 for decreasing var scaleSpeed = 0.01; // Speed of scaling monetka.update = function () { // Update the scale monetka.scale.x += scaleSpeed * scaleDirection; monetka.scale.y += scaleSpeed * scaleDirection; // Check if we need to change direction if (monetka.scale.x >= 1.2) { scaleDirection = -1; // Start decreasing } else if (monetka.scale.x <= 1) { scaleDirection = 1; // Start increasing } }; } // Create Monetka every 3 seconds var monetkaTimer = LK.setInterval(createMonetka, 3000); // Add ikonka button to the GUI overlay layer to make it static var ikonkaButton = LK.gui.topRight.addChild(LK.getAsset('ikonka', { anchorX: 0.5, anchorY: 0.5, x: -100, // Move 100 pixels to the left y: 120 // Move 100 pixels down })); // Create and display score text at the top center of the screen var scoreText = new Text2(LK.getScore().toString(), { size: 130, fill: 0xFFFFFF, fontWeight: 'bold', font: 'Arial' // Specify the desired font here }); scoreText.anchor.set(0.5, 0); // Center horizontally, top edge scoreText.y = 30; // Move score 50 pixels down LK.gui.top.addChild(scoreText); ikonkaButton.interactive = true; // Make ikonka interactive ikonkaButton.down = function (x, y, obj) { if (ikonkaButton.isPressed) { return; // Debounce: Ignore if already pressed } ikonkaButton.isPressed = true; // Set pressed state LK.setTimeout(function () { ikonkaButton.isPressed = false; // Reset pressed state after a short delay }, 200); // 200ms debounce delay // Toggle transparency on button press if (ikonkaButton.alpha === 1) { ikonkaButton.alpha = 0.5; // Set transparency to 50% buttonTop.x -= 1700; // Move buttonTop 100 pixels to the left buttonBot.x -= 1700; // Move buttonBot 100 pixels to the left } else { ikonkaButton.alpha = 1; // Reset transparency buttonTop.x += 1700; // Move buttonTop back to original position buttonBot.x += 1700; // Move buttonBot back to original position } ikonkaButton.isPressed = false; // Reset pressed state }; var oblako = game.addChild(LK.getAsset('Oblako', { anchorX: 0.5, anchorY: 0.5 })); oblako.x = 1400; // Position 'Oblako' in the middle of the right side of the screen oblako.y = Math.floor(Math.random() * (600 - 400)) + 400; // Random height between 200 and 700 oblako.rotation = Math.PI / 9; // Rotate 'Oblako' by 20 degrees clockwise oblako.alpha = 0.3; // Set transparency to 50% oblako.scale.set(Math.random() * (1 - 0.33) + 0.33); // Apply random scale between 0.33 and 1 // Add a new cloud 400 pixels to the left of the first cloud var oblakoLeft = game.addChild(LK.getAsset('Oblako', { anchorX: 0.5, anchorY: 0.5 })); oblakoLeft.x = oblako.x - 700; // Position 400 pixels to the left of the first cloud oblakoLeft.y = Math.floor(Math.random() * (500 - 300)) + 300; oblakoLeft.rotation = oblako.rotation; // Same rotation as the first cloud oblakoLeft.alpha = oblako.alpha; // Same transparency as the first cloud oblakoLeft.scale.set(Math.random() * (1 - 0.33) + 0.33); // Apply random scale between 0.33 and 1 var otherImageSpeed = 20; // Initial speed for other images var speedIncreaseTimer = LK.setInterval(function () { otherImageSpeed += 0.2; // Increase speed by 1 every 5 seconds }, 10000); var oblakoInstances = []; // Array to track oblako instances var oblakoTimer = LK.setInterval(function () { var newOblako = game.addChild(LK.getAsset('Oblako', { anchorX: 0.5, anchorY: 0.5 })); var scaleFactor = Math.random() * (1 - 0.33) + 0.33; // Random scale factor between 0.33 and 1 newOblako.scale.set(scaleFactor); // Apply random scale newOblako.x = 2248; // Position 'Oblako' in the middle of the right side of the screen newOblako.y = Math.floor(Math.random() * (901 - 400)) + 400; // Random height between 200 and 700 newOblako.rotation = Math.PI / 9; // Rotate 'Oblako' by 20 degrees clockwise newOblako.alpha = 0.3; // Set transparency to 50% oblakoInstances.push(newOblako); // Add new oblako to the array }, 8000); // Create an array to store 'Dom' images // Define BLEND_MODES to fix the undefined variable error var BLEND_MODES = { NORMAL: 0 }; var domImages = []; // Create the first 'Dom' image after 2 seconds LK.setTimeout(function () { var newDom = game.addChild(LK.getAsset('Dom', { anchorX: 0.5, anchorY: 0.5 })); newDom.x = 2048 / 2 + 2170; // Center image horizontally newDom.y = 2732 / 2 + 450; // Center image vertically newDom.rotation = Math.PI / 9; // Rotate image by 20 degrees clockwise newDom.alpha = 0.2; // Set transparency to 20% newDom.blendMode = BLEND_MODES.NORMAL; // Ensure transparency does not sum up domImages.push(newDom); // Create subsequent 'Dom' images every 3 seconds var domTimer = LK.setInterval(function () { var newDom = game.addChild(LK.getAsset('Dom', { anchorX: 0.5, anchorY: 0.5 })); newDom.x = 2048 / 2 + 2170; // Center image horizontally newDom.y = 2732 / 2 + 450; // Center image vertically newDom.rotation = Math.PI / 9; // Rotate image by 20 degrees clockwise newDom.alpha = 0.2; // Set transparency to 20% newDom.blendMode = BLEND_MODES.NORMAL; // Ensure transparency does not sum up domImages.push(newDom); }, 12500); }, 2220); // Set a random interval between 4 to 8 seconds to create SUNDUK function randomSundukCreation() { var randomTime = Math.floor(Math.random() * (10000 - 4000 + 1)) + 4000; LK.setTimeout(function () { createSunduk(); randomSundukCreation(); // Call again for continuous random creation }, randomTime); } // Start the random SUNDUK creation randomSundukCreation(); // Function to create SUNDUK image function createSunduk() { var sunduk = game.addChild(LK.getAsset('Sunduk', { anchorX: 0.5, anchorY: 0.5 })); sunduk.x = 2090; // Center image horizontally sunduk.y = Math.floor(Math.random() * (2732 - 2332 + 1)) + 2332; // Random height between 2332 and 2732 sunduk.rotation = Math.PI / 9; // Rotate image by 20 degrees clockwise sunduk.alpha = 0.5; // Set transparency to 50% } // Function to create UFO image function createUfo() { var ufo = game.addChild(LK.getAsset('Ufo', { anchorX: 0.5, anchorY: 0.5 })); ufo.x = 2090; // Center image horizontally ufo.y = Math.floor(Math.random() * (2732 - 2332 + 1)) + 2332; // Random height between 2332 and 2732 ufo.rotation = Math.PI / 9; // Rotate image by 20 degrees clockwise ufo.alpha = 0.5; // Set transparency to 50% } // Create a new image 123 every 3 seconds on the right side of the screen var image123Timer = LK.setInterval(function () { var newImage123 = game.addChild(LK.getAsset('123', { anchorX: 0.5, anchorY: 0.5 })); newImage123.x = 2048 + newImage123.width / 2; // Position on the right side of the screen newImage123.y = 2732 / 2 + 1290; // Move image down by 600 pixels newImage123.rotation = Math.PI / 9; // Rotate image by 20 degrees clockwise }, 1450); LK.setTimeout(function () { vzriv = game.addChild(LK.getAsset('Vzriv', { anchorX: 0.5, anchorY: 0.5 })); vzriv.x = vzriv.width / 2 + 90; // Position Vzriv at the left center of the screen vzriv.y = 2732 / 2 - 280; // Center Vzriv vertically game.setChildIndex(player, game.children.length - 1); // Move player to the top game.setChildIndex(buttonBot, game.children.length - 1); // Ensure buttonBot is on top game.setChildIndex(buttonTop, game.children.length - 1); // Ensure buttonTop is on top // Remove Vzriv 2.1 seconds after the game starts LK.setTimeout(function () { vzriv.destroy(); }, 2100); }, 1860); // Add image 123 to the center of the screen var image123 = game.addChild(LK.getAsset('123', { anchorX: 0.5, anchorY: 0.5 })); image123.x = 2048 / 2; // Center image horizontally image123.y = 2732 / 2 + 280; // Move image 123 down by 280 pixels image123.rotation = Math.PI / 9; // Rotate image 123 by 20 degrees clockwise // Add snow image to the top center of the screen var snowImage = game.addChild(LK.getAsset('snow', { anchorX: 0.5, anchorY: 0.5 })); snowImage.x = 2050; // Center image horizontally snowImage.y = 100; // Position image at the top snowImage.rotation = Math.PI * (320 / 180); // Rotate image by 320 degrees clockwise // Add 'Dom' image to the center of the screen var domImage = game.addChild(LK.getAsset('Dom', { anchorX: 0.5, anchorY: 0.5 })); domImage.x = 2048 / 2 + 70; // Center image horizontally domImage.y = 2732 / 2 - 305; // Center image vertically domImage.rotation = Math.PI / 9; // Rotate image by 20 degrees clockwise domImage.alpha = 0.2; // Set transparency to 50% domImage.blendMode = BLEND_MODES.NORMAL; // Ensure transparency does not sum up // Add a glow effect to the 'Dom' image tween(domImage, { alpha: 0.2 }, { duration: 1000, yoyo: true, repeat: Infinity }); // Add image 'niz' to the bottom of the screen var niz = game.addChild(LK.getAsset('NIZ', { anchorX: 0.5, // Center horizontally anchorY: 0.5 // Align to the bottom })); niz.x = 2048 / 2 - 150; // Center image horizontally niz.y = 2732 - 200; // Position image at the bottom of the screen niz.rotation = Math.PI / 9; game.setChildIndex(niz, 0); // Move 'niz' to the back layer // Function to create ALMAZ image function createAlmaz() { var almaz = game.addChild(LK.getAsset('almaz', { anchorX: 0.5, anchorY: 0.5 })); almaz.x = 2090; // Center image horizontally almaz.y = Math.floor(Math.random() * (2732 - 2332 + 1)) + 2332; // Random height between 2332 and 2732 almaz.rotation = Math.PI / 9; // Rotate image by 20 degrees clockwise almaz.alpha = 0.7; // Set transparency to 70% } // Function to create SKELET image function createSkelet() { var skelet = game.addChild(LK.getAsset('Skelet', { anchorX: 0.5, anchorY: 0.5 })); skelet.x = 2090; // Center image horizontally skelet.y = Math.floor(Math.random() * (2732 - 2332 + 1)) + 2332; // Random height between 2332 and 2732 skelet.rotation = Math.PI / 9; // Rotate image by 20 degrees clockwise skelet.alpha = 0.5; // Set transparency to 50% } // Set a random interval between 4 to 8 seconds to create ALMAZ function randomAlmazCreation() { var randomTime = Math.floor(Math.random() * (10000 - 4000 + 1)) + 4000; LK.setTimeout(function () { createAlmaz(); randomAlmazCreation(); // Call again for continuous random creation }, randomTime); } // Start the random ALMAZ creation randomAlmazCreation(); // Set a random interval between 4 to 8 seconds to create SKELET function randomSkeletCreation() { var randomTime = Math.floor(Math.random() * (10000 - 4000 + 1)) + 4000; LK.setTimeout(function () { createSkelet(); randomSkeletCreation(); // Call again for continuous random creation }, randomTime); } // Start the random SKELET creation randomSkeletCreation(); // Set a random interval between 4 to 8 seconds to create UFO function randomUfoCreation() { var randomTime = Math.floor(Math.random() * (10000 - 4000 + 1)) + 4000; LK.setTimeout(function () { createUfo(); randomUfoCreation(); // Call again for continuous random creation }, randomTime); } // Start the random UFO creation randomUfoCreation(); // Create 'niz' every 2 seconds, except for the first instance var nizTimer = LK.setInterval(function () { var newNiz = game.addChild(LK.getAsset('NIZ', { anchorX: 0.5, anchorY: 0.5 })); newNiz.x = 2048 / 2 + 2000; newNiz.y = 2732 + 580; newNiz.rotation = Math.PI / 9; game.setChildIndex(newNiz, 0); }, 2000); var ball = game.addChild(LK.getAsset('Ball', { anchorX: 0.5, anchorY: 0.5 })); ball.x = ball.width / 2 - 100; // Shift ball 100 pixels to the left ball.y = 2732 / 2 - 300; // Center ball vertically LK.setTimeout(function () { tween(ball, { x: ball.x + 400 }, { duration: 360, // Reduced duration to double the speed easing: tween.linear, onFinish: function onFinish() { ball.destroy(); // Remove the ball after it moves 200 pixels } }); }, 1500); game.down = function (x, y, obj) {}; var player = game.addChild(new Player()); player.x = player.width / 2 + 200; // Position player 200 units to the right of the center left of the screen player.y = 2732 / 2 - 250; // Move player 150 units down player.rotation = Math.PI / 12; // Set initial rotation to 15 degrees clockwise // Add background to the game var background = game.addChild(LK.getAsset('background_1', { anchorX: 0.5, anchorY: 0.5 })); game.setChildIndex(background, 0); // Move background to the bottom background.x = 2048 / 2; // Center background horizontally background.y = 2732 / 2 + 150; // Move background down by 550 pixels background.rotation = Math.PI / 9; // Rotate background by 20 degrees clockwise // Move background_1 towards its left side var backgroundCounter = 0; var backgroundTimer = LK.setInterval(function () { var newBackground = game.addChild(LK.getAsset('background_1', { anchorX: 0.5, anchorY: 0.5 })); newBackground.x = 2048 / 2 + 2500; // Move background 2048 pixels to the right newBackground.y = 2732 / 2 + 1060; // Move background down by 1100 pixels newBackground.rotation = Math.PI / 9; // Rotate background by 20 degrees clockwise backgroundCounter++; if (backgroundCounter === 1) { LK.clearInterval(backgroundTimer); backgroundTimer = LK.setInterval(function () { var newBackground = game.addChild(LK.getAsset('background_1', { anchorX: 0.5, anchorY: 0.5 })); newBackground.x = 2048 / 2 + 2500; // Move background 2048 pixels to the right newBackground.y = 2732 / 2 + 1060; // Move background down by 1100 pixels newBackground.rotation = Math.PI / 9; // Rotate background by 20 degrees clockwise }, 2300); } else if (backgroundCounter === 2) { LK.clearInterval(backgroundTimer); backgroundTimer = LK.setInterval(function () { var newBackground = game.addChild(LK.getAsset('background_1', { anchorX: 0.5, anchorY: 0.5 })); newBackground.x = 2048 / 2 + 2500; // Move background 2048 pixels to the right newBackground.y = 2732 / 2 + 1060; // Move background down by 1100 pixels newBackground.rotation = Math.PI / 9; // Rotate background by 20 degrees clockwise }, 1950); } }, 400); var gameStarted = false; // Removed score increment from timer var gameStartTimer = LK.setTimeout(function () { gameStarted = true; LK.getSound('go').play(); // Play 'go' sound 2 seconds after the game starts }, 2000); // Add BUTTON_TOP to the game var buttonTop = game.addChild(new ButtonTop()); buttonTop.x = 2048 - buttonTop.width / 2 - 50; // Position buttonTop 50 units to the left of the right edge of the screen buttonTop.y = 2732 - buttonTop.height / 2 - 350; // Position buttonTop 370 units above the bottom edge of the screen // Add BUTTON_BOT to the game var buttonBot = game.addChild(new ButtonBot()); buttonBot.x = 2048 - buttonBot.width / 2 - 50; // Position buttonBot 50 units to the left of the right edge of the screen buttonBot.y = 2732 - buttonBot.height / 2 - 20; // Position buttonBot 20 units above the bottom edge of the screen game.update = function () { if (!gameStarted) { buttonTop.interactive = false; buttonBot.interactive = false; return; } buttonTop.interactive = true; buttonBot.interactive = true; // Update lastY and lastX for player player.lastY = player.y; player.lastX = player.x; // Create a random obstacle every 200 ticks if (LK.ticks % obstacleInterval === 0) { createRandomObstacle(); } game.children.forEach(function (child) { if (child !== player && child !== buttonTop && child !== buttonBot) { if (child.assetId === 'snow' && (child.y + child.height / 2 < 0 || child.x - child.width / 2 > 2048 || child.y - child.height / 2 > 2732)) { child.destroy(); // Remove the snow image return; } if (child === monetka && player.intersects(monetka)) { monetka.destroy(); LK.setScore(LK.getScore() + 1); // Increase score by 1 scoreText.setText(LK.getScore().toString()); // Update score display // Check if the current score is a new high score if (LK.getScore() > storage.highScore) { storage.highScore = LK.getScore(); var newRecordImage = LK.gui.center.addChild(LK.getAsset('newRecordImage', { anchorX: 0.5, anchorY: 0.5 })); newRecordImage.x = 5; newRecordImage.y = -600; LK.setTimeout(function () { newRecordImage.destroy(); }, 1000); } return; } if (obstacles.includes(child)) { var dx = player.x - child.x; var dy = player.y - child.y; var distance = Math.sqrt(dx * dx + dy * dy); var playerHalfWidth = player.width / 2; var playerHalfHeight = player.height / 2; var obstacleRadius = Math.min(child.width, child.height) / 2; var combinedRadius = obstacleRadius + Math.abs(playerHalfWidth, playerHalfHeight); // Check collision based on player's orientation if (!player.inAir) { // Standing position: check height if (child.lastWasIntersecting === false && distance < obstacleRadius + playerHalfHeight) { LK.effects.flashScreen(0xff0000, 1000); // Flash screen red for 1 second LK.showGameOver(); // Trigger game over when player collides with any obstacle return; } } else { // Lying down position: check width if (child.lastWasIntersecting === false && distance < obstacleRadius + playerHalfWidth) { LK.effects.flashScreen(0xff0000, 1000); // Flash screen red for 1 second LK.showGameOver(); // Trigger game over when player collides with any obstacle return; } } child.lastWasIntersecting = distance < combinedRadius; } if (child.lastWasIntersecting === undefined) { child.lastWasIntersecting = false; } if (child.lastX === undefined) { child.lastX = child.x; } if (child.lastY === undefined) { child.lastY = child.y; } if (child === domImage) { if (child.lastX === undefined) { child.lastX = child.x; } if (child.lastY === undefined) { child.lastY = child.y; } if (child.lastX === undefined) { child.lastX = child.x; } if (child.lastY === undefined) { child.lastY = child.y; } child.x -= 3 * Math.cos(child.rotation); // Set speed for domImage child.y -= 3 * Math.sin(child.rotation); // Set speed for domImage child.lastX = child.x; child.lastY = child.y; } else if (domImages.includes(child)) { child.x -= 3 * Math.cos(child.rotation); // Set speed for newDom images child.y -= 3 * Math.sin(child.rotation); // Set speed for newDom images } else { if (child === oblako || child === oblakoLeft || oblakoInstances.includes(child)) { child.x -= 1 * Math.cos(child.rotation); // Set speed for 'Oblako' and 'OblakoLeft' child.y -= 1 * Math.sin(child.rotation); // Set speed for 'Oblako' and 'OblakoLeft' } else { child.x -= otherImageSpeed * Math.cos(child.rotation); // Apply increased speed for other images child.y -= otherImageSpeed * Math.sin(child.rotation); // Apply increased speed for other images } } if (child.y + child.height / 2 < 0 || child.x - child.width / 2 > 2048 || child.y - child.height / 2 > 2732) { // If the image is completely off the screen child.destroy(); // Remove the image if (obstacles.includes(child)) { obstacles.splice(obstacles.indexOf(child), 1); // Remove from obstacles array } if (oblakoInstances.includes(child)) { oblakoInstances.splice(oblakoInstances.indexOf(child), 1); // Remove from oblakoInstances array } if (domImages.includes(child)) { domImages.splice(domImages.indexOf(child), 1); // Remove from domImages array } } } game.setChildIndex(player, game.children.length - 1); // Move player to the top game.setChildIndex(buttonBot, game.children.length - 1); // Ensure buttonBot is on top game.setChildIndex(buttonTop, game.children.length - 1); // Ensure buttonTop is on top }); // Add shaking effect to the player if (gameStarted) { if (LK.ticks < 130) { // Strong shake for the first second (assuming 60 FPS) player.x = player.lastX + Math.sin(LK.ticks / 0.5) * 10; player.y = player.lastY + Math.cos(LK.ticks / 0.5) * 10; } else { player.x = player.lastX + Math.sin(LK.ticks / 0.5) * 3; player.y = player.lastY + Math.cos(LK.ticks / 0.5) * 3; } if (vzriv && vzriv.parent) { vzriv.destroy(); } } };
===================================================================
--- original.js
+++ change.js
@@ -352,9 +352,9 @@
var oblako = game.addChild(LK.getAsset('Oblako', {
anchorX: 0.5,
anchorY: 0.5
}));
-oblako.x = 1200; // Position 'Oblako' in the middle of the right side of the screen
+oblako.x = 1400; // Position 'Oblako' in the middle of the right side of the screen
oblako.y = Math.floor(Math.random() * (600 - 400)) + 400; // Random height between 200 and 700
oblako.rotation = Math.PI / 9; // Rotate 'Oblako' by 20 degrees clockwise
oblako.alpha = 0.3; // Set transparency to 50%
oblako.scale.set(Math.random() * (1 - 0.33) + 0.33); // Apply random scale between 0.33 and 1
@@ -362,10 +362,10 @@
var oblakoLeft = game.addChild(LK.getAsset('Oblako', {
anchorX: 0.5,
anchorY: 0.5
}));
-oblakoLeft.x = Math.floor(Math.random() * (600 - 400)) + 400;
-oblakoLeft.y = oblako.y; // Same random height as the first cloud
+oblakoLeft.x = oblako.x - 700; // Position 400 pixels to the left of the first cloud
+oblakoLeft.y = Math.floor(Math.random() * (500 - 300)) + 300;
oblakoLeft.rotation = oblako.rotation; // Same rotation as the first cloud
oblakoLeft.alpha = oblako.alpha; // Same transparency as the first cloud
oblakoLeft.scale.set(Math.random() * (1 - 0.33) + 0.33); // Apply random scale between 0.33 and 1
var otherImageSpeed = 20; // Initial speed for other images
@@ -384,9 +384,9 @@
newOblako.y = Math.floor(Math.random() * (901 - 400)) + 400; // Random height between 200 and 700
newOblako.rotation = Math.PI / 9; // Rotate 'Oblako' by 20 degrees clockwise
newOblako.alpha = 0.3; // Set transparency to 50%
oblakoInstances.push(newOblako); // Add new oblako to the array
-}, 5000);
+}, 8000);
// Create an array to store 'Dom' images
// Define BLEND_MODES to fix the undefined variable error
var BLEND_MODES = {
NORMAL: 0
создать мультяшного сидячего персонажа. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
snowball. 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
Скелет дракона. Мультяшный. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Ufo (летающая тарелка). Мультяшная. 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
Человек летит на параплане. Мультяшный. 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
Рука белая. Иконка. 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
text: New Record! Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows