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 () { var self = Container.call(this); var characterGraphics = self.attachAsset('character', { 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; // Create wall graphics based on type var wallAsset = self.wallType === 'poison' ? 'poisonWall' : 'normalWall'; var wallGraphics = self.attachAsset(wallAsset, { anchorX: 0.5, anchorY: 0 }); // Create opening in the wall (gap for player to pass through) self.gapPosition = Math.random() * (2048 - 400) + 200; // Random position with margins self.gapWidth = 200; // Create left and right wall segments var leftWall = self.attachAsset(wallAsset, { anchorX: 0, anchorY: 0, width: self.gapPosition, x: -1024 }); var rightWall = self.attachAsset(wallAsset, { anchorX: 0, anchorY: 0, width: 2048 - (self.gapPosition + self.gapWidth), x: self.gapPosition + self.gapWidth - 1024 }); 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) // Create ground var ground = game.addChild(LK.getAsset('ground', { anchorX: 0.5, anchorY: 1, x: 2048 / 2, y: 2732 })); // Create character var character = game.addChild(new Character()); character.x = 2048 / 2; character.y = groundLevel; // 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) { dragNode = character; character.x = Math.max(80, Math.min(2048 - 80, x)); // Keep character within bounds }; game.move = function (x, y, obj) { if (dragNode) { dragNode.x = Math.max(80, Math.min(2048 - 80, x)); // Keep character within bounds with margins } }; game.up = function (x, y, obj) { dragNode = null; }; // Main game update loop game.update = function () { 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()); } } // 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)) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); return; } } // Remove walls that are off screen if (wall.y > 2732 + 100) { wall.destroy(); walls.splice(i, 1); } } };
===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,139 @@
-/****
+/****
+* Classes
+****/
+var Character = Container.expand(function () {
+ var self = Container.call(this);
+ var characterGraphics = self.attachAsset('character', {
+ 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;
+ // Create wall graphics based on type
+ var wallAsset = self.wallType === 'poison' ? 'poisonWall' : 'normalWall';
+ var wallGraphics = self.attachAsset(wallAsset, {
+ anchorX: 0.5,
+ anchorY: 0
+ });
+ // Create opening in the wall (gap for player to pass through)
+ self.gapPosition = Math.random() * (2048 - 400) + 200; // Random position with margins
+ self.gapWidth = 200;
+ // Create left and right wall segments
+ var leftWall = self.attachAsset(wallAsset, {
+ anchorX: 0,
+ anchorY: 0,
+ width: self.gapPosition,
+ x: -1024
+ });
+ var rightWall = self.attachAsset(wallAsset, {
+ anchorX: 0,
+ anchorY: 0,
+ width: 2048 - (self.gapPosition + self.gapWidth),
+ x: self.gapPosition + self.gapWidth - 1024
+ });
+ 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: 0x000000
-});
\ No newline at end of file
+ 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)
+// Create ground
+var ground = game.addChild(LK.getAsset('ground', {
+ anchorX: 0.5,
+ anchorY: 1,
+ x: 2048 / 2,
+ y: 2732
+}));
+// Create character
+var character = game.addChild(new Character());
+character.x = 2048 / 2;
+character.y = groundLevel;
+// 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) {
+ dragNode = character;
+ character.x = Math.max(80, Math.min(2048 - 80, x)); // Keep character within bounds
+};
+game.move = function (x, y, obj) {
+ if (dragNode) {
+ dragNode.x = Math.max(80, Math.min(2048 - 80, x)); // Keep character within bounds with margins
+ }
+};
+game.up = function (x, y, obj) {
+ dragNode = null;
+};
+// Main game update loop
+game.update = function () {
+ 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());
+ }
+ }
+ // 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)) {
+ LK.effects.flashScreen(0xff0000, 1000);
+ LK.showGameOver();
+ return;
+ }
+ }
+ // Remove walls that are off screen
+ if (wall.y > 2732 + 100) {
+ wall.destroy();
+ walls.splice(i, 1);
+ }
+ }
+};
\ No newline at end of file