User prompt
Not too much
User prompt
Why the coins not spawning
User prompt
Fix Bug: 'ReferenceError: Enemy is not defined' in this line: 'var newEnemy = new Enemy();' Line Number: 182
User prompt
Replace the spawning normal enemy with enemy
User prompt
Reset back all enemy types
User prompt
Fix Bug: 'TypeError: enemyType is not a constructor' in this line: 'var newEnemy = new enemyType();' Line Number: 192
User prompt
Fix Bug: 'ReferenceError: NormalEnemy is not defined' in this line: 'var enemyType = Math.random() > 0.5 ? NormalEnemy : FastEnemy;' Line Number: 182
User prompt
Fix Bug: 'ReferenceError: NormalEnemy is not defined' in this line: 'var enemyType = Math.random() > 0.5 ? NormalEnemy : FastEnemy;' Line Number: 182
User prompt
Change back to normal enemy
User prompt
Fix Bug: 'ReferenceError: NormalEnemy is not defined' in this line: 'var enemyType = Math.random() > 0.5 ? FastEnemy : NormalEnemy;' Line Number: 182
User prompt
Make both types of enemy spawn
User prompt
Fix Bug: 'ReferenceError: Enemy is not defined' in this line: 'var newEnemy = new Enemy();' Line Number: 182
User prompt
Make another type of enemy that has faster movement than normal one
User prompt
Change coin earning upgrade to coin spawn average instead
User prompt
Make coin upgrade button increases the coin you obtain everytime u click coin
User prompt
Make frenzy button also increase coin spawn rate
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'width')' in this line: 'upgradesTxt.x = LK.gui.left.x + fireRateUpgradeButton.width / 2 + 100;' Line Number: 218
User prompt
Add text that says 'Upgrades' above the 2 upgrade button
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'width')' in this line: 'coinEarningUpgradeButton.x = LK.gui.left.x + fireRateUpgradeButton.width + 200;' Line Number: 214
User prompt
Make coins earning upgrade button that increases coins earning when clicking a coin by 1 for 10 coins
User prompt
More right pls
User prompt
Move frenzy button to right
User prompt
Put frenzy button in same height of fire rate button
User prompt
Put frenzy button to right screen part
User prompt
Put fire rate upgrade button to left screen part
/**** * Classes ****/ // Hero class var Hero = Container.expand(function () { var self = Container.call(this); var heroGraphics = self.createAsset('hero', 'Hero character', 0.5, 0.5); self.fireRateLevel = 0; // Initialize hero's fire rate level self.shoot = function () { // Shooting logic will be implemented in the game logic section }; self.update = function () { // Update logic for the hero, if needed }; }); // Bullet class var Bullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.createAsset('bullet', 'Hero Bullet', 0.5, 0.5); self.speed = -10; self.move = function () { self.y += self.speed; }; }); // FastEnemy class var FastEnemy = Container.expand(function () { var self = Container.call(this); var fastEnemyGraphics = self.createAsset('fastEnemy', 'Fast Enemy character', 0.5, 0.5); self.speed = 4; // Faster speed than the normal enemy self.move = function () { self.y += self.speed; }; }); // FrenzyButton class var FrenzyButton = Container.expand(function () { var self = Container.call(this); var buttonGraphics = self.createAsset('frenzyButton', 'Frenzy Mode Button', 0.5, 0.5); self.cooldown = false; self.activateFrenzy = function () { if (!self.cooldown) { game.frenzyMode = true; LK.setTimeout(function () { game.frenzyMode = false; }, 5000); // Frenzy mode lasts for 5 seconds self.cooldown = true; LK.setTimeout(function () { self.cooldown = false; }, 30000); // 30 second cooldown } }; self.on('down', function () { self.activateFrenzy(); }); }); // Coin class var Coin = Container.expand(function () { var self = Container.call(this); var coinGraphics = self.createAsset('coin', 'Game Coin', 0.5, 0.5); self.value = 1; // Default value, can be increased by shop upgrades self.collect = function () { var coinValue = game.frenzyMode ? self.value * 2 : self.value; game.coins += coinValue; coinTxt.setText(game.coins.toString()); // Update the coin display text self.destroy(); }; self.on('down', function () { self.collect(); }); }); // FireRateUpgradeButton class var FireRateUpgradeButton = Container.expand(function () { var self = Container.call(this); var buttonGraphics = self.createAsset('fireRateUpgradeButton', 'Fire Rate Upgrade Button', 0.5, 0.5); self.on('down', function () { if (game.coins >= 5) { game.coins -= 5; hero.fireRateLevel += 1; coinTxt.setText(game.coins.toString()); } }); }); // CoinSpawnAverageButton class var CoinSpawnAverageButton = Container.expand(function () { var self = Container.call(this); var buttonGraphics = self.createAsset('coinSpawnAverageButton', 'Coin Spawn Average Button', 0.5, 0.5); self.on('down', function () { if (game.coins >= 10) { game.coins -= 10; game.coinSpawnAverage = Math.max(100, game.coinSpawnAverage - 50); coinTxt.setText(game.coins.toString()); } }); }); /**** * Initialize Game ****/ // Create fire rate upgrade button instance // Create frenzy button instance // Create frenzy button instance var game = new LK.Game({ backgroundColor: 0xFFFFFF, // Init game with white background frenzyMode: false, // Track frenzy mode status coinSpawnAverage: 300 // Initialize coin spawn average }); /**** * Game Code ****/ // Create fire rate upgrade button instance var fireRateUpgradeButton = game.addChild(new FireRateUpgradeButton()); fireRateUpgradeButton.x = LK.gui.left.x + 100; fireRateUpgradeButton.y = LK.gui.bottom.y - 100; game.coins = 0; // Initialize coins as a number before creating coinTxt // Initialize important asset arrays and score var bullets = []; var enemies = []; var score = 0; // Create score display var scoreTxt = new Text2(score.toString(), { size: 150, fill: "#000000" }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Create coin display var coinTxt = new Text2(game.coins.toString(), { size: 100, fill: "#ffd700" }); coinTxt.anchor.set(0.5, 0); coinTxt.y = scoreTxt.height + 20; // Position below the score display LK.gui.top.addChild(coinTxt); // Create hero instance var hero = game.addChild(new Hero()); hero.x = 2048 / 2; hero.y = 2732 - 100; // Position hero near the bottom of the screen // Game tick event LK.on('tick', function () { // Move bullets for (var i = bullets.length - 1; i >= 0; i--) { bullets[i].move(); if (bullets[i].y < 0) { bullets[i].destroy(); bullets.splice(i, 1); } } // Move enemies for (var j = enemies.length - 1; j >= 0; j--) { enemies[j].move(); if (enemies[j].y > 2732) { LK.showGameOver(); } } // Check for bullet-enemy collisions for (var b = bullets.length - 1; b >= 0; b--) { for (var e = enemies.length - 1; e >= 0; e--) { if (bullets[b].intersects(enemies[e])) { // Increase score and update display score++; scoreTxt.setText(score.toString()); bullets[b].destroy(); bullets.splice(b, 1); enemies[e].destroy(); enemies.splice(e, 1); break; } } } // Spawn coins based on coinSpawnAverage property if (LK.ticks % game.coinSpawnAverage == 0) { var newCoin = new Coin(); newCoin.x = Math.random() * 2048; newCoin.y = Math.random() * (2732 - 100); game.addChild(newCoin); } // Spawn enemies var enemySpawnRate = game.frenzyMode ? 30 : 60; // Increased spawn rate during frenzy if (LK.ticks % enemySpawnRate == 0) { var enemyType = Math.random() > 0.5 ? FastEnemy : NormalEnemy; var newEnemy = new enemyType(); newEnemy.x = Math.random() * 2048; newEnemy.y = -50; enemies.push(newEnemy); game.addChild(newEnemy); } // Hero shooting var bulletSpawnRate = game.frenzyMode ? 15 : 30 - hero.fireRateLevel * 5; // Increased spawn rate during frenzy and further increased by hero's fire rate level if (LK.ticks % bulletSpawnRate == 0) { var newBullet = new Bullet(); newBullet.x = hero.x; newBullet.y = hero.y; bullets.push(newBullet); game.addChild(newBullet); } // Update hero hero.update(); }); // Touch event to move hero game.on('down', function (obj) { var pos = obj.event.getLocalPosition(game); hero.x = pos.x; }); // Ensure the game is touchscreen compatible game.on('move', function (obj) { if (obj.event.touches && obj.event.touches.length > 0) { var touch = obj.event.touches[0]; var pos = touch.getLocalPosition(game); hero.x = pos.x; } }); // Create frenzy button instance var frenzyButton = game.addChild(new FrenzyButton()); frenzyButton.x = LK.gui.right.x - frenzyButton.width / 2; frenzyButton.y = LK.gui.bottom.y - 100; // Create 'Upgrades' text display var upgradesTxt = new Text2('Upgrades', { size: 100, fill: "#ffffff" }); upgradesTxt.anchor.set(0.5, 0); upgradesTxt.x = fireRateUpgradeButton.x + fireRateUpgradeButton.width / 2 + 100; upgradesTxt.y = LK.gui.bottom.y - 200; LK.gui.top.addChild(upgradesTxt); // Create fire rate upgrade button instance var fireRateUpgradeButton = game.addChild(new FireRateUpgradeButton()); fireRateUpgradeButton.x = LK.gui.left.x + 100; fireRateUpgradeButton.y = LK.gui.bottom.y - 100; // Create coin spawn average button instance var coinSpawnAverageButton = game.addChild(new CoinSpawnAverageButton()); coinSpawnAverageButton.x = LK.gui.left.x + fireRateUpgradeButton.width + 200; coinSpawnAverageButton.y = LK.gui.bottom.y - 100;
===================================================================
--- original.js
+++ change.js
@@ -176,11 +176,12 @@
newCoin.y = Math.random() * (2732 - 100);
game.addChild(newCoin);
}
// Spawn enemies
- var enemySpawnRate = game.frenzyMode ? 60 : 120; // Increased spawn rate during frenzy
+ var enemySpawnRate = game.frenzyMode ? 30 : 60; // Increased spawn rate during frenzy
if (LK.ticks % enemySpawnRate == 0) {
- var newEnemy = new FastEnemy();
+ var enemyType = Math.random() > 0.5 ? FastEnemy : NormalEnemy;
+ var newEnemy = new enemyType();
newEnemy.x = Math.random() * 2048;
newEnemy.y = -50;
enemies.push(newEnemy);
game.addChild(newEnemy);
Coin. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Fighter jet. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Has rocket behind to boost movement to down faster
Explosion. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Medkit. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.