Code edit (1 edits merged)
Please save this source code
User prompt
Create a sprite sheet for me in this shooting game the theme is sci-fi space
User prompt
Please fix the bug: 'ReferenceError: score is not defined' in or related to this line: 'score += 100;' Line Number: 263
User prompt
Show kills instead of score
User prompt
Remove current
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: LK.showggwon is not a function' in or related to this line: 'LK.showggwon();' Line Number: 299
Code edit (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: LK.heyyouwon is not a function' in or related to this line: 'LK.heyyouwon();' Line Number: 299
Code edit (1 edits merged)
Please save this source code
User prompt
The turrent should not kill the player when epwaning it
User prompt
You should earn 100 score for a kill
User prompt
Make a current which will cost 200 score and will shoot those bullets for you
User prompt
It is still small
User prompt
Increase the size of enemy bullet
User prompt
Enemy bullet size increase
User prompt
Enemy bullet size increase
User prompt
Please fix the bug: 'Uncaught TypeError: Graphics is not a constructor' in or related to this line: 'var verticalLine = new Graphics();' Line Number: 130
User prompt
Make an imaginary grid which should be only visible to me
User prompt
After 40sec in the clock make it half of the enemy come near the hear. To make game a little harder
User prompt
Remove boss
User prompt
Show ammo as herobullet left
User prompt
And show how many bullets left as ammo
User prompt
Hero can shoot only six bullets then he have to wait 2 sec
User prompt
Bullet size smaller
/**** * Classes ****/ var Boss = Container.expand(function () { var self = Container.call(this); var bossGraphics = self.attachAsset('boss', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 2; self.health = 200; self.update = function () { self.y += self.speed; if (self.y > 2732) { self.destroy(); } }; self.takeDamage = function (damage) { self.health -= damage; if (self.health <= 0) { self.destroy(); } }; }); // Enemy class var Enemy = Container.expand(function () { var self = Container.call(this); var enemyGraphics = self.attachAsset('enemy', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.update = function () { self.y += self.speed; if (self.y > 2732) { self.destroy(); } }; }); // EnemyBullet class var EnemyBullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.attachAsset('enemyBullet', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 10; self.update = function () { self.y += self.speed; if (self.y > 2732) { self.destroy(); } }; }); //<Assets used in the game will automatically appear here> // Hero class var Hero = Container.expand(function () { var self = Container.call(this); var heroGraphics = self.attachAsset('hero', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 10; self.update = function () { // Update logic for hero }; self.shoot = function () { if (heroBullets.length < 6) { var bullet = new HeroBullet(); bullet.x = self.x; bullet.y = self.y; game.addChild(bullet); heroBullets.push(bullet); ammoTxt.setText('Ammo: ' + (6 - heroBullets.length)); } else { if (!self.reloading) { self.reloading = true; var reloadText = new Text2('Reloading...', { size: 50, fill: "#ffffff" }); reloadText.anchor.set(0.5, 0.5); reloadText.x = self.x; reloadText.y = self.y - 100; game.addChild(reloadText); LK.setTimeout(function () { self.reloading = false; heroBullets = []; ammoTxt.setText('Ammo: 6'); game.removeChild(reloadText); }, 2000); } } }; }); // HeroBullet class var HeroBullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.attachAsset('heroBullet', { anchorX: 0.5, anchorY: 0.5 }); self.speed = -10; self.update = function () { self.y += self.speed; if (self.y < 0) { self.destroy(); } }; }); var ShootButton = Container.expand(function () { var self = Container.call(this); var buttonGraphics = self.attachAsset('shootButton', { anchorX: 0.5, anchorY: 0.5 }); self.down = function (x, y, obj) { hero.shoot(); }; self.containsPoint = function (point) { var localPoint = self.toLocal(point); return localPoint.x >= -self.width / 2 && localPoint.x <= self.width / 2 && localPoint.y >= -self.height / 2 && localPoint.y <= self.height / 2; }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 //Init game with black background }); /**** * Game Code ****/ // Initialize arrays and variables // Update hero bullets var heroBullets = []; if (heroBullets && heroBullets.length) { for (var i = heroBullets.length - 1; i >= 0; i--) { heroBullets[i].update(); if (bossSpawned && heroBullets[i].intersects(boss)) { boss.takeDamage(10); // Reduce boss health by 10 if (boss.health <= 0) { score += 100; scoreTxt.setText('Score: ' + score); bossSpawned = false; } heroBullets[i].destroy(); // Destroy the bullet after hitting the boss heroBullets.splice(i, 1); continue; } for (var j = enemies.length - 1; j >= 0; j--) { if (heroBullets[i].intersects(enemies[j])) { enemies[j].destroy(); heroBullets[i].destroy(); enemies.splice(j, 1); heroBullets.splice(i, 1); score += 10; kills += 1; scoreTxt.setText('Score: ' + score); if (kills >= 30) { LK.showGameOver(); } break; } } } } var boss; var bossSpawned = false; var hero; var enemies = []; var heroBullets = []; var enemyBullets = []; var score = 0; var kills = 0; var gameDuration = 60000; // 1 minute in milliseconds var startTime = Date.now(); var scoreTxt = new Text2('Score: 0', { size: 50, fill: "#ffffff" }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); var ammoTxt = new Text2('Ammo: 6', { size: 50, fill: "#ffffff" }); ammoTxt.anchor.set(0.5, 0); ammoTxt.x = 2048 / 2; ammoTxt.y = 2732 - 100; LK.gui.top.addChild(ammoTxt); var timerTxt = new Text2('Time: 60', { size: 50, fill: "#ffffff" }); timerTxt.anchor.set(1, 0); LK.gui.topRight.addChild(timerTxt); // Initialize hero hero = new Hero(); hero.x = 2048 / 2; hero.y = 2732 - 400; hero.reloading = false; game.addChild(hero); // Initialize shoot button var shootButton = new ShootButton(); shootButton.x = 2048 - 200; shootButton.y = 2732 - 200; game.addChild(shootButton); // Spawn enemies function spawnEnemy() { var enemy = new Enemy(); enemy.x = Math.random() * 2048; enemy.y = -100; game.addChild(enemy); enemies.push(enemy); } // Update game state game.update = function () { // Update timer text var elapsedTime = Date.now() - startTime; var remainingTime = Math.max(0, Math.ceil((gameDuration - elapsedTime) / 1000)); timerTxt.setText('Time: ' + remainingTime); // Spawn boss at 30 seconds if (!bossSpawned && elapsedTime >= 30000) { boss = new Boss(); boss.x = 2048 / 2; boss.y = -300; game.addChild(boss); bossSpawned = true; } if (elapsedTime >= gameDuration) { LK.showGameOver(); alert("You Win! Your score: " + score); alert("Game Over! Your score: " + score); return; } // Update hero hero.update(); // Update enemies for (var i = enemies.length - 1; i >= 0; i--) { enemies[i].update(); if (enemies[i].intersects(hero)) { LK.showGameOver(); } } // Update boss if (bossSpawned) { boss.update(); if (boss.intersects(hero)) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } } for (var i = heroBullets.length - 1; i >= 0; i--) { heroBullets[i].update(); for (var j = enemies.length - 1; j >= 0; j--) { if (heroBullets[i].intersects(enemies[j])) { enemies[j].destroy(); heroBullets[i].destroy(); enemies.splice(j, 1); heroBullets.splice(i, 1); score += 10; kills += 1; scoreTxt.setText('Score: ' + score); if (kills >= 30) { LK.showGameOver(); } break; } } } // Update enemy bullets for (var i = enemyBullets.length - 1; i >= 0; i--) { enemyBullets[i].update(); if (enemyBullets[i].intersects(hero)) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } } // Spawn enemies periodically if (LK.ticks % 60 == 0) { spawnEnemy(); } }; // Handle touch events game.move = function (x, y, obj) { hero.x = x; }; game.up = function (x, y, obj) { // No action needed on touch up };
===================================================================
--- original.js
+++ change.js