User prompt
Add maximum fire rate upgrade to 4
User prompt
Adjust the distance between bullets when upgrading bullet count in the MultiBulletUpgradeButton class
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'y')' in this line: 'multiBulletUpgradeButton.y = fireRateUpgradeButton.y + fireRateUpgradeButton.height + 20;' Line Number: 243
User prompt
Delete button in left upper corner
User prompt
Make distance for additional buller upgrade
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'y')' in this line: 'multiBulletUpgradeButton.y = fireRateUpgradeButton.y + fireRateUpgradeButton.height + 20;' Line Number: 241
User prompt
Add multi bullet upgrade button that increases bullet shoot from hero by 1 each upgrade, it spends 5 diamonds
User prompt
When enemy killed by bomb button it increase score
User prompt
Magnet button cooldown for 3 second
User prompt
Move magnet button under bomb button
User prompt
Add magnet button that picks up all coins and diamonds in screen
User prompt
Bomb button cooldown for 5 second
User prompt
Frenzy mode lasts 10 seconds only
User prompt
Frenzy mode has 30second cooldown
User prompt
When enemy died of bomb it should drop either coins or diamonds
User prompt
Add bomb in map when bomb button press then it despawn after 3 sec
User prompt
Bomb lifetime for 3 second
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'x')' in this line: 'bombButton.x = frenzyButton.x;' Line Number: 155
User prompt
Add bomb button under frenzy button that shoot bomb and kill all enemy
User prompt
Frenzy mode increase fire rate and enemy spaen rste
User prompt
Frenzy mode isnt working
User prompt
Display how many diamond u got
User prompt
Add another currency diamond which is rarer to drop than coins
User prompt
Fix Bug: 'ReferenceError: coins is not defined' in this line: 'for (var c = coins.length - 1; c >= 0; c--) {' Line Number: 170
User prompt
Make diamond currency
/**** * 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; }; }); // Diamond class var Diamond = Container.expand(function () { var self = Container.call(this); var diamondGraphics = self.createAsset('diamond', 'Diamond', 0.5, 0.5); self.value = 1; self.speed = 5; self.move = function () { self.y += self.speed; }; 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; }; }); // DiamondsDisplay class var DiamondsDisplay = Container.expand(function () { var self = Container.call(this); var diamondsText = new Text2('Diamonds: 0', { size: 100, fill: "#b9f2ff" }); diamondsText.anchor.set(0.5, 0); self.addChild(diamondsText); self.updateDiamonds = function (totalDiamonds) { diamondsText.setText('Diamonds: ' + totalDiamonds.toString()); }; }); // FireRateUpgradeButton class var FireRateUpgradeButton = Container.expand(function () { var self = Container.call(this); var upgradeButtonGraphics = self.createAsset('fireRateUpgradeButton', 'Fire Rate Upgrade Button', 0.5, 0.5); self.cost = 5; self.on('down', function () { if (totalCoins >= self.cost) { fireRate = Math.max(5, fireRate - 5); totalCoins -= self.cost; coinsDisplay.updateCoins(totalCoins); } }); }); var FrenzyButton = Container.expand(function () { var self = Container.call(this); var frenzyButtonGraphics = self.createAsset('frenzyButton', 'Frenzy Mode Button', 0.5, 0.5); self.isFrenzyActive = false; self.toggleFrenzyMode = function () { if (!self.isFrenzyActive) { self.isFrenzyActive = true; LK.setTimeout(function () { self.isFrenzyActive = false; }, 25000); } }; self.on('down', function () { self.toggleFrenzyMode(); }); }); /**** * Initialize Game ****/ // Create frenzy button instance var game = new LK.Game({ backgroundColor: 0xFFFFFF //Init game with white background }); /**** * Game Code ****/ var fireRateUpgradeButton = game.addChild(new FireRateUpgradeButton()); fireRateUpgradeButton.x = 100; fireRateUpgradeButton.y = 2732 / 2; var frenzyButton = game.addChild(new FrenzyButton()); frenzyButton.x = 2048 - frenzyButton.width / 2 - 100; frenzyButton.y = 2732 / 2; // Initialize important asset arrays, score, coins, and fire rate var bullets = []; var enemies = []; var diamonds = []; // Array to store diamond instances var fireRate = 30; // Initialize fire rate to 30 var totalDiamonds = 0; // Initialize total diamonds collected to 0 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 diamonds display instance var diamondsDisplay = new DiamondsDisplay(); diamondsDisplay.scale.set(0.5, 0.5); LK.gui.top.addChild(diamondsDisplay); diamondsDisplay.y = scoreTxt.height; // Create hero instance var hero = game.addChild(new Hero()); hero.x = 2048 / 2; hero.y = 2732 - hero.height / 2; // Position hero further down 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 diamond when an enemy is destroyed if (diamonds.length < 10) { var newDiamond = new Diamond(); newDiamond.x = enemies[e].x; newDiamond.y = enemies[e].y; diamonds.push(newDiamond); game.addChild(newDiamond); } enemies[e].destroy(); enemies.splice(e, 1); break; } } } // Move and collect coins for (var c = coins.length - 1; c >= 0; c--) { coins[c].move(); if (hero.intersects(diamonds[c])) { // Increment total diamonds collected totalDiamonds += diamonds[c].value; // Update the total diamonds display diamondsDisplay.updateDiamonds(totalDiamonds); diamonds[c].destroy(); diamonds.splice(c, 1); } else if (diamonds[c].y > 2732) { // Remove diamonds that have moved off screen diamonds[c].destroy(); diamonds.splice(c, 1); } } // Spawn enemies var enemySpawnRate = frenzyButton.isFrenzyActive ? 60 : 120; if (LK.ticks % enemySpawnRate == 0) { var newEnemy = new Enemy(); newEnemy.x = Math.random() * 2048; newEnemy.y = -50; enemies.push(newEnemy); game.addChild(newEnemy); } // Hero shooting if (LK.ticks % fireRate == 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.data && obj.event.data.originalEvent.touches && obj.event.data.originalEvent.touches.length > 0) { var touch = obj.event.data.originalEvent.touches[0]; var pos = game.toLocal(new Point(touch.clientX, touch.clientY)); hero.x = pos.x; } });
/****
* 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;
};
});
// Diamond class
var Diamond = Container.expand(function () {
var self = Container.call(this);
var diamondGraphics = self.createAsset('diamond', 'Diamond', 0.5, 0.5);
self.value = 1;
self.speed = 5;
self.move = function () {
self.y += self.speed;
};
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;
};
});
// DiamondsDisplay class
var DiamondsDisplay = Container.expand(function () {
var self = Container.call(this);
var diamondsText = new Text2('Diamonds: 0', {
size: 100,
fill: "#b9f2ff"
});
diamondsText.anchor.set(0.5, 0);
self.addChild(diamondsText);
self.updateDiamonds = function (totalDiamonds) {
diamondsText.setText('Diamonds: ' + totalDiamonds.toString());
};
});
// FireRateUpgradeButton class
var FireRateUpgradeButton = Container.expand(function () {
var self = Container.call(this);
var upgradeButtonGraphics = self.createAsset('fireRateUpgradeButton', 'Fire Rate Upgrade Button', 0.5, 0.5);
self.cost = 5;
self.on('down', function () {
if (totalCoins >= self.cost) {
fireRate = Math.max(5, fireRate - 5);
totalCoins -= self.cost;
coinsDisplay.updateCoins(totalCoins);
}
});
});
var FrenzyButton = Container.expand(function () {
var self = Container.call(this);
var frenzyButtonGraphics = self.createAsset('frenzyButton', 'Frenzy Mode Button', 0.5, 0.5);
self.isFrenzyActive = false;
self.toggleFrenzyMode = function () {
if (!self.isFrenzyActive) {
self.isFrenzyActive = true;
LK.setTimeout(function () {
self.isFrenzyActive = false;
}, 25000);
}
};
self.on('down', function () {
self.toggleFrenzyMode();
});
});
/****
* Initialize Game
****/
// Create frenzy button instance
var game = new LK.Game({
backgroundColor: 0xFFFFFF //Init game with white background
});
/****
* Game Code
****/
var fireRateUpgradeButton = game.addChild(new FireRateUpgradeButton());
fireRateUpgradeButton.x = 100;
fireRateUpgradeButton.y = 2732 / 2;
var frenzyButton = game.addChild(new FrenzyButton());
frenzyButton.x = 2048 - frenzyButton.width / 2 - 100;
frenzyButton.y = 2732 / 2;
// Initialize important asset arrays, score, coins, and fire rate
var bullets = [];
var enemies = [];
var diamonds = []; // Array to store diamond instances
var fireRate = 30; // Initialize fire rate to 30
var totalDiamonds = 0; // Initialize total diamonds collected to 0
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 diamonds display instance
var diamondsDisplay = new DiamondsDisplay();
diamondsDisplay.scale.set(0.5, 0.5);
LK.gui.top.addChild(diamondsDisplay);
diamondsDisplay.y = scoreTxt.height;
// Create hero instance
var hero = game.addChild(new Hero());
hero.x = 2048 / 2;
hero.y = 2732 - hero.height / 2; // Position hero further down 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 diamond when an enemy is destroyed
if (diamonds.length < 10) {
var newDiamond = new Diamond();
newDiamond.x = enemies[e].x;
newDiamond.y = enemies[e].y;
diamonds.push(newDiamond);
game.addChild(newDiamond);
}
enemies[e].destroy();
enemies.splice(e, 1);
break;
}
}
}
// Move and collect coins
for (var c = coins.length - 1; c >= 0; c--) {
coins[c].move();
if (hero.intersects(diamonds[c])) {
// Increment total diamonds collected
totalDiamonds += diamonds[c].value;
// Update the total diamonds display
diamondsDisplay.updateDiamonds(totalDiamonds);
diamonds[c].destroy();
diamonds.splice(c, 1);
} else if (diamonds[c].y > 2732) {
// Remove diamonds that have moved off screen
diamonds[c].destroy();
diamonds.splice(c, 1);
}
}
// Spawn enemies
var enemySpawnRate = frenzyButton.isFrenzyActive ? 60 : 120;
if (LK.ticks % enemySpawnRate == 0) {
var newEnemy = new Enemy();
newEnemy.x = Math.random() * 2048;
newEnemy.y = -50;
enemies.push(newEnemy);
game.addChild(newEnemy);
}
// Hero shooting
if (LK.ticks % fireRate == 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.data && obj.event.data.originalEvent.touches && obj.event.data.originalEvent.touches.length > 0) {
var touch = obj.event.data.originalEvent.touches[0];
var pos = game.toLocal(new Point(touch.clientX, touch.clientY));
hero.x = pos.x;
}
});
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.