User prompt
engele corporsa 5 saniye süresi ozolt
User prompt
10 Soniye süremiz olsun o süre içinde seçemezsek oyun bitsin doğru tercih yapılına süresi sıfırla nsın
User prompt
tercih yapıldıktan sonra 1 süre be kle
User prompt
Karakter tercihlere dokunacak
User prompt
Terc ihlere dokununca bi ri doğru diğeri yanlış
User prompt
en sondo olacak tercihler
User prompt
Geçitler üst üste olsun engel platformun ortasında olsun
User prompt
Karakter yukarı sürüklenebilsin
User prompt
Biz karakteri sürükleyebilirsiniz
User prompt
bu otomatik hareket etmesin
User prompt
koraktor hareket etmesin
User prompt
Biz bir yere tıklayarak hareket edelim
User prompt
Karoktoni hareket ettiredin
Code edit (1 edits merged)
Please save this source code
User prompt
Doğru Geçidi Bul: Platform Macerası
Initial prompt
Bir platform üzerinde hareket edelim bir engellen otlayalım ve platformun sonunda 2 farklı geçit olsun biri doğru olsun
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ // Gate class var Gate = Container.expand(function () { var self = Container.call(this); // Attach gate asset (ellipse, color depends on type) var gateAsset = self.attachAsset(self.gateType === 'correct' ? 'gateCorrect' : 'gateWrong', { anchorX: 0.5, anchorY: 1 }); self.width = gateAsset.width; self.height = gateAsset.height; // Type: 'correct' or 'wrong' self.gateType = 'wrong'; // Set color based on type self.setType = function (type) { self.gateType = type; var color = type === 'correct' ? 0x44de83 : 0xde4444; gateAsset.tint = color; }; return self; }); // Obstacle class var Obstacle = Container.expand(function () { var self = Container.call(this); // Attach obstacle asset (yellow box) var obsAsset = self.attachAsset('obstacle', { anchorX: 0.5, anchorY: 1 }); self.width = obsAsset.width; self.height = obsAsset.height; return self; }); // Player character class var Player = Container.expand(function () { var self = Container.call(this); // Attach player asset (red box) var playerAsset = self.attachAsset('player', { anchorX: 0.5, anchorY: 1 }); // Player movement speed self.speed = 18; self.jumpPower = 60; self.isJumping = false; self.velocityY = 0; // For collision detection self.width = playerAsset.width; self.height = playerAsset.height; // Jump method self.jump = function () { if (!self.isJumping) { self.isJumping = true; self.velocityY = -self.jumpPower; } }; // Update method (called every tick) self.update = function () { // Horizontal movement (move right automatically) if (!self.isJumping) { self.x += self.speed; // Clamp to platform edges var minX = 120 + self.width / 2; var maxX = 2048 - 120 - self.width / 2; if (self.x > maxX) self.x = maxX; if (self.x < minX) self.x = minX; } // Gravity if (self.isJumping) { self.y += self.velocityY; self.velocityY += 6; // gravity // If landed on platform if (self.y >= platformY) { self.y = platformY; self.isJumping = false; self.velocityY = 0; } } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ // No title, no description // Always backgroundColor is black backgroundColor: 0x000000 }); /**** * Game Code ****/ // Platform Y position (ground level) var platformY = 2200; // Level state var currentLevel = 1; // Arrays for obstacles and gates var obstacles = []; var gates = []; // Dragging state for player movement var dragPlayer = false; // Score text var scoreTxt = new Text2('Seviye: 1', { size: 100, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Platform asset (long gray box) var platform = LK.getAsset('platform', { width: 1800, height: 60, color: 0x888888, shape: 'box', anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: platformY + 30 }); game.addChild(platform); // Create player var player = new Player(); game.addChild(player); player.x = 400; player.y = platformY; // Level setup function function setupLevel(level) { // Remove old obstacles and gates for (var i = 0; i < obstacles.length; i++) { obstacles[i].destroy(); } obstacles = []; for (var j = 0; j < gates.length; j++) { gates[j].destroy(); } gates = []; // Update score text scoreTxt.setText('Seviye: ' + level); // Place player at start player.x = 400; player.y = platformY; player.isJumping = false; player.velocityY = 0; // Place obstacles (random positions, but not too close to start or end) var numObstacles = Math.min(2 + level, 6); for (var o = 0; o < numObstacles; o++) { var obs = new Obstacle(); var minX = 600; var maxX = 2048 - 600; var obsX = minX + Math.floor((maxX - minX) * (o + 1) / (numObstacles + 1)); obs.x = obsX; obs.y = platformY; game.addChild(obs); obstacles.push(obs); } // Place gates at end of platform var gateY = platformY; var gateOffset = 250; var gate1 = new Gate(); var gate2 = new Gate(); // Randomly assign correct/wrong var correctGate = Math.random() < 0.5 ? 1 : 2; if (correctGate === 1) { gate1.setType('correct'); gate2.setType('wrong'); } else { gate1.setType('wrong'); gate2.setType('correct'); } // Place gates gate1.x = 2048 / 2 - gateOffset; gate2.x = 2048 / 2 + gateOffset; gate1.y = gateY - 80; gate2.y = gateY - 80; game.addChild(gate1); game.addChild(gate2); gates.push(gate1); gates.push(gate2); } // Helper: check collision between two containers (AABB) function isColliding(a, b) { return a.x - a.width / 2 < b.x + b.width / 2 && a.x + a.width / 2 > b.x - b.width / 2 && a.y - a.height < b.y && a.y > b.y - b.height; } // Helper: check if player is at a gate function playerAtGate(gate) { // Player must be at the same x as gate, and at the end of platform return Math.abs(player.x - gate.x) < gate.width / 2 && player.y === platformY; } // Touch/mouse controls: Tap anywhere to move player to that X position (on platform) game.down = function (x, y, obj) { // No movement on tap }; game.move = function (x, y, obj) { // No drag movement }; game.up = function (x, y, obj) { // No drag state }; // Main game update loop game.update = function () { player.update(); // Prevent player from falling below platform if (player.y > platformY) { player.y = platformY; player.isJumping = false; player.velocityY = 0; } // Obstacle collision for (var i = 0; i < obstacles.length; i++) { var obs = obstacles[i]; if (isColliding(player, obs) && player.y === platformY // Only if on ground ) { // Flash and reset level LK.effects.flashScreen(0xde4444, 600); setupLevel(currentLevel); return; } } // Gate check (if at end of platform) for (var g = 0; g < gates.length; g++) { var gate = gates[g]; if (playerAtGate(gate)) { if (gate.gateType === 'correct') { // Next level currentLevel += 1; LK.effects.flashScreen(0x44de83, 400); setupLevel(currentLevel); } else { // Wrong gate: game over LK.effects.flashScreen(0xde4444, 1000); LK.showGameOver(); } return; } } }; // Asset initialization (shapes) // Start first level setupLevel(currentLevel);
===================================================================
--- original.js
+++ change.js
@@ -196,20 +196,9 @@
return Math.abs(player.x - gate.x) < gate.width / 2 && player.y === platformY;
}
// Touch/mouse controls: Tap anywhere to move player to that X position (on platform)
game.down = function (x, y, obj) {
- var local = game.toLocal({
- x: x,
- y: y
- });
- // Clamp X to platform
- var minX = 120 + player.width / 2;
- var maxX = 2048 - 120 - player.width / 2;
- player.x = Math.max(minX, Math.min(maxX, local.x));
- // Always set player on platform
- player.y = platformY;
- player.isJumping = false;
- player.velocityY = 0;
+ // No movement on tap
};
game.move = function (x, y, obj) {
// No drag movement
};