User prompt
key1 i alınca skora 2 puan ekle,key2 i alınca skora 5 puan ekle,key3 i alınca skora 7 puan ekle,
User prompt
keyleri alınca skor anlık sıfırlanıyor ve puanıda eklemiyor bunu düzelt
User prompt
keyler her 5 puanda bir gelsin
User prompt
Please fix the bug: 'ReferenceError: keyType is not defined' in or related to this line: 'switch (keyType) {' Line Number: 125
User prompt
key1 i alıca ekranda "+2 score" yazsın ve skora 2 puan eklensin, key2 yi alınca ekranda "+5 score" yazsın ve skore 5 puan eklensin, key3 ü alınca ekranda "+7score" yazsın ve skoar 7 puan eklensin
User prompt
Please fix the bug: 'ReferenceError: keyType is not defined' in or related to this line: 'if (keyType === 'key1') {' Line Number: 125
User prompt
key1 i alıca üzerinde "+2 score" yazsın ve skora 2 puan eklensin, key2 yi alınca "+5 score" yazsın ve skore 5 puan eklensin, key3 ü alınca "+7score" yazsın ve skoar 7 puan eklensin
User prompt
her 15 puanda bir "key1","key2","key3" herhangi bir koridordan gelsin ve bunları alabilelim
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'intersects')' in or related to this line: 'if (obstacles[i].intersects(player)) {' Line Number: 216
User prompt
skor arttıkça mermileri hızlandır
User prompt
mermilerin spawn olma süresini arttır
User prompt
mermilerin y ekseni arasındaki mesafeyi arttır
User prompt
mermilerin x ekseni arasındaki mesafeyi arttır
User prompt
mermilerin yataydaki arasındaki mesafeyi arttır
User prompt
mermilerin yataydaki mesafesini arttır (hızını değiştirmeden)
User prompt
bazen 2 mermi birden gelsin farklı koridorlardan
User prompt
her 30 skorda bir key1 herhangi bir koridordan gelsin ve bunu alabilelim
User prompt
bazen 2 koridordanda mermi gelsin
User prompt
bazene 2 koridordanda mermi gelsin
User prompt
her 20 skorda bi key3 herhangi bir koridordan gelsni gelsin
User prompt
her 10 skorda bi key3 gelsin
User prompt
her 10 skorda 3 saniye mermi gelmesin
User prompt
her 10 korda 2 dalga mermi gelmesin
User prompt
keylerin hızını biraz azalt
User prompt
keylerin hızını 2 katına çıakrve her 10 skorda bir gelsinler
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ // Define the Button class var Button = Container.expand(function () { var self = Container.call(this); var buttonGraphics = self.attachAsset('button', { anchorX: 0.5, anchorY: 0.5 }); return self; }); // Define the Key class var Key = Container.expand(function () { var self = Container.call(this); var keyTypes = ['key1', 'key2', 'key3']; var keyType = keyTypes[Math.floor(Math.random() * keyTypes.length)]; var keyGraphics = self.attachAsset(keyType, { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { self.x -= 5; // Move the key to the left }; return self; }); // Define the Obstacle class var Obstacle = Container.expand(function () { var self = Container.call(this); var obstacleGraphics = self.attachAsset('bullet', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; // Initial speed // Update method for obstacle movement self.update = function () { self.x -= self.speed; }; return self; }); //<Assets used in the game will automatically appear here> //<Write imports for supported plugins here> // Define the Player class var Player = Container.expand(function () { var self = Container.call(this); var playerGraphics = self.attachAsset('character', { anchorX: 0.5, anchorY: 0.5 }); self.layer = 1; // Start on the middle layer self.speed = 10; // Initial speed // Method to move the player up a layer self.moveUp = function () { if (self.layer > 0) { self.layer--; tween(self, { y: self.y - 450 }, { duration: 300, easing: tween.easeInOut }); } }; // Method to move the player down a layer self.moveDown = function () { if (self.layer < 2) { self.layer++; tween(self, { y: self.y + 450 }, { duration: 300, easing: tween.easeInOut }); } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x0000FF //Init game with blue background }); /**** * Game Code ****/ function spawnKey() { var lanes = [-450, 0, 450]; var lane = lanes[Math.floor(Math.random() * lanes.length)]; var key = new Key(); var keyType = key.keyType; // Define keyType within the function scope key.x = 2048; key.y = 1366 - 450 + lane; game.addChild(key); // Check for collision with player key.update = function () { this.x -= 5; if (this.intersects(player)) { var scoreIncrement = 0; var message = ""; switch (keyType) { case 'key1': scoreIncrement = 2; message = "+2 score"; break; case 'key2': scoreIncrement = 5; message = "+5 score"; break; case 'key3': scoreIncrement = 7; message = "+7 score"; break; } score += scoreIncrement; scoreTxt.setText(score); // Display score increment message var scoreMessage = new Text2(message, { size: 100, fill: 0xFFFFFF }); scoreMessage.x = this.x; scoreMessage.y = this.y; game.addChild(scoreMessage); // Fade out and remove the message tween(scoreMessage, { alpha: 0 }, { duration: 1000, onFinish: function onFinish() { scoreMessage.destroy(); } }); this.destroy(); } }; } var background = game.attachAsset('background', { anchorX: 0.0, anchorY: 0.0 }); background.x = 0; background.y = 0; // Initialize player var player = new Player(); player.x = 200; player.y = 1366 - 450; // Start on the middle layer game.addChild(player); // Create a variable to keep track of the current character asset var characterAssets = ['character', 'c2', 'c3', 'c4']; var currentCharacterAsset = 0; // Create a timer to change the character asset every 0.2 seconds LK.setInterval(function () { // Remove the current character asset player.removeChild(player.children[0]); // Update the current character asset index currentCharacterAsset = (currentCharacterAsset + 1) % characterAssets.length; // Attach the new character asset player.attachAsset(characterAssets[currentCharacterAsset], { anchorX: 0.5, anchorY: 0.5 }); }, 200); // Initialize buttons var buttonUp = new Button(); buttonUp.x = 1024; buttonUp.y = 2732 - 600; // Position at the bottom of the screen buttonUp.scale.set(2); // Increase the size of the button game.addChild(buttonUp); var buttonDown = new Button(); buttonDown.x = 1024; buttonDown.y = 2732 - 300; // Position at the bottom of the screen buttonDown.scale.set(2); // Increase the size of the button buttonDown.rotation = Math.PI; // Rotate the button by 180 degrees game.addChild(buttonDown); // Initialize obstacles array var obstacles = []; // Initialize score var score = 0; var scoreTxt = new Text2('0', { size: 150, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Function to create obstacles function createObstacle() { var lanes = [-450, 0, 450]; var selectedLanes = [lanes[Math.floor(Math.random() * lanes.length)]]; // 30% chance to spawn a second obstacle in a different lane if (Math.random() < 0.3) { var secondLane; do { secondLane = lanes[Math.floor(Math.random() * lanes.length)]; } while (selectedLanes.includes(secondLane)); selectedLanes.push(secondLane); } selectedLanes.forEach(function (lane) { var obstacle = new Obstacle(); obstacle.x = 2048; obstacle.y = 1366 - 450 + lane; obstacles.push(obstacle); game.addChild(obstacle); }); } // Function to update game speed function updateSpeed() { var speedIncrease = score * 0.01; // Increase speed based on score player.speed += speedIncrease; obstacles.forEach(function (obstacle) { obstacle.speed += speedIncrease; }); } // Handle swipe up and down game.move = function (x, y, obj) { if (obj.event && obj.event.deltaY < 0) { player.moveUp(); } else if (obj.event && obj.event.deltaY > 0) { player.moveDown(); } }; // Handle button presses buttonUp.down = function (x, y, obj) { if (!buttonUp.cooldown && !buttonDown.cooldown) { player.moveUp(); buttonUp.cooldown = true; buttonDown.cooldown = true; LK.setTimeout(function () { buttonUp.cooldown = false; buttonDown.cooldown = false; }, 310); } }; buttonDown.down = function (x, y, obj) { if (!buttonUp.cooldown && !buttonDown.cooldown) { player.moveDown(); buttonUp.cooldown = true; buttonDown.cooldown = true; LK.setTimeout(function () { buttonUp.cooldown = false; buttonDown.cooldown = false; }, 310); } }; // Game update loop game.update = function () { // Update obstacles for (var i = obstacles.length - 1; i >= 0; i--) { obstacles[i].update(); if (obstacles[i].x < -100) { obstacles[i].destroy(); obstacles.splice(i, 1); score++; scoreTxt.setText(score); } if (score > 0 && score % 5 === 0 && !game.keySpawned) { spawnKey(); game.keySpawned = true; } else if (score % 5 !== 0) { game.keySpawned = false; } if (obstacles[i] && obstacles[i].intersects(player)) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } } // Create new obstacles if (LK.ticks % 120 == 0) { createObstacle(); } // Update speed updateSpeed(); };
===================================================================
--- original.js
+++ change.js