User prompt
Oyunda aynı anda en fazla 2 coin olsun
User prompt
Mesela karakter sola giderken sola baksın sağa giderken sağa baksın
User prompt
Yukarıdan giden kartallar biraz daha yukarıdan gidebilir mi
User prompt
Oyuncu 50 skora ylaşırsa oyunu kazansın
User prompt
Düşmanlar birleikte gelmesin birbirlerinde ayrı gelsinlar
User prompt
Düşmanların hızını birazcık arttır
User prompt
Düşmanlar sonsuza kadar gelmeye devam etsinler bir de hızlarını biraz azalt
User prompt
Düşmanlar da biraz seyrek gelsinler
User prompt
Bazı düşmanlar karakterin zıplama seviyesine yakın yetlerde doğsunlar
User prompt
Düşmaların üstüne değince düşmanlar ölmesin
User prompt
Biraz daha seyrek teleport olsunlar
User prompt
Paralar da sürekli rastgele yerlerde teleport olsun
User prompt
Karakter sola basılı tutulunca sola sağa baslı tutulunca sağa ilerlesin
User prompt
Oyun sürekli ilerlesin bitinca durmasın
User prompt
Bu oyunu düz bir zemin üzerinde yapar mısın
User prompt
İlerleme şeklini zıplama tuşuna basılı tutunca sağa doğru ilerlesin şeklinde yapar mısın
User prompt
It is not working
User prompt
Super Coin Jumper
Initial prompt
Can you make a game like super mario in the game we will collect moneys and we will destroy other creatures
/**** * Classes ****/ // Coin class var Coin = Container.expand(function () { var self = Container.call(this); var coinAsset = self.attachAsset('coin', { anchorX: 0.5, anchorY: 0.5 }); self.width = coinAsset.width; self.height = coinAsset.height; self.update = function () { // Optionally animate coin }; return self; }); // Enemy class var Enemy = Container.expand(function () { var self = Container.call(this); var enemyAsset = self.attachAsset('enemy', { anchorX: 0.5, anchorY: 1 }); self.vx = -6; self.width = enemyAsset.width; self.height = enemyAsset.height; self.update = function () { self.x += self.vx; if (self.lastX === undefined) self.lastX = self.x; }; return self; }); // Platform class var Platform = Container.expand(function () { var self = Container.call(this); var platAsset = self.attachAsset('platform', { anchorX: 0, anchorY: 0 }); self.width = platAsset.width; self.height = platAsset.height; return self; }); // Player class var Player = Container.expand(function () { var self = Container.call(this); var playerAsset = self.attachAsset('player', { anchorX: 0.5, anchorY: 1 }); self.vx = 0; self.vy = 0; self.isOnGround = false; self.width = playerAsset.width; self.height = playerAsset.height; self.update = function () { // Gravity self.vy += 2.5; // Clamp vy if (self.vy > 60) self.vy = 60; self.x += self.vx; self.y += self.vy; // Save last position for collision checks if (self.lastX === undefined) self.lastX = self.x; if (self.lastY === undefined) self.lastY = self.y; }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87ceeb // sky blue }); /**** * Game Code ****/ ; // --- Game variables --- var player; var platforms = []; var coins = []; var enemies = []; var score = 0; var scoreTxt; var dragStartX = null; var dragStartY = null; var jumpQueued = false; // --- Setup game objects --- function setupLevel() { // Player player = new Player(); player.x = 300; player.y = 2000; game.addChild(player); // Platforms var plat1 = new Platform(); plat1.x = 200; plat1.y = 2200; game.addChild(plat1); platforms.push(plat1); var plat2 = new Platform(); plat2.x = 700; plat2.y = 1800; game.addChild(plat2); platforms.push(plat2); var plat3 = new Platform(); plat3.x = 1200; plat3.y = 1500; game.addChild(plat3); platforms.push(plat3); // Coins var coin1 = new Coin(); coin1.x = 750; coin1.y = 1700; game.addChild(coin1); coins.push(coin1); var coin2 = new Coin(); coin2.x = 1250; coin2.y = 1400; game.addChild(coin2); coins.push(coin2); // Enemies var enemy1 = new Enemy(); enemy1.x = 1000; enemy1.y = 2200; game.addChild(enemy1); enemies.push(enemy1); // Score text scoreTxt = new Text2('0', { size: 120, fill: 0xFFF700 }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); scoreTxt.setText(score); } setupLevel(); // --- Controls (touch drag left/right, tap to jump) --- game.down = function (x, y, obj) { dragStartX = x; dragStartY = y; jumpQueued = false; }; game.move = function (x, y, obj) { if (dragStartX !== null) { var dx = x - dragStartX; if (Math.abs(dx) > 30) { player.vx = dx > 0 ? 16 : -16; } else { player.vx = 0; } } }; game.up = function (x, y, obj) { if (dragStartX !== null && Math.abs(x - dragStartX) < 30 && Math.abs(y - dragStartY) < 30) { // Tap: jump jumpQueued = true; } dragStartX = null; dragStartY = null; player.vx = 0; }; // --- Main game loop --- game.update = function () { // Player update player.update(); // Clamp player to screen if (player.x < 0) player.x = 0; if (player.x > 2048) player.x = 2048; // Platform collision player.isOnGround = false; for (var i = 0; i < platforms.length; i++) { var plat = platforms[i]; // Simple AABB collision, only check if falling if (player.vy >= 0 && player.x + player.width / 2 > plat.x && player.x - player.width / 2 < plat.x + plat.width && player.y > plat.y && player.lastY <= plat.y) { // Land on platform player.y = plat.y; player.vy = 0; player.isOnGround = true; } } // Jump if (jumpQueued && player.isOnGround) { player.vy = -48; jumpQueued = false; } // Coin collection for (var i = coins.length - 1; i >= 0; i--) { var coin = coins[i]; if (player.intersects(coin)) { score += 1; scoreTxt.setText(score); coin.destroy(); coins.splice(i, 1); } } // Enemy update and collision for (var i = enemies.length - 1; i >= 0; i--) { var enemy = enemies[i]; enemy.update(); // Remove if off screen if (enemy.x < -200) { enemy.destroy(); enemies.splice(i, 1); continue; } // Player/enemy collision var wasIntersecting = enemy.lastWasIntersecting || false; var isIntersecting = player.intersects(enemy); if (!wasIntersecting && isIntersecting) { // Check if player is falling onto enemy if (player.vy > 0 && player.y < enemy.y) { // Defeat enemy enemy.destroy(); enemies.splice(i, 1); player.vy = -32; // bounce score += 5; scoreTxt.setText(score); } else { // Player hit from side or below: game over LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); return; } } enemy.lastWasIntersecting = isIntersecting; } // Save lastY for player player.lastY = player.y; player.lastX = player.x; };
===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,235 @@
-/****
+/****
+* Classes
+****/
+// Coin class
+var Coin = Container.expand(function () {
+ var self = Container.call(this);
+ var coinAsset = self.attachAsset('coin', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.width = coinAsset.width;
+ self.height = coinAsset.height;
+ self.update = function () {
+ // Optionally animate coin
+ };
+ return self;
+});
+// Enemy class
+var Enemy = Container.expand(function () {
+ var self = Container.call(this);
+ var enemyAsset = self.attachAsset('enemy', {
+ anchorX: 0.5,
+ anchorY: 1
+ });
+ self.vx = -6;
+ self.width = enemyAsset.width;
+ self.height = enemyAsset.height;
+ self.update = function () {
+ self.x += self.vx;
+ if (self.lastX === undefined) self.lastX = self.x;
+ };
+ return self;
+});
+// Platform class
+var Platform = Container.expand(function () {
+ var self = Container.call(this);
+ var platAsset = self.attachAsset('platform', {
+ anchorX: 0,
+ anchorY: 0
+ });
+ self.width = platAsset.width;
+ self.height = platAsset.height;
+ return self;
+});
+// Player class
+var Player = Container.expand(function () {
+ var self = Container.call(this);
+ var playerAsset = self.attachAsset('player', {
+ anchorX: 0.5,
+ anchorY: 1
+ });
+ self.vx = 0;
+ self.vy = 0;
+ self.isOnGround = false;
+ self.width = playerAsset.width;
+ self.height = playerAsset.height;
+ self.update = function () {
+ // Gravity
+ self.vy += 2.5;
+ // Clamp vy
+ if (self.vy > 60) self.vy = 60;
+ self.x += self.vx;
+ self.y += self.vy;
+ // Save last position for collision checks
+ if (self.lastX === undefined) self.lastX = self.x;
+ if (self.lastY === undefined) self.lastY = self.y;
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x87ceeb // sky blue
+});
+
+/****
+* Game Code
+****/
+;
+// --- Game variables ---
+var player;
+var platforms = [];
+var coins = [];
+var enemies = [];
+var score = 0;
+var scoreTxt;
+var dragStartX = null;
+var dragStartY = null;
+var jumpQueued = false;
+// --- Setup game objects ---
+function setupLevel() {
+ // Player
+ player = new Player();
+ player.x = 300;
+ player.y = 2000;
+ game.addChild(player);
+ // Platforms
+ var plat1 = new Platform();
+ plat1.x = 200;
+ plat1.y = 2200;
+ game.addChild(plat1);
+ platforms.push(plat1);
+ var plat2 = new Platform();
+ plat2.x = 700;
+ plat2.y = 1800;
+ game.addChild(plat2);
+ platforms.push(plat2);
+ var plat3 = new Platform();
+ plat3.x = 1200;
+ plat3.y = 1500;
+ game.addChild(plat3);
+ platforms.push(plat3);
+ // Coins
+ var coin1 = new Coin();
+ coin1.x = 750;
+ coin1.y = 1700;
+ game.addChild(coin1);
+ coins.push(coin1);
+ var coin2 = new Coin();
+ coin2.x = 1250;
+ coin2.y = 1400;
+ game.addChild(coin2);
+ coins.push(coin2);
+ // Enemies
+ var enemy1 = new Enemy();
+ enemy1.x = 1000;
+ enemy1.y = 2200;
+ game.addChild(enemy1);
+ enemies.push(enemy1);
+ // Score text
+ scoreTxt = new Text2('0', {
+ size: 120,
+ fill: 0xFFF700
+ });
+ scoreTxt.anchor.set(0.5, 0);
+ LK.gui.top.addChild(scoreTxt);
+ scoreTxt.setText(score);
+}
+setupLevel();
+// --- Controls (touch drag left/right, tap to jump) ---
+game.down = function (x, y, obj) {
+ dragStartX = x;
+ dragStartY = y;
+ jumpQueued = false;
+};
+game.move = function (x, y, obj) {
+ if (dragStartX !== null) {
+ var dx = x - dragStartX;
+ if (Math.abs(dx) > 30) {
+ player.vx = dx > 0 ? 16 : -16;
+ } else {
+ player.vx = 0;
+ }
+ }
+};
+game.up = function (x, y, obj) {
+ if (dragStartX !== null && Math.abs(x - dragStartX) < 30 && Math.abs(y - dragStartY) < 30) {
+ // Tap: jump
+ jumpQueued = true;
+ }
+ dragStartX = null;
+ dragStartY = null;
+ player.vx = 0;
+};
+// --- Main game loop ---
+game.update = function () {
+ // Player update
+ player.update();
+ // Clamp player to screen
+ if (player.x < 0) player.x = 0;
+ if (player.x > 2048) player.x = 2048;
+ // Platform collision
+ player.isOnGround = false;
+ for (var i = 0; i < platforms.length; i++) {
+ var plat = platforms[i];
+ // Simple AABB collision, only check if falling
+ if (player.vy >= 0 && player.x + player.width / 2 > plat.x && player.x - player.width / 2 < plat.x + plat.width && player.y > plat.y && player.lastY <= plat.y) {
+ // Land on platform
+ player.y = plat.y;
+ player.vy = 0;
+ player.isOnGround = true;
+ }
+ }
+ // Jump
+ if (jumpQueued && player.isOnGround) {
+ player.vy = -48;
+ jumpQueued = false;
+ }
+ // Coin collection
+ for (var i = coins.length - 1; i >= 0; i--) {
+ var coin = coins[i];
+ if (player.intersects(coin)) {
+ score += 1;
+ scoreTxt.setText(score);
+ coin.destroy();
+ coins.splice(i, 1);
+ }
+ }
+ // Enemy update and collision
+ for (var i = enemies.length - 1; i >= 0; i--) {
+ var enemy = enemies[i];
+ enemy.update();
+ // Remove if off screen
+ if (enemy.x < -200) {
+ enemy.destroy();
+ enemies.splice(i, 1);
+ continue;
+ }
+ // Player/enemy collision
+ var wasIntersecting = enemy.lastWasIntersecting || false;
+ var isIntersecting = player.intersects(enemy);
+ if (!wasIntersecting && isIntersecting) {
+ // Check if player is falling onto enemy
+ if (player.vy > 0 && player.y < enemy.y) {
+ // Defeat enemy
+ enemy.destroy();
+ enemies.splice(i, 1);
+ player.vy = -32; // bounce
+ score += 5;
+ scoreTxt.setText(score);
+ } else {
+ // Player hit from side or below: game over
+ LK.effects.flashScreen(0xff0000, 1000);
+ LK.showGameOver();
+ return;
+ }
+ }
+ enemy.lastWasIntersecting = isIntersecting;
+ }
+ // Save lastY for player
+ player.lastY = player.y;
+ player.lastX = player.x;
+};
\ No newline at end of file