User prompt
the game displays banners on the screen depending of how many baloons have been destroyed with a single dagger however each of those has a fixed time that defines how long they stay on screen. we need to add an extra rule that overrides this timer, so that if a new banner appears, the previous one should instantly go away even if the timer didn't fully pass
Code edit (1 edits merged)
Please save this source code
User prompt
add the BGmusic music as the background music for the game. this sound should loop indefinitely
User prompt
add the BGmusic sound as the background music for the game. this sound should loop indefinitely. start this as soon as the game loads
User prompt
add the BGmusic sound as the background music for the game. this sound should loop indefinitely
User prompt
Please fix the bug: 'TypeError: LK.getSound(...).isPlaying is not a function' in or related to this line: 'if (LK.getSound('Background').isPlaying()) {' Line Number: 275
User prompt
only play the Background sound at the start of each new round, including at the start of the game. if a new round start and the previous Background sound is still playing, stop and and start it again
User prompt
only play the Background sound at the start of each new round, including at the start of the game. if a new round start and the previous Background sound is still playing, stop and and start it again
User prompt
Please fix the bug: 'TypeError: LK.getSound(...).isPlaying is not a function' in or related to this line: 'if (!LK.getSound('Background').isPlaying()) {' Line Number: 158
User prompt
on tick check if background is playing, if not, then play
User prompt
play background music on game start
User prompt
on tick check if background is playing, if not, then play\
User prompt
play the Music sound in the background when the game starts
User prompt
on tick check if background music is playing, if not, then play
User prompt
play the music sound continously as a loopin the background whenever the game starts. restart the sound when the game restarts
User prompt
play the music sound in the background whenever the game starts. restart the sound when the game restarts
User prompt
play the music sound in the background when the game starts
User prompt
play the Deadly sound when displaying the comboMulti
User prompt
play the Sharp sound when displaying the comboTriple
User prompt
play the Edgy sound when displaying the comboDouble. rght now it doesnt play
User prompt
play the Edgy sound when displaying the comboDouble
User prompt
play the Edgy sound when displaying the comboDouble
User prompt
when a dagger is released play the Dagger sound
User prompt
when a balloon is destroyed, play the Pop sound
User prompt
Migrate to the latest version of LK
/**** * Classes ****/ var Dagger = Container.expand(function () { var self = Container.call(this); var daggerGraphics = self.attachAsset('dagger', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 22 * 1.1; self.direction = 1; self._move_migrated = function () { if (!self.isDropping) { if (self.x > 2048 - self.width / 2) { self.x = 2048 - self.width / 2; self.direction *= -1; } else if (self.x < self.width / 2) { self.x = self.width / 2; self.direction *= -1; } self.x += self.speed * self.direction; } else { self.y += self.speed * 2; } }; self.isDropping = false; self.targetsHit = 0; self.drop = function () { if (self.isDropping) { self.y += self.speed * 2; } }; }); var DoubleCombo = Container.expand(function () { var self = Container.call(this); var comboGraphics = self.attachAsset('comboDouble', { anchorX: 0.5, anchorY: 0.5 }); self.x = 2048 / 2; self.y = 2732 / 2; self.show = function () { if (currentBanner) { currentBanner.destroy(); } self.visible = true; currentBanner = self; LK.getSound('Edgy').play(); // Play the 'Edgy' sound LK.setTimeout(function () { if (currentBanner === self) { self.destroy(); currentBanner = null; } }, 1500); }; self.visible = false; }); var Explosion = Container.expand(function () { var self = Container.call(this); var explosionGraphics = self.attachAsset('explosion', { anchorX: 0.5, anchorY: 0.5 }); self.visible = false; self.show = function () { self.visible = true; LK.setTimeout(function () { self.destroy(); }, 115); }; }); var MultiCombo = Container.expand(function () { var self = Container.call(this); var comboGraphics = self.attachAsset('comboMulti', { anchorX: 0.5, anchorY: 0.5 }); self.x = 2048 / 2; self.y = 2732 / 2; self.show = function () { if (currentBanner) { currentBanner.destroy(); } self.visible = true; currentBanner = self; LK.getSound('Deadly').play(); // Play the 'Deadly' sound LK.setTimeout(function () { if (currentBanner === self) { self.destroy(); currentBanner = null; } }, 1500); }; self.visible = false; }); var Target = Container.expand(function (index) { var self = Container.call(this); var targetGraphics = self.attachAsset('target', { anchorX: 0.5, anchorY: 0.5 }); self.direction = index % 2 === 0 ? -1 : 1; self.speed = 2 * 3 * 1.25 * 0.9 * (1 + 0.25 * index); self._move_migrated = function () { if (self.x > 2048 - self.width / 2) { self.x = 2048 - self.width / 2; self.direction *= -1; targetGraphics.scale.x *= -1; } else if (self.x < self.width / 2) { self.x = self.width / 2; self.direction *= -1; targetGraphics.scale.x *= -1; } self.x += self.speed * self.direction; self.y += Math.sin(LK.ticks / 60) * 0.5; }; LK.on('tick', function () { self._move_migrated(); }); }); var TripleCombo = Container.expand(function () { var self = Container.call(this); var comboGraphics = self.attachAsset('comboTriple', { anchorX: 0.5, anchorY: 0.5 }); self.x = 2048 / 2; self.y = 2732 / 2; self.show = function () { if (currentBanner) { currentBanner.destroy(); } self.visible = true; currentBanner = self; LK.getSound('Sharp').play(); // Play the 'Sharp' sound LK.setTimeout(function () { if (currentBanner === self) { self.destroy(); currentBanner = null; } }, 1500); }; self.visible = false; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ var background = game.attachAsset('background', {}); background.width = 2048; background.height = 2732; var daggers = []; var currentScore = 0; var currentBanner = null; var targets = []; var currentScore = 0; var scoreTxt = new Text2(currentScore.toString(), { size: 150, fill: "#ffffff", stroke: "#000000", strokeThickness: 11.25, font: "'Luckiest Guy', 'Arial Black', sans-serif" }); scoreTxt.anchor.set(.5, 0); LK.gui.top.addChild(scoreTxt); var targetSpacing = 150; var currentLevel = 1; function addTargets(level) { for (var i = 0; i < level + 3; i++) { var target = game.addChild(new Target(i)); target.x = Math.random() * 2048; target.y = 2732 / 2 + i * targetSpacing - 1200 - 100 + 500 + 300; target.number = i + 1; targets.push(target); } } addTargets(currentLevel); var dragNode = null; var isGameOver = false; var tickOffset = 0; for (var i = 0; i < 5; i++) { var newDagger = new Dagger(); newDagger.x = 2048 / 2; newDagger.y = 2732 / 4 - 200 - i * 50; // Reduced vertical spacing to 50 daggers.push(newDagger); game.addChild(newDagger); if (i === 0) { dragNode = newDagger; newDagger.isDropping = false; } } game.on('down', function (x, y, obj) { if (dragNode && !dragNode.isDropping) { dragNode.isDropping = true; LK.getSound('Dagger').play(); // Play the 'Dagger' sound dragNode = null; } }); LK.on('tick', function () { for (var a = daggers.length - 1; a >= 0; a--) { if (daggers[a]) { daggers[a]._move_migrated(); daggers[a].drop(); } for (var b = targets.length - 1; b >= 0; b--) { if (daggers[a].intersects(targets[b])) { var explosion = game.addChild(new Explosion()); explosion.x = targets[b].x; explosion.y = targets[b].y; explosion.show(); game.removeChild(targets[b]); targets.splice(b, 1); daggers[a].targetsHit++; currentScore += daggers[a].targetsHit; LK.setScore(currentScore); scoreTxt.setText(LK.getScore().toString()); LK.getSound('Pop').play(); // Play the 'Pop' sound break; } } if (daggers[a] && daggers[a].y > 2732) { var comboCount = daggers[a].targetsHit; var comboType = comboCount === 2 ? 'Double' : comboCount === 3 ? 'Triple' : comboCount >= 4 ? 'Multi' : ''; if (comboCount === 2) { var doubleCombo = new DoubleCombo(); game.addChildAt(doubleCombo, game.children.indexOf(background) + 1); doubleCombo.show(); } else if (comboCount === 3) { var tripleCombo = new TripleCombo(); game.addChildAt(tripleCombo, game.children.indexOf(background) + 1); tripleCombo.show(); } else if (comboCount >= 4) { var multiCombo = new MultiCombo(); game.addChildAt(multiCombo, game.children.indexOf(background) + 1); multiCombo.show(); } daggers[a].destroy(); daggers.splice(a, 1); if (daggers.length > 0) { dragNode = daggers[daggers.length - 1]; dragNode.isDropping = false; dragNode.targetsHit = 0; } else if (targets.length === 0) { currentLevel++; daggers = []; if (currentLevel <= 12) { addTargets(currentLevel); } else { isGameOver = true; } } } } if ((isGameOver || daggers.length === 0) && targets.length > 0) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } else if (targets.length === 0) { var spareDaggers = daggers.length - 1; if (spareDaggers > 0) { var spareDaggerPoints = spareDaggers * 2; currentScore += spareDaggerPoints; } LK.setScore(currentScore); scoreTxt.setText(LK.getScore().toString()); for (var i = 0; i < daggers.length; i++) { daggers[i].destroy(); } daggers = []; currentLevel++; addTargets(currentLevel); for (var i = 0; i < 5; i++) { var newDagger = new Dagger(); newDagger.x = 2048 / 2; newDagger.y = 2732 / 4 - 200 - i * 50; // Reduced vertical spacing to 50 daggers.push(newDagger); game.addChild(newDagger); if (i === 0) { dragNode = newDagger; dragNode.isDropping = false; } } } }); // Play background music that loops indefinitely LK.playMusic('BGmusic', { loop: true });
===================================================================
--- original.js
+++ change.js
@@ -39,12 +39,19 @@
});
self.x = 2048 / 2;
self.y = 2732 / 2;
self.show = function () {
+ if (currentBanner) {
+ currentBanner.destroy();
+ }
self.visible = true;
+ currentBanner = self;
LK.getSound('Edgy').play(); // Play the 'Edgy' sound
LK.setTimeout(function () {
- self.destroy();
+ if (currentBanner === self) {
+ self.destroy();
+ currentBanner = null;
+ }
}, 1500);
};
self.visible = false;
});
@@ -70,12 +77,19 @@
});
self.x = 2048 / 2;
self.y = 2732 / 2;
self.show = function () {
+ if (currentBanner) {
+ currentBanner.destroy();
+ }
self.visible = true;
+ currentBanner = self;
LK.getSound('Deadly').play(); // Play the 'Deadly' sound
LK.setTimeout(function () {
- self.destroy();
+ if (currentBanner === self) {
+ self.destroy();
+ currentBanner = null;
+ }
}, 1500);
};
self.visible = false;
});
@@ -112,12 +126,19 @@
});
self.x = 2048 / 2;
self.y = 2732 / 2;
self.show = function () {
+ if (currentBanner) {
+ currentBanner.destroy();
+ }
self.visible = true;
+ currentBanner = self;
LK.getSound('Sharp').play(); // Play the 'Sharp' sound
LK.setTimeout(function () {
- self.destroy();
+ if (currentBanner === self) {
+ self.destroy();
+ currentBanner = null;
+ }
}, 1500);
};
self.visible = false;
});
@@ -136,8 +157,9 @@
background.width = 2048;
background.height = 2732;
var daggers = [];
var currentScore = 0;
+var currentBanner = null;
var targets = [];
var currentScore = 0;
var scoreTxt = new Text2(currentScore.toString(), {
size: 150,
dagger pointing down Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows. pixel. 8 bit
pixelated cloudy sky Single Game Texture. In-Game background. 2d. High contrast. No shadows. 8 bit
white round cloud burst. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.8 bit. pixelated
colored text saying (EDGY). Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows. pixelated. 8 bit
colored text saying (SHARP). Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows. pixelated. 8 bit. retro
colored text saying (DEADLY). sharp dagger edges around the text. pixelated. 8 bit. retro Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
cute red balloon. looking up. feeling scared. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows. pixel. 8 bit