User prompt
erase wave
User prompt
decrease enemy speed to slugish
User prompt
every wave only 5 enemies spawn
User prompt
fix spawn enemy
User prompt
every waves just spawn 5 enemys
User prompt
fix enemy numbers
User prompt
enemy movement very low
User prompt
reduce the number of enemies that appear each wave to only 5
User prompt
enemy spawn just 5
User prompt
enemy one hit dead
User prompt
enemy spawn just for
User prompt
one hit death
User prompt
reduce bullet quantity
User prompt
erase bounching
User prompt
bounching bullet
User prompt
bullet super speed
User prompt
reduce quantity of enemy for stability game
User prompt
slow speed enemy
User prompt
multiple direct bullte storm
User prompt
multiple directional shoot
Code edit (1 edits merged)
Please save this source code
User prompt
Fantasy Arena Clash
Initial prompt
make fantasy battle arena with random obstacle
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ var Bullet = Container.expand(function () { var self = Container.call(this); var bulletSprite = self.attachAsset('bullet', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 20; // Increase bullet speed for super speed effect self.damage = 25; self.directionX = 0; self.directionY = 0; self.update = function () { self.x += self.directionX * self.speed; self.y += self.directionY * self.speed; }; return self; }); var Enemy = Container.expand(function () { var self = Container.call(this); var enemySprite = self.attachAsset('enemy', { anchorX: 0.5, anchorY: 0.5 }); self.health = 50; self.speed = 0.5; self.damage = 10; self.attackCooldown = 0; self.update = function () { if (!player) { return; } // Calculate direction to player var dx = player.x - self.x; var dy = player.y - self.y; var distance = Math.sqrt(dx * dx + dy * dy); // Move towards player if (distance > 0) { self.x += dx / distance * self.speed; self.y += dy / distance * self.speed; } // Attack player if close enough and cooldown is done if (distance < 100 && self.attackCooldown <= 0) { if (player.takeDamage(self.damage)) { self.attackCooldown = 60; // 1 second cooldown } } // Decrease attack cooldown if (self.attackCooldown > 0) { self.attackCooldown--; } }; self.takeDamage = function (amount) { self.health -= amount; // Flash red LK.effects.flashObject(self, 0xff0000, 200); if (self.health <= 0) { // Increase score waveManager.killCount++; LK.setScore(LK.getScore() + 10); scoreText.setText("Score: " + LK.getScore()); // Play death sound LK.getSound('enemyDeath').play(); // Remove from enemies array var index = enemies.indexOf(self); if (index !== -1) { enemies.splice(index, 1); } // Destroy the enemy self.destroy(); return true; } return false; }; return self; }); var HealingPool = Container.expand(function () { var self = Container.call(this); var healingSprite = self.attachAsset('healingPool', { anchorX: 0.5, anchorY: 0.5 }); self.type = 'healing'; self.healAmount = 25; self.healCooldown = 0; self.update = function () { if (self.healCooldown > 0) { self.healCooldown--; healingSprite.alpha = 0.5; } else { healingSprite.alpha = 1; } // Heal player if they're in the pool and cooldown is ready if (player && self.healCooldown <= 0 && player.intersects(self)) { player.heal(self.healAmount); self.healCooldown = 180; // 3 seconds } }; return self; }); var Obstacle = Container.expand(function () { var self = Container.call(this); var obstacleSprite = self.attachAsset('obstacle', { anchorX: 0.5, anchorY: 0.5 }); self.type = 'obstacle'; // Default type is blocking obstacle self.update = function () { // No behavior for basic obstacles }; return self; }); var Player = Container.expand(function () { var self = Container.call(this); var playerSprite = self.attachAsset('player', { anchorX: 0.5, anchorY: 0.5 }); self.health = 100; self.maxHealth = 100; self.speed = 5; self.baseSpeed = 5; self.attackCooldown = 0; self.invulnerable = 0; self.update = function () { // Decrease cooldowns if (self.attackCooldown > 0) { self.attackCooldown--; } if (self.invulnerable > 0) { self.invulnerable--; // Flash effect when invulnerable playerSprite.alpha = self.invulnerable % 10 < 5 ? 0.5 : 1; } else { playerSprite.alpha = 1; } }; self.takeDamage = function (amount) { if (self.invulnerable > 0) { return false; } self.health = 0; // Update health bar updateHealthBar(); // Set invulnerability frames self.invulnerable = 60; // 1 second // Play hit sound LK.getSound('playerHit').play(); // Flash red LK.effects.flashObject(self, 0xff0000, 500); return true; }; self.heal = function (amount) { self.health += amount; if (self.health > self.maxHealth) { self.health = self.maxHealth; } // Update health bar updateHealthBar(); // Play powerup sound LK.getSound('powerup').play(); // Flash green LK.effects.flashObject(self, 0x00ff00, 500); }; self.setSpeedBoost = function (duration) { self.speed = self.baseSpeed * 1.5; // Play powerup sound LK.getSound('powerup').play(); // Reset speed after duration LK.setTimeout(function () { self.speed = self.baseSpeed; }, duration); }; return self; }); var SpeedBoost = Container.expand(function () { var self = Container.call(this); var boostSprite = self.attachAsset('speedBoost', { anchorX: 0.5, anchorY: 0.5 }); self.type = 'speed'; self.active = true; self.update = function () { // Provide speed boost when player touches it if (player && self.active && player.intersects(self)) { player.setSpeedBoost(5000); // 5 seconds // Deactivate and remove self.active = false; // Remove from obstacles array var index = obstacles.indexOf(self); if (index !== -1) { obstacles.splice(index, 1); } self.destroy(); } // Pulse animation if (self.active) { var pulse = 0.8 + 0.2 * Math.sin(LK.ticks / 10); boostSprite.scale.set(pulse, pulse); } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x2c3e50 }); /**** * Game Code ****/ // Game state variables var player = null; var bullets = []; var enemies = []; var obstacles = []; var dragTarget = null; var isAttacking = false; var attackDirection = { x: 0, y: 0 }; var healthBar = null; var healthBarBg = null; var scoreText = null; var waveText = null; // Wave manager var waveManager = { currentWave: 1, enemiesPerWave: 5, enemiesRemaining: 0, killCount: 0, waveDelay: 180, // 3 seconds delayCounter: 0, waveInProgress: false, startWave: function startWave() { this.enemiesRemaining = Math.floor(this.currentWave * this.enemiesPerWave * 0.7); // Reduce enemy count by 30% this.killCount = 0; this.waveInProgress = true; // Update wave text waveText.setText("Wave: " + this.currentWave); // Spawn initial enemies this.spawnEnemies(5); // Create new obstacles createObstacles(); }, spawnEnemies: function spawnEnemies(count) { for (var i = 0; i < count; i++) { if (this.enemiesRemaining <= 0) { break; } var enemy = new Enemy(); // Position enemy at edge of screen var side = Math.floor(Math.random() * 4); switch (side) { case 0: // Top enemy.x = Math.random() * 2048; enemy.y = -50; break; case 1: // Right enemy.x = 2048 + 50; enemy.y = Math.random() * 2732; break; case 2: // Bottom enemy.x = Math.random() * 2048; enemy.y = 2732 + 50; break; case 3: // Left enemy.x = -50; enemy.y = Math.random() * 2732; break; } // Scale difficulty with wave enemy.health = 50 + (this.currentWave - 1) * 10; enemy.speed = 1 + (this.currentWave - 1) * 0.1; game.addChild(enemy); enemies.push(enemy); this.enemiesRemaining--; } }, update: function update() { if (!this.waveInProgress) { this.delayCounter++; if (this.delayCounter >= this.waveDelay) { this.currentWave++; this.startWave(); this.delayCounter = 0; } return; } // Check if wave is complete if (enemies.length === 0 && this.enemiesRemaining <= 0) { this.waveInProgress = false; this.delayCounter = 0; } // Spawn more enemies if there's space and enemies remaining if (enemies.length < 10 && this.enemiesRemaining > 0) { this.spawnEnemies(1); } } }; // Initialize game function initGame() { // Create player player = new Player(); player.x = 2048 / 2; player.y = 2732 / 2; game.addChild(player); // Create health bar background healthBarBg = LK.getAsset('obstacle', { anchorX: 0, anchorY: 0, width: 300, height: 30, tint: 0x333333 }); // Create health bar healthBar = LK.getAsset('obstacle', { anchorX: 0, anchorY: 0, width: 300, height: 30, tint: 0x2ecc71 }); // Create score text scoreText = new Text2("Score: 0", { size: 40, fill: 0xFFFFFF }); scoreText.anchor.set(1, 0); // Create wave text waveText = new Text2("Wave: 1", { size: 40, fill: 0xFFFFFF }); waveText.anchor.set(0, 0); // Add UI elements to GUI LK.gui.topRight.addChild(scoreText); LK.gui.top.addChild(waveText); LK.gui.bottomLeft.addChild(healthBarBg); LK.gui.bottomLeft.addChild(healthBar); // Position health bar healthBarBg.x = 20; healthBarBg.y = -50; healthBar.x = 20; healthBar.y = -50; // Position score text scoreText.x = -20; scoreText.y = 20; // Position wave text waveText.x = 0; waveText.y = 20; // Reset score LK.setScore(0); // Spawn 5 enemies at the start of the game waveManager.spawnEnemies(5); // Play background music LK.playMusic('battleMusic'); } // Update health bar display function updateHealthBar() { if (player && healthBar) { var healthPercent = player.health / player.maxHealth; healthBar.width = 300 * healthPercent; // Change color based on health if (healthPercent > 0.6) { healthBar.tint = 0x2ecc71; // Green } else if (healthPercent > 0.3) { healthBar.tint = 0xf39c12; // Orange } else { healthBar.tint = 0xe74c3c; // Red } } } // Create obstacles for the current wave function createObstacles() { // Clear existing obstacles for (var i = obstacles.length - 1; i >= 0; i--) { game.removeChild(obstacles[i]); obstacles[i].destroy(); } obstacles = []; // Number of obstacles based on wave var numObstacles = 3 + Math.min(5, waveManager.currentWave); var numHealingPools = 1 + Math.floor(waveManager.currentWave / 3); var numSpeedBoosts = Math.floor(waveManager.currentWave / 2); // Create regular obstacles for (var i = 0; i < numObstacles; i++) { var obstacle = new Obstacle(); placeObstacleRandomly(obstacle); game.addChild(obstacle); obstacles.push(obstacle); } // Create healing pools for (var i = 0; i < numHealingPools; i++) { var healingPool = new HealingPool(); placeObstacleRandomly(healingPool); game.addChild(healingPool); obstacles.push(healingPool); } // Create speed boosts for (var i = 0; i < numSpeedBoosts; i++) { var speedBoost = new SpeedBoost(); placeObstacleRandomly(speedBoost); game.addChild(speedBoost); obstacles.push(speedBoost); } } // Place obstacle at a random position that doesn't overlap with player function placeObstacleRandomly(obstacle) { var positioned = false; var attempts = 0; while (!positioned && attempts < 20) { obstacle.x = 100 + Math.random() * (2048 - 200); obstacle.y = 100 + Math.random() * (2732 - 200); // Check if too close to player var dx = obstacle.x - player.x; var dy = obstacle.y - player.y; var distToPlayer = Math.sqrt(dx * dx + dy * dy); // Check if overlapping with other obstacles var overlapping = false; for (var i = 0; i < obstacles.length; i++) { if (obstacle.intersects(obstacles[i])) { overlapping = true; break; } } if (distToPlayer > 300 && !overlapping) { positioned = true; } attempts++; } } // Fire a bullet in the given direction function fireBullet(dirX, dirY) { if (player.attackCooldown > 0) { return; } // Normalize direction var length = Math.sqrt(dirX * dirX + dirY * dirY); if (length > 0) { dirX /= length; dirY /= length; } var bullet = new Bullet(); bullet.x = player.x; bullet.y = player.y; bullet.directionX = dirX; bullet.directionY = dirY; game.addChild(bullet); bullets.push(bullet); // Set attack cooldown player.attackCooldown = 15; // 0.25 seconds // Play attack sound LK.getSound('playerAttack').play(); } // Handle player movement with the specified dx, dy direction function movePlayer(dx, dy) { if (!player) { return; } // Normalize direction var length = Math.sqrt(dx * dx + dy * dy); if (length > 0) { dx /= length; dy /= length; } // Calculate new position var newX = player.x + dx * player.speed; var newY = player.y + dy * player.speed; // Check boundaries if (newX < 40) { newX = 40; } if (newX > 2048 - 40) { newX = 2048 - 40; } if (newY < 40) { newY = 40; } if (newY > 2732 - 40) { newY = 2732 - 40; } // Check obstacle collision var canMoveX = true; var canMoveY = true; for (var i = 0; i < obstacles.length; i++) { var obstacle = obstacles[i]; // Only check collision with blocking obstacles if (obstacle.type === 'obstacle') { // Check if moving in X direction would cause collision var tempPlayer = { x: newX, y: player.y, width: player.width, height: player.height }; if (intersectsSimple(tempPlayer, obstacle)) { canMoveX = false; } // Check if moving in Y direction would cause collision tempPlayer = { x: player.x, y: newY, width: player.width, height: player.height }; if (intersectsSimple(tempPlayer, obstacle)) { canMoveY = false; } } } // Apply movement if (canMoveX) { player.x = newX; } if (canMoveY) { player.y = newY; } } // Simple intersection check for collision detection function intersectsSimple(objA, objB) { return !(objA.x + objA.width / 2 < objB.x - objB.width / 2 || objA.x - objA.width / 2 > objB.x + objB.width / 2 || objA.y + objA.height / 2 < objB.y - objB.height / 2 || objA.y - objA.height / 2 > objB.y + objB.height / 2); } // Movement input handlers for drag controls game.down = function (x, y, obj) { dragTarget = { x: x, y: y }; isAttacking = false; }; game.move = function (x, y, obj) { if (dragTarget) { // Calculate drag distance and direction var dx = x - dragTarget.x; var dy = y - dragTarget.y; var distance = Math.sqrt(dx * dx + dy * dy); // If drag is long enough, it's an attack if (distance > 100) { isAttacking = true; attackDirection.x = dx / distance; attackDirection.y = dy / distance; // Fire bullets in multiple directions fireBullet(attackDirection.x, attackDirection.y); fireBullet(-attackDirection.x, -attackDirection.y); } else { isAttacking = false; // Otherwise it's movement if (distance > 5) { movePlayer(dx, dy); } } } }; game.up = function (x, y, obj) { if (isAttacking) { fireBullet(attackDirection.x, attackDirection.y); } dragTarget = null; isAttacking = false; }; // Main game update function game.update = function () { // Skip updates if player is dead if (player && player.health <= 0) { LK.showGameOver(); return; } // Update wave manager waveManager.update(); // Update player if (player) { player.update(); } // Update bullets for (var i = bullets.length - 1; i >= 0; i--) { var bullet = bullets[i]; bullet.update(); // Check collision with enemies for (var j = enemies.length - 1; j >= 0; j--) { var enemy = enemies[j]; if (bullet.intersects(enemy)) { enemy.takeDamage(enemy.health); // One-hit death // Remove bullet bullet.destroy(); bullets.splice(i, 1); break; } } // Check collision with obstacles for (var j = 0; j < obstacles.length; j++) { var obstacle = obstacles[j]; // Only check collision with blocking obstacles if (obstacle.type === 'obstacle' && bullet.intersects(obstacle)) { // Remove bullet bullet.destroy(); bullets.splice(i, 1); break; } } } // Update enemies for (var i = 0; i < enemies.length; i++) { var enemy = enemies[i]; enemy.update(); } // Update obstacles for (var i = 0; i < obstacles.length; i++) { var obstacle = obstacles[i]; obstacle.update(); } }; // Initialize the game initGame();
===================================================================
--- original.js
+++ change.js
@@ -251,9 +251,9 @@
this.waveInProgress = true;
// Update wave text
waveText.setText("Wave: " + this.currentWave);
// Spawn initial enemies
- this.spawnEnemies(Math.min(5, this.enemiesRemaining));
+ this.spawnEnemies(5);
// Create new obstacles
createObstacles();
},
spawnEnemies: function spawnEnemies(count) {
top down defend scifi strong hold. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
top down scifi image military slugish tank. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
brutal fire explosion. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
dark brown top down wide meadow. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows