User prompt
enemy die after 3 hit from heroBullets
Code edit (1 edits merged)
Please save this source code
User prompt
when score reach 5000 player win the game
Code edit (2 edits merged)
Please save this source code
User prompt
enemy respawn more by 2
Code edit (3 edits merged)
Please save this source code
User prompt
enemy die after 2 hit from heroBullets
User prompt
make scoreText in middle top of screen
Code edit (2 edits merged)
Please save this source code
User prompt
make scoreText on top right of screen
User prompt
make score for killing enemy , when samurai kills enemy he get 10 point , points appear on top left of screen , when score reach 1000 player win the game.
User prompt
make the enemy move toward Grendizer
User prompt
make the enemy move toward the hero
Code edit (1 edits merged)
Please save this source code
User prompt
hero get boosted after collect 15 boost
User prompt
when hero collect boost change heroBullets to fireBall
User prompt
make the hero move with mouse direction
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'length')' in this line: 'for (var i = heroBullets.length - 1; i >= 0; i--) {' Line Number: 82
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'length')' in this line: 'for (var i = heroBullets.length - 1; i >= 0; i--) {' Line Number: 82
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'length')' in this line: 'for (var i = heroBullets.length - 1; i >= 0; i--) {' Line Number: 82
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'length')' in this line: 'for (var i = heroBullets.length - 1; i >= 0; i--) {' Line Number: 86
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'length')' in this line: 'for (var m = enemyMissiles.length - 1; m >= 0; m--) {' Line Number: 106
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'length')' in this line: 'for (var m = enemyMissiles.length - 1; m >= 0; m--) {' Line Number: 106
User prompt
make enemy shoot missile into Grendizer
Code edit (3 edits merged)
Please save this source code
/**** * Classes ****/ // Define the Grendizer (player's character) class var Grendizer = Container.expand(function () { var self = Container.call(this); var grendizerGraphics = self.createAsset('grendizer', 'Player character', 0.5, 0.5); self.speed = 50; self.isBoosted = false; self.boostCounter = 0; // Counter for collected boosts self.moveLeft = function () { self.x = Math.max(self.width / 2, self.x - self.speed); }; self.moveRight = function () { self.x = Math.min(2048 - self.width / 2, self.x + self.speed); }; self.update = function () { // Update logic for Grendizer }; }); // Define the Bullet class for Grendizer var HeroBullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.createAsset('heroBullet', 'Hero Bullet', 0.5, 0.5); self.speed = -14; self.move = function () { self.y += self.speed; }; }); // Define the 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 = 15; self.hitCount = 0; // Counter for hits received self.move = function (playerX, playerY) { var directionX = playerX - self.x; var directionY = playerY - self.y; var magnitude = Math.sqrt(directionX * directionX + directionY * directionY); self.x += self.speed * (directionX / magnitude); self.y += self.speed * (directionY / magnitude); }; }); // Define the Boost class var Boost = Container.expand(function () { var self = Container.call(this); var boostGraphics = self.createAsset('boost', 'Boost item', 0.5, 0.5); self.speed = 10; self.move = function () { self.y += self.speed; }; }); // Define the FireBall class for Grendizer when boosted var FireBall = Container.expand(function () { var self = Container.call(this); var fireBallGraphics = self.createAsset('fireBall', 'Fire Ball', 0.5, 0.5); self.speed = -15; self.move = function () { self.y += self.speed; }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 // Init game with black background }); /**** * Game Code ****/ // Initialize important asset arrays and score var heroBullets = []; var enemies = []; var boosts = []; var score = 0; // Create the player's character and score display var player = game.addChild(new Grendizer()); var scoreText = new Text2('0', { size: 150, fill: "#ffffff" }); scoreText.anchor.set(0.5, 0); LK.gui.top.addChild(scoreText); player.x = 2048 / 2; player.y = 2732 - player.height; // Game tick event LK.on('tick', function () { // Update player player.update(); // Move and check hero bullets for (var i = heroBullets.length - 1; i >= 0; i--) { heroBullets[i].move(); if (heroBullets[i].y < -heroBullets[i].height) { heroBullets[i].destroy(); heroBullets.splice(i, 1); } } // Move and check enemies for (var j = enemies.length - 1; j >= 0; j--) { enemies[j].move(player.x, player.y); if (enemies[j].y > 2732 + enemies[j].height) { enemies[j].destroy(); enemies.splice(j, 1); } } // Move and check boosts for (var k = boosts.length - 1; k >= 0; k--) { boosts[k].move(); if (boosts[k].y > 2732 + boosts[k].height) { boosts[k].destroy(); boosts.splice(k, 1); } } // Spawn enemies and boosts if (LK.ticks % 60 == 0) { for (var i = 0; i < 2; i++) { var newEnemy = new Enemy(); newEnemy.x = Math.random() * (2048 - newEnemy.width) + newEnemy.width / 2; newEnemy.y = -newEnemy.height * (i + 1); enemies.push(newEnemy); game.addChild(newEnemy); } } if (LK.ticks % 300 == 0) { var newBoost = new Boost(); newBoost.x = Math.random() * (2048 - newBoost.width) + newBoost.width / 2; newBoost.y = -newBoost.height; boosts.push(newBoost); game.addChild(newBoost); } // Check for collisions enemies.forEach(function (enemy) { if (player.intersects(enemy)) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } heroBullets.forEach(function (bullet) { if (bullet.intersects(enemy)) { // Increment hit counter enemy.hitCount++; // Destroy bullet bullet.destroy(); heroBullets.splice(heroBullets.indexOf(bullet), 1); // Check if enemy has been hit three times if (enemy.hitCount >= 3) { // Increase score and destroy enemy score += 10; scoreText.setText(score.toString()); enemy.destroy(); enemies.splice(enemies.indexOf(enemy), 1); } // Check if player wins the game if (score >= 5000) { LK.effects.flashScreen(0x00ff00, 1000); LK.showGameOver(); } } }); }); boosts.forEach(function (boost) { if (player.intersects(boost)) { boost.destroy(); boosts.splice(boosts.indexOf(boost), 1); player.boostCounter++; if (player.boostCounter >= 15) { player.isBoosted = true; player.boostCounter = 0; // Reset the counter after getting boosted } } }); }); // Touch event listener for continuous player movement game.on('move', function (obj) { var touchPos = obj.event.getLocalPosition(game); player.x = touchPos.x; }); // Fire bullets game.on('down', function (obj) { var newBullet = player.isBoosted ? new FireBall() : new HeroBullet(); newBullet.x = player.x; newBullet.y = player.y - player.height / 2; heroBullets.push(newBullet); game.addChild(newBullet); });
===================================================================
--- original.js
+++ change.js
@@ -142,10 +142,10 @@
enemy.hitCount++;
// Destroy bullet
bullet.destroy();
heroBullets.splice(heroBullets.indexOf(bullet), 1);
- // Check if enemy has been hit twice
- if (enemy.hitCount >= 2) {
+ // Check if enemy has been hit three times
+ if (enemy.hitCount >= 3) {
// Increase score and destroy enemy
score += 10;
scoreText.setText(score.toString());
enemy.destroy();
mini ufo. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
fire ball. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
delete
blue fire ball. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
moving dynamic crystal. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
dark space sky shooting game backround. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.