User prompt
move the arrow shoot location to the hand of the stickman
User prompt
play different sound on released.
User prompt
play sound when click is released.
User prompt
rotate the arrow in the opposite direction of the drag when released
User prompt
rotate the arrow in the direction of the drag when released
User prompt
Please fix the bug: 'Uncaught ReferenceError: arrow is not defined' in or related to this line: 'arrow.rotation = Math.atan2(stickman.y - y, stickman.x - x);' Line Number: 164
User prompt
rotate the arrow in the direction of the drag
User prompt
Change the color of stickman to blue-white
User prompt
Change the text color to dark blue.
User prompt
use the background asset for the background of the game.
User prompt
make the backround asset to game background
User prompt
do not reduce the score when ballon skip
User prompt
flash screen red when the ballon skip reduces
User prompt
remove the instruction text after the wave 1 completed.
User prompt
at the start of the game show wave 1.
User prompt
write text on the bottom center of the screen : " Click And Drag Behind to Shoot With More Power "
User prompt
Change background image
User prompt
Play sound when arrow hits the ballon
User prompt
remove the point reducing logic
User prompt
decrease the point by 1 if the arrow missed the ballons and reached the bottom edge of the screen.
User prompt
destroy the ballons and arrows if the are not visible on the screen, or outside of the screen bowndry
User prompt
on each arrow miss decrease the point
User prompt
Rotate the bow in the direction of the gravity
User prompt
now there is some performance issue so instaed of increasing the number of ballons in each wave, increase the speed bit by bit in each wave.
User prompt
now game is lagging after wave 4, fix the issue.
/**** * Classes ****/ //<Assets used in the game will automatically appear here> // Arrow class var Arrow = Container.expand(function () { var self = Container.call(this); var arrowGraphics = self.attachAsset('arrow', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 10; self.update = function () { // Apply physics self.speedY = (self.speedY || 0) + 0.2; // further reduced gravity self.y += Math.sin(self.rotation) * self.speed + self.speedY; self.x += Math.cos(self.rotation) * self.speed; }; }); // Balloon class var Balloon = Container.expand(function () { var self = Container.call(this); var balloonColors = ['redBalloon', 'greenBalloon', 'blueBalloon']; var randomColor = balloonColors[Math.floor(Math.random() * balloonColors.length)]; var balloonGraphics = self.attachAsset(randomColor, { anchorX: 0.5, anchorY: 0.5 }); self.speed = Math.random() * 2; self.active = false; self.update = function () { if (self.active) { self.y -= self.speed; } }; self.reset = function () { self.active = false; self.y = 2732; self.x = Math.random() * 2048; }; self.activate = function () { self.active = true; }; }); // PowerUp class var PowerUp = Container.expand(function () { var self = Container.call(this); var powerUpGraphics = self.attachAsset('powerUp', { anchorX: 0.5, anchorY: 0.5 }); self.speed = Math.random() * 5 + 1; self.update = function () { self.y -= self.speed; }; }); // Stickman class var Stickman = Container.expand(function () { var self = Container.call(this); var stickmanGraphics = self.attachAsset('stickman', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { // Stickman can have some movement logic if needed }; }); // Target class var Target = Container.expand(function () { var self = Container.call(this); var targetGraphics = self.attachAsset('target', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { // Targets can have some movement logic if needed }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0xdc0a04 }); /**** * Game Code ****/ var background = game.attachAsset('background', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 }); // Create a timer to spawn balloons at a regular interval var balloonSpawnTimer = LK.setInterval(function () { for (var i = 0; i < wave; i++) { createTarget(); } }, 2000); // Spawn balloons every 2 seconds var arrows = []; var stickman = new Stickman(); stickman.x = 2048 / 2; stickman.y = 2732 / 2; game.addChild(stickman); var targets = []; var wave = 1; var score = 0; var scoreTxt = new Text2('0', { size: 150, fill: "#ffffff" }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); var balloonSkips = 5; var balloonSkipIcons = []; for (var i = 0; i < balloonSkips; i++) { var balloonSkipIcon = LK.getAsset('balloonSkip', { anchorX: 0.0, anchorY: 0.0, x: i * 120, y: 0 }); balloonSkipIcons.push(balloonSkipIcon); LK.gui.topLeft.addChild(balloonSkipIcon); } // Create initial target function createTarget() { var balloon = new Balloon(); balloon.x = Math.random() * 2048; balloon.y = 2732; targets.push(balloon); game.addChild(balloon); } // Update score function updateScore() { scoreTxt.setText(score); } // Handle shooting arrows game.down = function (x, y, obj) { // Do nothing on mouse down }; var isMouseDown = false; game.down = function (x, y, obj) { isMouseDown = true; }; game.up = function (x, y, obj) { if (isMouseDown) { var arrow = new Arrow(); arrow.x = stickman.x; arrow.y = stickman.y; arrow.rotation = Math.atan2(stickman.y - y, stickman.x - x); // Rotate the stickman in the direction of the drag stickman.rotation = arrow.rotation; // Calculate the distance between the stickman and the point where the drag was released var distance = Math.sqrt(Math.pow(stickman.x - x, 2) + Math.pow(stickman.y - y, 2)); // Use this distance to set the speed of the arrow arrow.speed = distance / 50; arrows.push(arrow); game.addChild(arrow); isMouseDown = false; } }; game.move = function (x, y, obj) { if (isMouseDown) { // Rotate the stickman towards the mouse pointer stickman.rotation = Math.atan2(stickman.y - y, stickman.x - x); } }; // Game update loop game.update = function () { // Update and check arrows for (var i = arrows.length - 1; i >= 0; i--) { var arrow = arrows[i]; arrow.update(); // Remove off-screen arrows if (arrow.y < -50 || arrow.y > 2732 || arrow.x < 0 || arrow.x > 2048) { arrow.destroy(); arrows.splice(i, 1); continue; } // Check for collisions with targets for (var j = targets.length - 1; j >= 0; j--) { var target = targets[j]; if (arrow.intersects(target)) { // Update score score += 2; updateScore(); // Destroy target target.destroy(); targets.splice(j, 1); // Play sound LK.getSound('arrowHit').play(); // Check for wave increase if (score % 50 == 0) { wave++; var waveText = new Text2('Wave ' + wave, { size: 150, fill: "#ffffff" }); waveText.anchor.set(0.5, 0.5); LK.gui.center.addChild(waveText); LK.setTimeout(function () { waveText.destroy(); }, 2000); // Remove instruction text after wave 1 if (wave == 2) { instructionTxt.destroy(); } } break; } } } // Update and check targets for (var j = targets.length - 1; j >= 0; j--) { var target = targets[j]; target.update(); // Reset off-screen targets if (target.y < -50 || target.y > 2732 || target.x < 0 || target.x > 2048) { target.destroy(); targets.splice(j, 1); // Decrease balloon skips balloonSkips--; if (balloonSkips >= 0) { balloonSkipIcons[balloonSkips].destroy(); balloonSkipIcons.splice(balloonSkips, 1); // Flash screen red LK.effects.flashScreen(0xff0000, 1000); } // Score remains the same when a balloon is skipped // Check for game over if (balloonSkips <= 0) { LK.showGameOver(); LK.gui.center.addChild(new Text2('Final Score: ' + score, { size: 150, fill: "#ffffff" })); } } } // Increase the speed of balloons in each wave for (var j = 0; j < targets.length; j++) { var target = targets[j]; if (!target.active) { target.speed += wave * 0.1; // Increase the speed by 10% for each wave target.activate(); } } // Check for power up collection for (var i = 0; i < game.children.length; i++) { var child = game.children[i]; if (child instanceof PowerUp && child.intersects(stickman)) { // Destroy all targets for (var j = targets.length - 1; j >= 0; j--) { targets[j].destroy(); targets.splice(j, 1); } // Destroy the power up child.destroy(); } } }; // Initialize first target createTarget(); // Show wave 1 at the start of the game var waveText = new Text2('Wave ' + wave, { size: 150, fill: "#ffffff" }); waveText.anchor.set(0.5, 0.5); LK.gui.center.addChild(waveText); LK.setTimeout(function () { waveText.destroy(); }, 2000); // Add instruction text at the bottom center of the screen var instructionTxt = new Text2('Click And Drag Behind to Shoot With More Power', { size: 50, fill: "#ffffff" }); instructionTxt.anchor.set(0.5, 1); // Anchor at the bottom center LK.gui.bottom.addChild(instructionTxt);
===================================================================
--- original.js
+++ change.js
@@ -86,8 +86,14 @@
/****
* Game Code
****/
+var background = game.attachAsset('background', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 2048 / 2,
+ y: 2732 / 2
+});
// Create a timer to spawn balloons at a regular interval
var balloonSpawnTimer = LK.setInterval(function () {
for (var i = 0; i < wave; i++) {
createTarget();
Ballon Skiped. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Needle Shooting Stickman. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A clear blue sky with fluffy white clouds drifting lazily across.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.