User prompt
Add a sound when fragments explode or are removed from the screen.
User prompt
Make sure direction is set on particle when this bone.
User prompt
Particles that spawn when a fragment is removed should evaporate in a circle from the explosion point.
User prompt
Use a different acid for particles than you do use for fragments.
User prompt
When removing an explosion fragment, spawn a bunch of particles that sort of flies up from the spot where the explosion fragment was removed.
User prompt
We're currently removing elements from the screen when they reach a certain speed. Increase the removal threshold by 10x.
User prompt
only allow the fragments to fly for so long, add a modifier to them that slows them down over time, and when they stop moving, remove them from the game.
User prompt
Rather than adding one more target for each level, add two targets for each level.
User prompt
Add background music to the game.
User prompt
Add a sound when an explosion occurs.
User prompt
Prevent the background from getting smaller than 33%.
User prompt
Something seems to be broken with the levels. Level 1 starts with 3 targets, but level 2 only has 2 targets. Please make level 1 has 3 targets at a random position, level 2 having 4 targets, and so on.
User prompt
When progressing to a new level, also scale down the background with the same percentage as your scale elements. Animate this transition.
User prompt
make the background element have opacity of 30%.
User prompt
Please add a background to this game, just a big image that sits at the center of the screen.
User prompt
If two targets intercept, have them bounce off each other using billiard-type physics.
User prompt
Please add score to this game where the score increases by one when you destroy one target. Show the score in the top center of the screen.
User prompt
For the live GUI elements that exist in the top right corner, please rotate these 45 degrees anticlockwise.
User prompt
The top right GUI element is anchored at the top right corner. Right now you seem to offset the X based on the top right element being anchored in the top left corner. Please fix this.
Code edit (1 edits merged)
Please save this source code
User prompt
The fragments indicating how many lives are back does not seem to show on the screen. Please make sure they are aligned appropriately.
User prompt
Show three fragments in the top right corner indicating how many attempts I have back.
User prompt
When deleting a fragment that has left the screen, if there is no fragments left on the screen and I have no more attempts at creating an explosion, call game over.
User prompt
I should only have three attempts at creating an explosion by clicking the screen per level. Please implement this feature.
User prompt
In the createExplosion method, after setting fragment.direction, please also set the rotation of the fragment.
/**** * 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; } // Check for collision with other enemies for (var i = 0; i < enemies.length; i++) { if (enemies[i] !== self && self.intersects(enemies[i])) { // Calculate the angle of the collision var angle = Math.atan2(enemies[i].y - self.y, enemies[i].x - self.x); // Reverse the direction of the enemy self.direction = angle + Math.PI; // Push the enemy away from the other enemy self.x += Math.cos(self.direction) * self.speed; self.y += Math.sin(self.direction) * self.speed; } } }; }); // 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.update = function () { self.x += Math.cos(self.direction) * self.speed; self.y += Math.sin(self.direction) * self.speed; self.speed *= 0.99; if (self.speed < 0.1) { var index = explosions.indexOf(self); if (index > -1) { explosions.splice(index, 1); } // Spawn particles when the fragment is removed for (var i = 0; i < 10; i++) { var particle = new Particle(); particle.x = self.x; particle.y = self.y; // Set the direction of each particle to form a perfect circle particle.direction = i * (Math.PI / 4); game.addChild(particle); } // Play fragment explosion sound LK.getSound('fragmentExplosion').play(); self.destroy(); } else if (self.x < 0 || self.x > 2048 || self.y < 0 || self.y > 2732) { var index = explosions.indexOf(self); if (index > -1) { explosions.splice(index, 1); } // Play fragment explosion sound LK.getSound('fragmentExplosion').play(); self.destroy(); } }; }); //<Assets used in the game will automatically appear here> // Particle class var Particle = Container.expand(function () { var self = Container.call(this); var particleGraphics = self.attachAsset('particle', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 2; self.update = function () { self.x += Math.cos(self.direction) * self.speed; self.y += Math.sin(self.direction) * self.speed; self.alpha -= 0.01; if (self.alpha <= 0) { self.destroy(); } }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 //Init game with black background }); /**** * Game Code ****/ LK.playMusic('backgroundMusic'); var background = game.attachAsset('background', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2, alpha: 0.3 }); // Initialize three fragment images to represent the attempts left var attemptsImages = []; for (var i = 0; i < 3; i++) { var attemptImage = LK.getAsset('fragment', { anchorX: 1.0, anchorY: 0.0, x: -(i + 1) * 100, y: 0, rotation: -Math.PI / 4 // Rotate 45 degrees anticlockwise }); attemptsImages.push(attemptImage); LK.gui.topRight.addChild(attemptImage); } // Initialize arrays and variables var explosions = []; var enemies = []; var level = 1; var enemySize = 100; var attempts = 3; var score = 0; // Initialize score text var scoreTxt = new Text2('0', { size: 150, fill: "#ffffff" }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Function to create an explosion function createExplosion(x, y) { // Create eight explosion fragments for (var i = 0; i < 8; 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 / 4); fragment.rotation = fragment.direction; // Shrink the fragments as the targets shrink fragment.scale.set(enemySize / 100, enemySize / 100); explosions.push(fragment); game.addChild(fragment); } // Play the explosion sound LK.getSound('explosion').play(); } // 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.scale.set(enemySize * 2 / 200, enemySize * 2 / 200); enemies.push(enemy); game.addChild(enemy); } // Handle screen press to create an explosion game.down = function (x, y, obj) { if (attempts > 0) { createExplosion(x, y); attempts--; // Update the display of attempts left attemptsImages[attempts].visible = false; } }; // Update function called every game tick game.update = function () { // Update explosions for (var i = explosions.length - 1; i >= 0; i--) { if (explosions[i]) { explosions[i].update(); if (explosions[i] && 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); // Increase score and update score text score++; scoreTxt.setText(score); 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; attempts = 3; // Reset the display of attempts left for (var i = 0; i < 3; i++) { attemptsImages[i].visible = true; } // Remove all fragments for (var i = explosions.length - 1; i >= 0; i--) { if (explosions[i] instanceof ExplosionFragment) { explosions[i].destroy(); explosions.splice(i, 1); } } // Flash the screen white LK.effects.flashScreen(0xffffff, 1000); // Scale down the background only if it's larger than 33% if (background.scale.x > 0.33 && background.scale.y > 0.33) { background.scale.x *= 0.9; background.scale.y *= 0.9; } // Create new enemies for (var i = 0; i < level * 2 + 1; i++) { createEnemy(Math.random() * 2048, Math.random() * 2732); } } else if (enemies.length > 0 && explosions.length == 0 && attempts == 0) { // If there are still enemies, no fragments left on the screen and no more attempts at creating an explosion, call game over LK.showGameOver(); } }; // Create initial enemies createEnemy(500, 500); createEnemy(1000, 1000); createEnemy(1500, 1500);
===================================================================
--- original.js
+++ change.js
@@ -62,14 +62,18 @@
// Set the direction of each particle to form a perfect circle
particle.direction = i * (Math.PI / 4);
game.addChild(particle);
}
+ // Play fragment explosion sound
+ LK.getSound('fragmentExplosion').play();
self.destroy();
} else if (self.x < 0 || self.x > 2048 || self.y < 0 || self.y > 2732) {
var index = explosions.indexOf(self);
if (index > -1) {
explosions.splice(index, 1);
}
+ // Play fragment explosion sound
+ LK.getSound('fragmentExplosion').play();
self.destroy();
}
};
});
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.