User prompt
Check if sMetalMusic is playing every 4.25 seconds
User prompt
Check if sMetalMusic is playing every 4 seconds
User prompt
Check if sMetalMusic is playing every 5 seconds
User prompt
and if it isn't playing, play smetalmusic
User prompt
Please fix the bug: 'Timeout.tick error: LK.getSound(...).isPlaying is not a function' in or related to this line: 'if (!LK.getSound('sMetalMusic').isPlaying()) {' Line Number: 197
User prompt
Check if sMetalMusic is playing every 3 seconds
User prompt
now play it 1.5 seconds after the game starts and loop it
User prompt
LK.setTimeout(function () { var metalMusic = LK.getSound('sMetalMusic'); metalMusic.loop = true; metalMusic.play(); }, 1000);
User prompt
do it
User prompt
death is inevitable should be in white
User prompt
when bluenemy, redenemy and yellowenemy are outside of the playspace destroy them
User prompt
after specialobject is instanciated play sound sWallSound
User prompt
before instanciating bloodsplatter play sound sSplurt or sSplurt2 or Splurt3
User prompt
0.5 seconds after game start play sHohoho sound
User prompt
when game start play sHohoho sound
User prompt
before game over play sound sHohoho
User prompt
before greenpowerup is destroyed play sExplosion sound
User prompt
when greenpowerup is destroyed play sExplosion
User prompt
when santa fires, play sBazooka sound
User prompt
Migrate to the latest version of LK
Code edit (1 edits merged)
Please save this source code
User prompt
spawnobject should spawn when the game begins
Code edit (1 edits merged)
Please save this source code
User prompt
the wall seems to lose momentum as it moves down after being pushed back, fix it so it reverts to its initial downward speed
User prompt
when special object receives a bullet, it shouldn't be able to receive anymore bullets momentarily
/**** * Classes ****/ var BloodSplatter = Container.expand(function () { var self = Container.call(this); var scale = (0.5 + Math.random() * 0.5) * 2.5; var splatterGraphics = self.attachAsset('bloodSplatter', { anchorX: 0.5, anchorY: 0.5 }); splatterGraphics.scale.set(scale, scale); self.lifeSpan = 500; self.on('tick', function () { self.lifeSpan -= 16.6667; if (self.lifeSpan <= 0) { LK.setTimeout(function () { self.destroy(); }, 3000); } }); }); var BlueEnemy = Container.expand(function () { var self = Container.call(this); var enemyGraphics = self.attachAsset('blueEnemy', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 6.25; self.teleportTimer = 0; self.teleportInterval = 1; self._move_migrated = function () { self.y += self.speed; if (self.y > game.height || self.x < 0 || self.x > 2048) { self.destroy(); } self.teleportTimer += 1 / 60; if (self.teleportTimer >= self.teleportInterval) { var teleportDirection = Math.random() < 0.5 ? -200 : 200; self.x += Math.max(0, Math.min(2048 - self.width, self.x + teleportDirection)) - self.x; self.teleportTimer = 0; } }; }); var Bullet = Container.expand(function () { var self = Container.call(this); var scale = 0.5 + Math.random() * 0.5; var bulletGraphics = self.attachAsset('bullet', { anchorX: 0.5, anchorY: 0.5 }); bulletGraphics.scale.set(scale, scale); self.speed = 20; self._move_migrated = function () { self.y -= self.speed; }; }); var GraySquare = Container.expand(function () { var self = Container.call(this); var graySquareGraphics = self.attachAsset('graySquare', { anchorX: 0.5, anchorY: 0.5 }); graySquareGraphics.width = 150; graySquareGraphics.height = 150; graySquareGraphics.tint = 0x808080; }); var GreenPowerup = Container.expand(function () { var self = Container.call(this); var powerupGraphics = self.attachAsset('greenPowerup', { anchorX: 0.5, anchorY: 0.5 }); self.amplitude = 10; self.frequency = 0.05; self.baseY = self.y; self._move_migrated = function () { self.y = self.baseY + self.amplitude * Math.sin(LK.ticks * self.frequency); }; }); var RedEnemy = Container.expand(function () { var self = Container.call(this); var enemyGraphics = self.attachAsset('redEnemy', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 10; self._move_migrated = function () { self.y += self.speed; if (self.y > game.height || self.x < 0 || self.x > 2048) { self.destroy(); } }; }); var Santa = Container.expand(function () { var self = Container.call(this); var santaGraphics = self.attachAsset('santa', { anchorX: 0.5, anchorY: 0.5 }); santaGraphics.rotation = -Math.PI / 2; self.direction = 1; self.speed = 15; self._move_migrated = function () { if (self.x >= 2048 - this.width * 0.6 || self.x <= this.width * 0.6) { self.direction *= -1; santaGraphics.scale.y *= -1; } self.x += self.speed * self.direction; }; self.fire = function () { this.direction *= -1; santaGraphics.scale.y *= -1; }; }); var SpecialObject = Container.expand(function () { var self = Container.call(this); var specialObjectGraphics = self.attachAsset('specialObject', { anchorX: 0.5, anchorY: 0.5 }); specialObjectGraphics.scale.x *= 4; self.speed = 2; self._move_migrated = function () { self.y += self.speed; }; self.canBeHit = true; self.hit = function () { if (!self.canBeHit) { return; } self.canBeHit = false; self.speed = -self.speed; LK.setTimeout(function () { self.speed = Math.abs(self.speed); self.canBeHit = true; }, 1000); }; }); var YellowEnemy = Container.expand(function () { var self = Container.call(this); var enemyGraphics = self.attachAsset('yellowEnemy', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 3.75; self.scaleIncrement = 0.2; self.scaleTimer = 0; self._move_migrated = function () { self.y += self.speed; if (self.y > game.height || self.x < 0 || self.x > 2048) { self.destroy(); } self.scaleTimer += 1 / 60; if (self.scaleTimer >= 1) { self.scale.x += self.scaleIncrement; self.scale.y += self.scaleIncrement; self.scaleTimer = 0; } }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ LK.setTimeout(function () { var metalMusic = LK.getSound('sMetalMusic'); metalMusic.loop = true; metalMusic.play(); }, 1000); LK.setTimeout(function () { LK.getSound('sHohoho').play(); }, 500); var background = game.attachAsset('background', {}); background.width = 2048; background.height = 2732; game.addChildAt(background, 0); var santa = game.addChild(new Santa()); var greenPowerup; var greenPowerupSpawnTimer; var score = 0; var specialObject; var specialObjectSpawned = false; var scoreTxt = new Text2(score.toString(), { size: 100, fill: "#FFA500" }); scoreTxt.y += 94; scoreTxt.anchor.set(.5, 0); LK.gui.top.addChild(scoreTxt); var remainingBulletsTxt = new Text2('Bullets: 5', { size: 70, fill: "#FFA500" }); remainingBulletsTxt.y = scoreTxt.height + 114; remainingBulletsTxt.anchor.set(0.5, 0); LK.gui.top.addChild(remainingBulletsTxt); var bullets = []; var enemies = []; santa.x = 2048 / 2; santa.y = 2732 - santa.height; var spawnEnemy = function spawnEnemy() { var enemyType = Math.random(); var enemy; if (enemyType < 0.33) { enemy = new YellowEnemy(); } else if (enemyType < 0.66) { enemy = new BlueEnemy(); } else { enemy = new RedEnemy(); } var boundaryPadding = enemy.width; enemy.x = Math.random() * (2048 - boundaryPadding * 2) + boundaryPadding; enemy.y = 0; enemies.push(enemy); if (specialObject && specialObject.parent === game) { game.addChildAt(enemy, game.getChildIndex(specialObject)); } else { if (specialObject && specialObject.parent === game) { game.addChildAt(enemy, game.getChildIndex(specialObject) - 1); } else { game.addChild(enemy); } } }; var fireBullet = function fireBullet() { if (bullets.length < 5) { santa.fire(); var bullet = new Bullet(); bullet.x = santa.x; bullet.y = santa.y - santa.height / 2 - bullet.height / 2; var graySquare = new GraySquare(); graySquare.x = bullet.x; graySquare.y = bullet.y + 50; game.addChild(graySquare); LK.setTimeout(function () { graySquare.destroy(); }, 500); bullets.push(bullet); game.addChild(bullet); bullet._move_migrated(); remainingBulletsTxt.setText('Bullets: ' + (5 - bullets.length).toString()); // Play sBazooka sound when Santa fires a bullet LK.getSound('sBazooka').play(); } }; game.on('down', function (x, y, obj) { if (santa.x > santa.width * 0.6 && santa.x < 2048 - santa.width * 0.6) { fireBullet(); } }); LK.on('tick', function () { santa._move_migrated(); bullets.forEach(function (bullet, bulletIndex) { bullet._move_migrated(); if (bullet.y < -bullet.height) { bullet.destroy(); bullets.splice(bulletIndex, 1); remainingBulletsTxt.setText('Bullets: ' + (5 - bullets.length).toString()); return; } enemies.forEach(function (enemy, enemyIndex) { if (bullet.intersects(enemy)) { bullet.destroy(); // Play sSplurt, sSplurt2, or sSplurt3 sound before instantiating BloodSplatter var splurtSounds = ['sSplurt', 'sSplurt2', 'sSplurt3']; var randomSplurtSound = splurtSounds[Math.floor(Math.random() * splurtSounds.length)]; LK.getSound(randomSplurtSound).play(); var splatter = new BloodSplatter(); splatter.x = enemy.x; splatter.y = enemy.y; game.addChild(splatter); enemy.destroy(); enemies.forEach(function (e) { e.speed *= 1.1; }); score += 1; if (score >= 100 && !specialObjectSpawned) { specialObject = new SpecialObject(); specialObject.x = 2048 / 2; specialObject.y = -1300; game.addChild(specialObject); specialObjectSpawned = true; // Play sWallSound after SpecialObject is instantiated LK.getSound('sWallSound').play(); var deathText = new Text2('Death Is Inevitable', { size: 150, fill: '#ffffff', align: 'center' }); deathText.anchor.set(0.5, 0.5); deathText.x = 2048 / 4 + 225; deathText.y = 2732 / 2 - deathText.height / 2 - 300; LK.gui.topLeft.addChild(deathText); var toggleTransparency = function toggleTransparency() { deathText.alpha = deathText.alpha === 1 ? 0 : 1; }; var transparencyInterval = LK.setInterval(toggleTransparency, 500); LK.setTimeout(function () { LK.clearInterval(transparencyInterval); deathText.destroy(); }, 5000); } scoreTxt.setText(score.toString()); santa.speed += 1; bullets.splice(bulletIndex, 1); enemies.splice(enemyIndex, 1); remainingBulletsTxt.setText('Bullets: ' + (4 - bullets.length).toString()); } else if (greenPowerup && bullet.intersects(greenPowerup)) { // Play sExplosion sound before greenPowerup is destroyed LK.getSound('sExplosion').play(); bullets.splice(bulletIndex, 1); bullet.destroy(); enemies.forEach(function (e) { var splatter = new BloodSplatter(); splatter.x = e.x; splatter.y = e.y; game.addChild(splatter); e.destroy(); score += 1; }); enemies.length = 0; greenPowerup.destroy(); LK.effects.flashScreen(0x808080, 1000); santa.speed = 15; greenPowerup = undefined; scoreTxt.setText(score.toString()); remainingBulletsTxt.setText('Bullets: ' + (4 - bullets.length).toString()); } }); }); if (specialObject) { specialObject._move_migrated(); bullets.forEach(function (bullet, bulletIndex) { if (bullet.intersects(specialObject) && specialObject.canBeHit) { specialObject.hit(); bullet.destroy(); bullets.splice(bulletIndex, 1); remainingBulletsTxt.setText('Bullets: ' + (5 - bullets.length).toString()); } }); } enemies.forEach(function (enemy) { enemy._move_migrated(); if (santa.intersects(enemy)) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); isGameOver = true; } }); }); var enemySpawnRate = 1000 / 1.75; var enemySpawnTimer = LK.setInterval(spawnEnemy, enemySpawnRate); LK.on('tick', function () {}); greenPowerupSpawnTimer = LK.setInterval(function () { if (greenPowerup && !greenPowerup.isDestroyed) { return; } greenPowerup = new GreenPowerup(); var centerX = 2048 / 2; var centerY = 2732 / 2; var randomOffsetX = (Math.random() - 0.5) * 1200; var randomOffsetY = (Math.random() - 0.5) * 1200; greenPowerup.x = centerX + randomOffsetX - greenPowerup.width / 2; greenPowerup.y = centerY + randomOffsetY - greenPowerup.height / 2; greenPowerup._move_migrated = function () { this.angle += 0.05; this.x = this.center.x + this.radius * Math.cos(this.angle); this.y = this.center.y + this.radius * Math.sin(this.angle); }; game.addChild(greenPowerup); }, 15000);
===================================================================
--- original.js
+++ change.js
@@ -169,9 +169,11 @@
/****
* Game Code
****/
LK.setTimeout(function () {
- LK.getSound('sMetalMusic').play();
+ var metalMusic = LK.getSound('sMetalMusic');
+ metalMusic.loop = true;
+ metalMusic.play();
}, 1000);
LK.setTimeout(function () {
LK.getSound('sHohoho').play();
}, 500);
a top view of a 16 bit sprite santa with a bazooka Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
16 bit sprite of a christmas ornament Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
16 bit sprite of a red eyed christmas elf Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
16 bit sprite of a blood splatter Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
16 bit sprite of a red eye reindeer Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
16 bit sprite of a red eye mother christmas Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
16 bit top view background of a christmas field set in hell Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
16 bit smoke Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
16 bit wall of skulls with red eyes Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
"Death Is Inevitable" Text Bubble Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
16 bit CHRISTMAS bomb power up icon. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.