User prompt
arkaplan müziğini sürekli çaldır
User prompt
eğer kırmızı duvara deydikten sonra puanımız 0 olursa veya altı olursa oyunu kaybedeliöm
User prompt
zehirli duvara temas edersek oyunu kaybetmiyelim ve 20 puan kaybedelim ve oyunun başında karakter seçelim
User prompt
eğer kırmızı duvara temas edersek -20 puan alalım
User prompt
eğer puan alırsak ses2 çalsın
User prompt
eğer kırmızıyı atlarsak ses1
User prompt
100 puan olunca oyunu kazanalım
User prompt
oyunu kybedersek ses1 çalsın
User prompt
simge1 ve simge2 duvarların üstünde olsun
User prompt
normal duvarlarda da delik olsun ve normal duvarda simge2 zehirli duvarda simge1 gözüksün
User prompt
zehirsiz duvara değersek puanımız 5 artsın
User prompt
eğer bir zehirsiz bir duvara temas edersek temas etiğimiz duvar yok olsun
User prompt
zehirli duvarların yanları veya ortasında açık olsun açıklıklar en başta büyük olsun ama puan artıkça küçülsün ama karakterin boyunda daha fazla küçülmesin
Code edit (1 edits merged)
Please save this source code
User prompt
Wall Runner
Initial prompt
bir zemin olsun önden duvarlar gelsin ama duvarlar iki tür olsun biri zehirli biri normal normalin içinden geçersek puan kazanalım zehirliden geçersek kaybedelim ve puan yukarı solda olsun
/**** * Classes ****/ var Character = Container.expand(function (characterType) { var self = Container.call(this); self.characterType = characterType || 'character1'; var characterGraphics = self.attachAsset(self.characterType, { anchorX: 0.5, anchorY: 1 }); return self; }); var Wall = Container.expand(function (wallType) { var self = Container.call(this); // Store wall type (normal or poison) self.wallType = wallType || 'normal'; self.speed = 8; self.passed = false; if (self.wallType === 'poison') { // For poison walls, create openings that get smaller with score // Base gap width starts at 300, decreases by 10 for each point, minimum 100 (slightly larger than character) var currentScore = LK.getScore(); self.gapWidth = Math.max(100, 300 - currentScore * 10); // Randomly choose gap position: left side, center, or right side var gapType = Math.floor(Math.random() * 3); // 0=left, 1=center, 2=right if (gapType === 0) { // Left side opening self.gapPosition = 50; } else if (gapType === 1) { // Center opening self.gapPosition = (2048 - self.gapWidth) / 2; } else { // Right side opening self.gapPosition = 2048 - self.gapWidth - 50; } // Create wall graphics based on type var wallAsset = 'poisonWall'; // Create left wall segment (if gap is not at the far left) if (self.gapPosition > 0) { var leftWall = self.attachAsset(wallAsset, { anchorX: 0, anchorY: 0, width: self.gapPosition, x: -1024 }); } // Create right wall segment (if gap is not at the far right) if (self.gapPosition + self.gapWidth < 2048) { var rightWall = self.attachAsset(wallAsset, { anchorX: 0, anchorY: 0, width: 2048 - (self.gapPosition + self.gapWidth), x: self.gapPosition + self.gapWidth - 1024 }); } // Add simge1 symbol to poison walls var simge1 = self.attachAsset('simge1', { anchorX: 0.5, anchorY: 0.5, x: self.gapPosition + self.gapWidth / 2 - 1024, y: -50 }); } else { // Normal walls - create openings similar to poison walls but smaller var currentScore = LK.getScore(); self.gapWidth = Math.max(120, 200 - currentScore * 5); // Smaller gaps than poison walls // Randomly choose gap position: left side, center, or right side var gapType = Math.floor(Math.random() * 3); // 0=left, 1=center, 2=right if (gapType === 0) { // Left side opening self.gapPosition = 50; } else if (gapType === 1) { // Center opening self.gapPosition = (2048 - self.gapWidth) / 2; } else { // Right side opening self.gapPosition = 2048 - self.gapWidth - 50; } // Create wall graphics based on type var wallAsset = 'normalWall'; // Create left wall segment (if gap is not at the far left) if (self.gapPosition > 0) { var leftWall = self.attachAsset(wallAsset, { anchorX: 0, anchorY: 0, width: self.gapPosition, x: -1024 }); } // Create right wall segment (if gap is not at the far right) if (self.gapPosition + self.gapWidth < 2048) { var rightWall = self.attachAsset(wallAsset, { anchorX: 0, anchorY: 0, width: 2048 - (self.gapPosition + self.gapWidth), x: self.gapPosition + self.gapWidth - 1024 }); } // Add simge2 symbol to normal walls var simge2 = self.attachAsset('simge2', { anchorX: 0.5, anchorY: 0.5, x: self.gapPosition + self.gapWidth / 2 - 1024, y: -50 }); } self.update = function () { self.y += self.speed; }; // Check if character is in the gap self.isCharacterInGap = function (characterX) { return characterX >= self.gapPosition && characterX <= self.gapPosition + self.gapWidth; }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87CEEB }); /**** * Game Code ****/ // Game dimensions are 2048x2732 var groundLevel = 2732 - 100; // Ground at bottom of screen var walls = []; var wallSpawnTimer = 0; var wallSpawnDelay = 80; // Spawn wall every 80 ticks (about 1.3 seconds at 60fps) // Character selection state var gameState = 'characterSelect'; // 'characterSelect' or 'playing' var selectedCharacterType = 'character1'; var characterPreview1, characterPreview2, characterPreview3; var selectButton1, selectButton2, selectButton3; var selectButtonText1, selectButtonText2, selectButtonText3; var titleText; // Create ground var ground = game.addChild(LK.getAsset('ground', { anchorX: 0.5, anchorY: 1, x: 2048 / 2, y: 2732 })); // Create character selection UI titleText = new Text2('Choose Your Character', { size: 80, fill: '#ffffff' }); titleText.anchor.set(0.5, 0.5); titleText.x = 2048 / 2; titleText.y = 400; game.addChild(titleText); // Character 1 preview characterPreview1 = game.addChild(new Character('character1')); characterPreview1.x = 2048 / 2 - 300; characterPreview1.y = 1000; // Character 2 preview characterPreview2 = game.addChild(new Character('character2')); characterPreview2.x = 2048 / 2; characterPreview2.y = 1000; // Character 3 preview characterPreview3 = game.addChild(new Character('character3')); characterPreview3.x = 2048 / 2 + 300; characterPreview3.y = 1000; // Select buttons selectButton1 = game.addChild(LK.getAsset('selectButton', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2 - 300, y: 1200 })); selectButton2 = game.addChild(LK.getAsset('selectButton', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 1200 })); selectButton3 = game.addChild(LK.getAsset('selectButton', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2 + 300, y: 1200 })); // Button texts selectButtonText1 = new Text2('Blue Hero', { size: 40, fill: '#ffffff' }); selectButtonText1.anchor.set(0.5, 0.5); selectButtonText1.x = 2048 / 2 - 300; selectButtonText1.y = 1200; game.addChild(selectButtonText1); selectButtonText2 = new Text2('Orange Hero', { size: 40, fill: '#ffffff' }); selectButtonText2.anchor.set(0.5, 0.5); selectButtonText2.x = 2048 / 2; selectButtonText2.y = 1200; game.addChild(selectButtonText2); selectButtonText3 = new Text2('Purple Hero', { size: 40, fill: '#ffffff' }); selectButtonText3.anchor.set(0.5, 0.5); selectButtonText3.x = 2048 / 2 + 300; selectButtonText3.y = 1200; game.addChild(selectButtonText3); // Character will be created after selection var character; // Create score display var scoreTxt = new Text2('Score: 0', { size: 60, fill: '#ffffff' }); scoreTxt.anchor.set(0, 0); scoreTxt.x = 150; // Offset from top-left to avoid menu icon scoreTxt.y = 50; LK.gui.topLeft.addChild(scoreTxt); var dragNode = null; // Handle touch/mouse input game.down = function (x, y, obj) { if (gameState === 'characterSelect') { // Check which character selection button was pressed if (y >= 1170 && y <= 1230) { if (x >= 2048 / 2 - 400 && x <= 2048 / 2 - 200) { // Character 1 selected selectedCharacterType = 'character1'; startGame(); } else if (x >= 2048 / 2 - 100 && x <= 2048 / 2 + 100) { // Character 2 selected selectedCharacterType = 'character2'; startGame(); } else if (x >= 2048 / 2 + 200 && x <= 2048 / 2 + 400) { // Character 3 selected selectedCharacterType = 'character3'; startGame(); } } } else if (gameState === 'playing') { dragNode = character; character.x = Math.max(80, Math.min(2048 - 80, x)); // Keep character within bounds } }; game.move = function (x, y, obj) { if (gameState === 'playing' && dragNode) { dragNode.x = Math.max(80, Math.min(2048 - 80, x)); // Keep character within bounds with margins } }; game.up = function (x, y, obj) { if (gameState === 'playing') { dragNode = null; } }; // Function to start the game after character selection function startGame() { gameState = 'playing'; // Remove character selection UI titleText.destroy(); characterPreview1.destroy(); characterPreview2.destroy(); characterPreview3.destroy(); selectButton1.destroy(); selectButton2.destroy(); selectButton3.destroy(); selectButtonText1.destroy(); selectButtonText2.destroy(); selectButtonText3.destroy(); // Create selected character character = game.addChild(new Character(selectedCharacterType)); character.x = 2048 / 2; character.y = groundLevel; // Start background music LK.playMusic('arakplan'); } // Main game update loop game.update = function () { if (gameState !== 'playing') return; wallSpawnTimer++; // Spawn new walls if (wallSpawnTimer >= wallSpawnDelay) { wallSpawnTimer = 0; // Randomly choose wall type (80% normal, 20% poison for balanced gameplay) var wallType = Math.random() < 0.8 ? 'normal' : 'poison'; var newWall = new Wall(wallType); newWall.x = 2048 / 2; newWall.y = -100; // Start above screen walls.push(newWall); game.addChild(newWall); } // Update walls and check collisions for (var i = walls.length - 1; i >= 0; i--) { var wall = walls[i]; // Check if wall has passed character level and award score for normal walls if (!wall.passed && wall.y > character.y - 40) { wall.passed = true; if (wall.wallType === 'normal') { LK.setScore(LK.getScore() + 1); scoreTxt.setText('Score: ' + LK.getScore()); LK.getSound('ses2').play(); } } // Check collision with poison walls if (wall.wallType === 'poison' && wall.y > character.y - 80 && wall.y < character.y + 40) { // Check if character is NOT in the gap (collision with wall) if (!wall.isCharacterInGap(character.x)) { // Check if we haven't already deducted points for this wall if (!wall.pointsDeducted) { wall.pointsDeducted = true; // Deduct 20 points when touching poison wall LK.setScore(Math.max(0, LK.getScore() - 20)); scoreTxt.setText('Score: ' + LK.getScore()); LK.getSound('ses1').play(); LK.effects.flashScreen(0xff0000, 500); // Check if score is 0 or below after deduction if (LK.getScore() <= 0) { LK.showGameOver(); return; } } } else { // Character is in the gap - successfully passed through poison wall if (!wall.passedThroughGap) { wall.passedThroughGap = true; LK.getSound('ses1').play(); } } } // Check collision with normal walls - destroy them when touched if (wall.wallType === 'normal' && wall.y > character.y - 80 && wall.y < character.y + 40) { // Character is touching the normal wall - check if NOT in gap (collision with wall) if (!wall.isCharacterInGap(character.x)) { LK.setScore(LK.getScore() + 5); scoreTxt.setText('Score: ' + LK.getScore()); LK.getSound('ses2').play(); // Check win condition if (LK.getScore() >= 100) { LK.showYouWin(); return; } wall.destroy(); walls.splice(i, 1); continue; // Skip to next wall since this one is destroyed } } // Remove walls that are off screen if (wall.y > 2732 + 100) { wall.destroy(); walls.splice(i, 1); } } };
===================================================================
--- original.js
+++ change.js
@@ -271,8 +271,10 @@
// Create selected character
character = game.addChild(new Character(selectedCharacterType));
character.x = 2048 / 2;
character.y = groundLevel;
+ // Start background music
+ LK.playMusic('arakplan');
}
// Main game update loop
game.update = function () {
if (gameState !== 'playing') return;