User prompt
oyunun başında bir düşman olsun ve her düşman öldürdüğümüzde yeni bir düşman çıksın
User prompt
etrafta belirli aralıklarla spawn olan düşmanları öldürebileceğimiz bir oyuncu yarat ve ekranın ortasına koy
User prompt
Spawn Hunter
Initial prompt
etrafta belirli aralıklarla spawn olan düşmanları öldürdüğümüz bir oyun
/**** * Classes ****/ var Bullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.attachAsset('bullet', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 10; self.lifespan = 120; // 2 seconds at 60fps self.update = function () { // Move in direction of rotation self.x += Math.cos(self.rotation) * self.speed; self.y += Math.sin(self.rotation) * self.speed; // Check for collisions with enemies for (var i = enemies.length - 1; i >= 0; i--) { var enemy = enemies[i]; if (self.intersects(enemy)) { enemy.takeDamage(1); self.destroy(); var index = bullets.indexOf(self); if (index > -1) { bullets.splice(index, 1); } return; } } // Bullet lifespan self.lifespan--; if (self.lifespan <= 0 || self.x < 0 || self.x > 2048 || self.y < 0 || self.y > 2732) { self.destroy(); var index = bullets.indexOf(self); if (index > -1) { bullets.splice(index, 1); } } }; return self; }); // Set background color var Enemy = Container.expand(function () { var self = Container.call(this); var enemyGraphics = self.attachAsset('enemy', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 2 + Math.random() * 1.5; self.health = 1; self.lastWasIntersecting = false; self.update = function () { // Move toward player var dx = player.x - self.x; var dy = player.y - self.y; var dist = Math.sqrt(dx * dx + dy * dy); if (dist > 0) { self.x += dx / dist * self.speed; self.y += dy / dist * self.speed; } // Check collision with player var isIntersecting = self.intersects(player); if (!self.lastWasIntersecting && isIntersecting) { player.takeDamage(10); self.destroy(); var index = enemies.indexOf(self); if (index > -1) { enemies.splice(index, 1); } } self.lastWasIntersecting = isIntersecting; }; self.takeDamage = function (amount) { self.health -= amount; if (self.health <= 0) { LK.getSound('explosion').play(); LK.effects.flashObject(self, 0xFFFFFF, 100); self.destroy(); var index = enemies.indexOf(self); if (index > -1) { enemies.splice(index, 1); } LK.setScore(LK.getScore() + 10); } }; return self; }); var Player = Container.expand(function () { var self = Container.call(this); var playerGraphics = self.attachAsset('player', { anchorX: 0.5, anchorY: 0.5 }); self.health = 100; self.rotation = 0; self.shootCooldown = 0; self.update = function () { if (self.shootCooldown > 0) { self.shootCooldown--; } }; self.shoot = function () { if (self.shootCooldown <= 0) { var bullet = new Bullet(); bullet.x = self.x; bullet.y = self.y; bullet.rotation = self.rotation; game.addChild(bullet); bullets.push(bullet); LK.getSound('shoot').play(); self.shootCooldown = 10; // Cooldown between shots } }; self.takeDamage = function (amount) { self.health -= amount; LK.effects.flashObject(self, 0xFF0000, 300); if (self.health <= 0) { LK.effects.flashScreen(0xFF0000, 1000); LK.showGameOver(); } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ // Set background color game.setBackgroundColor(0x2c3e50); // Game variables var player; var enemies = []; var bullets = []; var spawnTimer = 0; var spawnInterval = 120; // Start with 2 seconds between spawns var spawnDistance = 800; // Distance from center to spawn enemies var aimDirection = 0; var score = 0; // Create player in center of screen player = new Player(); player.x = 2048 / 2; player.y = 2732 / 2; game.addChild(player); // Spawn an initial enemy at the start of the game spawnEnemy(); // Create score text var scoreText = new Text2('Score: 0', { size: 60, fill: 0xFFFFFF }); scoreText.anchor.set(0, 0); LK.gui.topLeft.addChild(scoreText); scoreText.x = 110; // Keep away from top left 100x100 area // Handle touch/click input for aiming and shooting game.down = function (x, y, obj) { // Calculate angle between player and touch point var dx = x - player.x; var dy = y - player.y; player.rotation = Math.atan2(dy, dx); // Shoot player.shoot(); }; game.move = function (x, y, obj) { // Update aim direction when moving touch/mouse var dx = x - player.x; var dy = y - player.y; player.rotation = Math.atan2(dy, dx); }; game.up = function (x, y, obj) { // Could add additional logic here }; // Spawn enemy at random position around the player function spawnEnemy() { var angle = Math.random() * Math.PI * 2; var enemy = new Enemy(); // Position enemy in a circle around the player enemy.x = player.x + Math.cos(angle) * spawnDistance; enemy.y = player.y + Math.sin(angle) * spawnDistance; game.addChild(enemy); enemies.push(enemy); // Increase difficulty if (spawnInterval > 30) { spawnInterval -= 0.5; } } // Game update loop game.update = function () { // Update player player.update(); // Update bullets for (var i = bullets.length - 1; i >= 0; i--) { bullets[i].update(); } // Update enemies for (var i = enemies.length - 1; i >= 0; i--) { enemies[i].update(); } // Spawn enemies spawnTimer++; if (spawnTimer >= spawnInterval) { spawnEnemy(); spawnTimer = 0; } // Update score display scoreText.setText('Score: ' + LK.getScore()); };
===================================================================
--- original.js
+++ change.js
@@ -146,8 +146,10 @@
player = new Player();
player.x = 2048 / 2;
player.y = 2732 / 2;
game.addChild(player);
+// Spawn an initial enemy at the start of the game
+spawnEnemy();
// Create score text
var scoreText = new Text2('Score: 0', {
size: 60,
fill: 0xFFFFFF