User prompt
Make the LoseLife sound play when a life is lost
User prompt
Make the score counter more cartoony
User prompt
Make the speed of targets increase for each target destroyed
User prompt
Increases minimum and maximum speed of targets ×2
User prompt
Increases the minimum and maximum speed of targets
User prompt
Make the DestroyTarget sound play when a target is destroyed
User prompt
Creates three objects that represent the life that the player has, when a dart leaves the screen, the dart and a life will be destroyed, when all lives are lost, the game is over.
User prompt
Make it so that only one bullet can be fired at a time, the next one can be fired when the bullet leaves the screen or destroys a target
User prompt
Make the maximum and minimum speed of targets increase for each target destroyed
User prompt
Create an image for the background
User prompt
Make the x position of the object that creates the bullets the x position of the click
User prompt
Make the object that creates the bullets move to where the click is by pressing the screen
User prompt
Make each target move randomly with random speed
User prompt
Make bullets appear from the previously created object
User prompt
Make bullets only appear with the object
User prompt
Make targerts not appear over time
User prompt
Make it not appear for time
User prompt
Make it only one at the start of the game
User prompt
Make the new target appear when the current one is destroyed.
User prompt
Create an image for that object
User prompt
Make an object that stays below the screen, that object will move to where the click is, when you click on the screen, a bullet is fired
Initial prompt
Aim game
/**** * Classes ****/ // Bullet class representing the bullets fired by the player var Bullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.attachAsset('bullet', { anchorX: 0.5, anchorY: 0.5 }); self.speed = -10; self.update = function () { self.y += self.speed; }; }); // Life class representing the player's lives var Life = Container.expand(function () { var self = Container.call(this); var lifeGraphics = self.attachAsset('Life', { anchorX: 0.5, anchorY: 0.5 }); }); // Object class representing the object that stays below the screen and moves to where the click is var Object = Container.expand(function () { var self = Container.call(this); var objectGraphics = self.attachAsset('object', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { // Add any object-specific update logic here }; }); //<Assets used in the game will automatically appear here> //<Write imports for supported plugins here> // Target class representing the targets to be hit var Target = Container.expand(function () { var self = Container.call(this); var targetGraphics = self.attachAsset('target', { anchorX: 0.5, anchorY: 0.5 }); // Initialize random speed and direction for the target self.speedX = (Math.random() - 0.5) * 10; self.speedY = (Math.random() - 0.5) * 10; self.update = function () { // Add any target-specific update logic here self.x += self.speedX; self.y += self.speedY; // Check if target is off-screen, then change direction if (self.x < 0 || self.x > 2048) { self.speedX *= -1; } if (self.y < 0 || self.y > 2732) { self.speedY *= -1; } }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 //Init game with black background }); /**** * Game Code ****/ var background = game.attachAsset('background', { anchorX: 0, anchorY: 0 }); // Initialize variables var targets = []; var bullets = []; var score = 0; var object = new Object(); object.y = 2732; game.addChild(object); // Initialize the player's lives var lives = []; for (var i = 0; i < 3; i++) { var life = new Life(); life.x = 100 + i * 100; life.y = 100; lives.push(life); game.addChild(life); } // Create score display var scoreTxt = new Text2('Score: 0', { size: 100, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Function to spawn a new target function spawnTarget() { var newTarget = new Target(); newTarget.x = Math.random() * 2048; newTarget.y = Math.random() * 1000 + 500; targets.push(newTarget); game.addChild(newTarget); } // Function to handle shooting function shoot(x, y) { var newBullet = new Bullet(); newBullet.x = x; newBullet.y = y; bullets.push(newBullet); game.addChild(newBullet); } // Handle game updates game.update = function () { // End the game when all lives are lost if (lives.length === 0) { LK.showGameOver(); return; } // Update bullets for (var i = bullets.length - 1; i >= 0; i--) { var bullet = bullets[i]; bullet.update(); // Check if bullet is off-screen if (bullet.y < -50) { bullet.destroy(); bullets.splice(i, 1); // Destroy a life var life = lives.pop(); life.destroy(); continue; } // Check for collisions with targets for (var j = targets.length - 1; j >= 0; j--) { var target = targets[j]; if (bullet.intersects(target)) { // Increase score score += 10; scoreTxt.setText('Score: ' + score); // Destroy bullet and target bullet.destroy(); bullets.splice(i, 1); target.destroy(); targets.splice(j, 1); // Play the DestroyTarget sound LK.getSound('DestroyTarget').play(); // Spawn a new target spawnTarget(); // Increase the maximum and minimum speed of targets for each target destroyed Target.prototype.speedX = (Math.random() - 0.5) * (10 + score / 10); Target.prototype.speedY = (Math.random() - 0.5) * (10 + score / 10); break; } } } }; // Handle touch or mouse down events game.down = function (x, y, obj) { object.x = x; if (bullets.length === 0) { shoot(object.x, object.y); } }; // Start the game spawnTarget();
===================================================================
--- original.js
+++ change.js
@@ -142,8 +142,10 @@
bullet.destroy();
bullets.splice(i, 1);
target.destroy();
targets.splice(j, 1);
+ // Play the DestroyTarget sound
+ LK.getSound('DestroyTarget').play();
// Spawn a new target
spawnTarget();
// Increase the maximum and minimum speed of targets for each target destroyed
Target.prototype.speedX = (Math.random() - 0.5) * (10 + score / 10);
Red and white target. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Dart shooting practice room. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Red heart. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows