User prompt
No i mean left
User prompt
Put frenzy button in right part screen
User prompt
Add frenzy button that increases fire rate and enemy spawn rate
User prompt
Increase coin movespeed
User prompt
Make coin value display instead of increasing score when collecting coin
User prompt
Shrink and move it under score display
User prompt
Add coins display
User prompt
Nevermind
User prompt
Display how many total coin u got from collecting
User prompt
Make coin value display instead of increasing score when collecting coin
User prompt
Why does coin not move
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'getLocalPosition')' in this line: 'var pos = obj.event.data.getLocalPosition(game);' Line Number: 147
User prompt
Why doesnt it move
User prompt
Make coin move to same direction as enemy
User prompt
Limit coin in screen to 10
User prompt
Add coin as currency
User prompt
Brighter screen
User prompt
Reset game as first time it was created
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'x')' in this line: 'upgradesTxt.x = fireRateUpgradeButton.x + fireRateUpgradeButton.width / 2 + 100;' Line Number: 219
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'toString')' in this line: 'var coinTxt = new Text2(game.coins.toString(), {' Line Number: 122
User prompt
Fix Bug: 'Uncaught ReferenceError: score is not defined' in this line: 'var scoreTxt = new Text2(score.toString(), {' Line Number: 114
User prompt
Reset all
User prompt
Reset coins
User prompt
Fix Bug: 'Cannot read properties of undefined (reading 'x')' in this line: 'upgradesTxt.x = fireRateUpgradeButton.x + fireRateUpgradeButton.width / 2 + 100;' Line Number: 220
User prompt
Reset the coin spawning rate as first time
/**** * 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.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; }; }); // Coin class var Coin = Container.expand(function () { var self = Container.call(this); var coinGraphics = self.createAsset('coin', 'Coin', 0.5, 0.5); self.value = 1; self.collect = function () { // Collection logic will be implemented in the game logic section }; }); // Enemy class var Enemy = Container.expand(function () { var self = Container.call(this); var enemyGraphics = self.createAsset('enemy', 'Enemy character', 0.5, 0.5); self.speed = 2; self.move = function () { self.y += self.speed; }; }); /**** * 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 }); /**** * Game Code ****/ // Initialize important asset arrays, score, and coins var bullets = []; var enemies = []; var coins = []; // Array to store coin instances var score = 0; // Initialize score to 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 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); // Spawn a coin when an enemy is destroyed if (coins.length < 10) { var newCoin = new Coin(); newCoin.x = enemies[e].x; newCoin.y = enemies[e].y; coins.push(newCoin); game.addChild(newCoin); } enemies[e].destroy(); enemies.splice(e, 1); break; } } } // Collect coins for (var c = coins.length - 1; c >= 0; c--) { if (hero.intersects(coins[c])) { // Increase score by coin value and update display score += coins[c].value; scoreTxt.setText(score.toString()); coins[c].destroy(); coins.splice(c, 1); } } // Spawn enemies if (LK.ticks % 120 == 0) { var newEnemy = new Enemy(); newEnemy.x = Math.random() * 2048; newEnemy.y = -50; enemies.push(newEnemy); game.addChild(newEnemy); } // Hero shooting if (LK.ticks % 30 == 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; } });
===================================================================
--- original.js
+++ change.js
@@ -95,13 +95,15 @@
scoreTxt.setText(score.toString());
bullets[b].destroy();
bullets.splice(b, 1);
// Spawn a coin when an enemy is destroyed
- var newCoin = new Coin();
- newCoin.x = enemies[e].x;
- newCoin.y = enemies[e].y;
- coins.push(newCoin);
- game.addChild(newCoin);
+ if (coins.length < 10) {
+ var newCoin = new Coin();
+ newCoin.x = enemies[e].x;
+ newCoin.y = enemies[e].y;
+ coins.push(newCoin);
+ game.addChild(newCoin);
+ }
enemies[e].destroy();
enemies.splice(e, 1);
break;
}
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.