User prompt
Don't set direction and rotation when in the ExplosionFragment class. Delete those two lines.
User prompt
In the Create Explosion method, after setting direction, also set rotation.
User prompt
The rotation of the explosion fragment seems random. The rotation should be the direction it's moving in.
User prompt
When the fragments spawn, I want them to sort of point in the direction of movement. Currently, the rotation seems wrong. Can you try to fix this?
User prompt
when spawning fragments at 45 degrees to the rotation they're spawning at.
User prompt
create eight fragments rather than six fragments when something explodes or you press the screen.
User prompt
Rather than spawning six fragments, spawn eight fragments.
User prompt
You seem to be factoring in enemies' existing width and height and fragments' width and height when calculating their new size. Don't factor in those.
User prompt
When scaling enemy or fragment, just use a fixed number. Don't factor in the enemies existing with a height or the fragments existing with a height.
User prompt
When scaling targets and fragments, don't set width and height directly. Use scale.set instead.
User prompt
Rotate each fragment asset such that they are rotated according to the direction they're flying in.
User prompt
When targets shrink, also shrink the fragments. So as you progress through levels, the fragments should also get smaller and smaller.
User prompt
Make the initial target size twice as big.
User prompt
When a level starts, write what level you're at at the center of the screen, and then fade it out after a few seconds.
User prompt
When you complete a label, flash the screen white.
User prompt
Please fix the bug: 'TypeError: undefined is not an object (evaluating 'explosions[i].radius')' in or related to this line: 'if (explosions[i].radius > 200) {' Line Number: 112
User prompt
There is too many explosion fragments being generated, please only generate six.
User prompt
The explosion acid itself is unnecessary, just halve the fragments and remove the explosion otherwise.
User prompt
Please fix the bug: 'TypeError: undefined is not an object (evaluating 'explosions[i].radius')' in or related to this line: 'if (explosions[i].radius > 200) {' Line Number: 135
User prompt
Please remove all fragments when you start the next level.
User prompt
Make sure fragments who fly off the screen are removed and garbage collected.
User prompt
Add levels to the game such that, when you have destroyed all targets, a new level starts that has one more target to hit, but the target is 10% smaller.
User prompt
So, the targets that you have to hit should spawn at a random position on the screen and they should have a movement vector. If they move off the screen, they should just wrap around the other side of the screen.
User prompt
use a different asset for fragments.
User prompt
When an explosion fragment intersects a target, the fragment should be destroyed.
/**** * Classes ****/ // Enemy class var Enemy = Container.expand(function () { var self = Container.call(this); var enemyGraphics = self.attachAsset('enemy', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { // Move the enemy in its current direction self.x += Math.cos(self.direction) * self.speed; self.y += Math.sin(self.direction) * self.speed; // Wrap around the screen if the enemy moves off the screen if (self.x < 0) { self.x += 2048; } else if (self.x > 2048) { self.x -= 2048; } if (self.y < 0) { self.y += 2732; } else if (self.y > 2732) { self.y -= 2732; } }; }); //<Assets used in the game will automatically appear here> // Explosion class var Explosion = Container.expand(function () { var self = Container.call(this); var explosionGraphics = self.attachAsset('explosion', { anchorX: 0.5, anchorY: 0.5 }); self.radius = 50; self.expandRate = 5; self.update = function () { self.radius += self.expandRate; explosionGraphics.width = self.radius * 2; explosionGraphics.height = self.radius * 2; if (self.radius > 200) { self.destroy(); } }; }); // Explosion Fragment class var ExplosionFragment = Container.expand(function () { var self = Container.call(this); var fragmentGraphics = self.attachAsset('fragment', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.direction = Math.random() * Math.PI * 2; // Random direction in radians self.update = function () { self.x += Math.cos(self.direction) * self.speed; self.y += Math.sin(self.direction) * self.speed; }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 //Init game with black background }); /**** * Game Code ****/ // Initialize arrays and variables var explosions = []; var enemies = []; var level = 1; var enemySize = 100; // Function to create an explosion function createExplosion(x, y) { var explosion = new Explosion(); explosion.x = x; explosion.y = y; explosions.push(explosion); game.addChild(explosion); // Create six explosion fragments for (var i = 0; i < 6; i++) { var fragment = new ExplosionFragment(); fragment.x = x; fragment.y = y; // Set the direction of each fragment to form a perfect circle fragment.direction = i * (Math.PI / 3); explosions.push(fragment); game.addChild(fragment); } } // Function to create an enemy function createEnemy(x, y) { var enemy = new Enemy(); enemy.x = x; enemy.y = y; // Assign a random direction and speed to the enemy enemy.direction = Math.random() * Math.PI * 2; enemy.speed = Math.random() * 5 + 1; // Set the size of the enemy based on the enemySize variable enemy.width = enemySize; enemy.height = enemySize; enemies.push(enemy); game.addChild(enemy); } // Handle screen press to create an explosion game.down = function (x, y, obj) { createExplosion(x, y); }; // Update function called every game tick game.update = function () { // Update explosions for (var i = explosions.length - 1; i >= 0; i--) { explosions[i].update(); if (explosions[i].radius > 200) { explosions.splice(i, 1); } } // Check for collisions between explosions and enemies for (var j = enemies.length - 1; j >= 0; j--) { for (var k = explosions.length - 1; k >= 0; k--) { if (enemies[j].intersects(explosions[k])) { createExplosion(enemies[j].x, enemies[j].y); enemies[j].destroy(); enemies.splice(j, 1); if (explosions[k] instanceof ExplosionFragment) { explosions[k].destroy(); explosions.splice(k, 1); } break; } } } // Start a new level when all enemies are destroyed if (enemies.length == 0) { level++; enemySize *= 0.9; for (var i = 0; i < level; i++) { createEnemy(Math.random() * 2048, Math.random() * 2732); } } }; // Create initial enemies createEnemy(500, 500); createEnemy(1000, 1000); createEnemy(1500, 1500);
===================================================================
--- original.js
+++ change.js
@@ -71,8 +71,10 @@
****/
// Initialize arrays and variables
var explosions = [];
var enemies = [];
+var level = 1;
+var enemySize = 100;
// Function to create an explosion
function createExplosion(x, y) {
var explosion = new Explosion();
explosion.x = x;
@@ -97,8 +99,11 @@
enemy.y = y;
// Assign a random direction and speed to the enemy
enemy.direction = Math.random() * Math.PI * 2;
enemy.speed = Math.random() * 5 + 1;
+ // Set the size of the enemy based on the enemySize variable
+ enemy.width = enemySize;
+ enemy.height = enemySize;
enemies.push(enemy);
game.addChild(enemy);
}
// Handle screen press to create an explosion
@@ -128,8 +133,16 @@
break;
}
}
}
+ // Start a new level when all enemies are destroyed
+ if (enemies.length == 0) {
+ level++;
+ enemySize *= 0.9;
+ for (var i = 0; i < level; i++) {
+ createEnemy(Math.random() * 2048, Math.random() * 2732);
+ }
+ }
};
// Create initial enemies
createEnemy(500, 500);
createEnemy(1000, 1000);
Hexagonal target sprite sheet. Bright colors, cartoon. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Puzzle game background image. Lots of octagons and other interesting elements. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.