User prompt
fix it so i can hear the background music
User prompt
add backround music please
User prompt
add and option for the user to turn sound on or off for the game add the option left down corner
User prompt
find a fix so i can hear background music
User prompt
make sure the background music can be heard and its playing automaticly
User prompt
add music intense as the background music for the game
User prompt
i want some music to be playing to make ppl enjoy the game
User prompt
find why i cannot heart it
User prompt
set the volume to 50 when the background music starts
User prompt
find why i cannot hear the background sound
User prompt
still i cannot hear it , find a fix
User prompt
add my new asset called intense for the background music
User prompt
make the sound play for the whole duration then repeat itself
User prompt
add the music for the background in the game
User prompt
still cant hear it
User prompt
i cannot head the background music
User prompt
add the arrow sound so whenever i shoot an arrow from the hero the sound comes
User prompt
the dngmusic asset i want to be played as the background music
User prompt
play background music when the game starts
User prompt
Please fix the bug: 'ReferenceError: NewMonster is not defined' in or related to this line: 'var newMonster = new NewMonster();' Line Number: 379
User prompt
Seems like there is an issue and the game stops after the boss, fix it
Remix started
Copy Dungeon Cry
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
// BigBoss class
var BigBoss = Container.expand(function () {
var self = Container.call(this);
var bossGraphics = self.attachAsset('bigBoss', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 2;
self.health = 500; // Big boss has 500 health
self.update = function () {
// Move boss towards the hero
var dx = hero.x - self.x;
var dy = hero.y - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance > 0) {
self.x += dx / distance * self.speed * 0.5;
self.y += dy / distance * self.speed * 0.5;
}
// Boss can shoot bullets at the hero
if (LK.ticks % 150 == 0) {
var bullet = new Bullet();
bullet.x = self.x;
bullet.y = self.y;
game.addChild(bullet);
}
};
self.healthBar = self.addChild(LK.getAsset('lifebar', {
anchorX: 0.5,
anchorY: 1.0,
y: -bossGraphics.height / 2 - 10
}));
self.damage = function (amount) {
self.health -= amount;
self.healthBar.scaleX = self.health / 2500; // Update health bar scale
if (self.health <= 0) {
self.destroy(); // Destroy the boss if health is 0 or less
var index = enemies.indexOf(self);
if (index > -1) {
enemies.splice(index, 1);
}
}
};
});
// Bomb class
var Bomb = Container.expand(function () {
var self = Container.call(this);
var bombGraphics = self.attachAsset('bomb', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 5;
self.update = function () {
self.y += self.speed;
};
});
// Bullet class
var Bullet = Container.expand(function () {
var self = Container.call(this);
var bulletGraphics = self.attachAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 15;
self.update = function () {
self.y -= self.speed;
};
});
// Enemy class
var Enemy = Container.expand(function () {
var self = Container.call(this);
var enemyGraphics = self.attachAsset('enemy', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 5;
self.health = 100; // Initialize health for the enemy
self.update = function () {
// Move goblins towards the hero
var dx = hero.x - self.x;
var dy = hero.y - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance > 0) {
self.x += dx / distance * self.speed * 0.5; // Move at half speed towards hero
self.y += dy / distance * self.speed * 0.5;
}
};
self.damage = function (amount) {
// Function to apply damage to the enemy
self.health -= amount;
if (self.health <= 0) {
self.destroy(); // Destroy the enemy if health is 0 or less
}
};
});
//<Assets used in the game will automatically appear here>
//<Write imports for supported plugins here>
// Hero class
var Hero = Container.expand(function () {
var self = Container.call(this);
var heroGraphics = self.attachAsset('hero', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 10;
self.update = function () {
// Hero update logic
};
self.damage = function () {
LK.showGameOver();
};
});
// NewMonster class
var NewMonster = Container.expand(function () {
var self = Container.call(this);
var monsterGraphics = self.attachAsset('enemy', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 5;
self.health = 150; // Initialize health for the new monster
self.update = function () {
// Move new monster towards the hero
var dx = hero.x - self.x;
var dy = hero.y - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance > 0) {
self.x += dx / distance * self.speed * 0.5;
self.y += dy / distance * self.speed * 0.5;
}
};
self.damage = function (amount) {
// Function to apply damage to the new monster
self.health -= amount;
if (self.health <= 0) {
self.destroy(); // Destroy the new monster if health is 0 or less
}
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000 //Init game with black background
});
/****
* Game Code
****/
//<Write imports for supported plugins here>
//<Assets used in the game will automatically appear here>
var background = game.attachAsset('background', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2
});
function initializeGame() {
var background = game.attachAsset('background', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2
});
// Play 'intense' as the background music when the game starts
LK.playMusic('intense', {
loop: true,
fade: {
start: 0,
end: 0.5,
// Set volume to 50%
duration: 1000
}
});
// Initialize hero
var hero = game.addChild(new Hero());
hero.x = 2048 / 2;
hero.y = 2732 - 200;
// Initialize enemies
var enemies = [];
for (var i = 0; i < 5; i++) {
var enemy = new Enemy();
enemy.x = Math.random() * 2048;
enemy.y = Math.random() * 1000;
enemies.push(enemy);
game.addChild(enemy);
LK.effects.flashObject(enemy, 0xFFFFFF, 500);
}
// Initialize bullets
var bullets = [];
// Initialize golden coins
var goldenCoins = [];
// Initialize enemies killed count
var enemiesKilled = 0;
// Create score display
var scoreDisplay = new Text2('Score: ' + LK.getScore(), {
size: 50,
fill: 0xFFFFFF
});
scoreDisplay.anchor.set(1, 0);
LK.gui.topRight.addChild(scoreDisplay);
// Function to update and animate the score display
function updateScoreDisplay() {
scoreDisplay.setText('Score: ' + LK.getScore());
tween(scoreDisplay, {
scaleX: 1.5,
scaleY: 1.5,
fill: 0xFFD700
}, {
duration: 200,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(scoreDisplay, {
scaleX: 1,
scaleY: 1,
fill: 0xFFFFFF
}, {
duration: 200,
easing: tween.easeIn
});
}
});
}
// Initialize current wave
var currentWave = 0;
// Initialize level
var level = 1;
// Create game title
var gameTitle = new Text2('Dungeon Cry', {
size: 50,
fill: 0xFFFFFF
});
gameTitle.anchor.set(0, 0);
LK.gui.topLeft.addChild(gameTitle);
// Animate the game title
tween(gameTitle, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 500,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(gameTitle, {
scaleX: 1,
scaleY: 1
}, {
duration: 500,
easing: tween.easeIn
});
}
});
// Create level display
var levelDisplay = new Text2('Level: ' + level, {
size: 50,
fill: 0xFFFFFF
});
levelDisplay.anchor.set(0.5, 0);
LK.gui.top.addChild(levelDisplay);
// Create sound toggle button
var soundToggleButton = new Text2('Sound: On', {
size: 50,
fill: 0xFFFFFF
});
soundToggleButton.anchor.set(0, 1); // Anchor to the bottom-left corner
soundToggleButton.x = 0;
soundToggleButton.y = 2732;
LK.gui.bottomLeft.addChild(soundToggleButton);
// Variable to track sound state
var isSoundOn = true;
// Function to toggle sound
function toggleSound() {
isSoundOn = !isSoundOn;
if (isSoundOn) {
LK.getSound('arrow').volume = 1;
LK.getSound('goblin').volume = 1;
LK.playMusic('intense', {
loop: true
});
soundToggleButton.setText('Sound: On');
} else {
LK.getSound('arrow').volume = 0;
LK.getSound('goblin').volume = 0;
LK.stopMusic();
soundToggleButton.setText('Sound: Off');
}
}
// Add event listener to toggle sound on button press
soundToggleButton.down = function () {
toggleSound();
};
}
// Initialize hero
var hero = game.addChild(new Hero());
hero.x = 2048 / 2;
hero.y = 2732 - 200;
// Initialize enemies
var enemies = [];
for (var i = 0; i < 5; i++) {
var enemy = new Enemy();
enemy.x = Math.random() * 2048;
enemy.y = Math.random() * 1000;
enemies.push(enemy);
game.addChild(enemy);
// Add spawn effect to the enemy
LK.effects.flashObject(enemy, 0xFFFFFF, 500);
}
// Initialize bullets
var bullets = [];
// Initialize golden coins
var goldenCoins = [];
// Initialize enemies killed count
var enemiesKilled = 0;
// Create score display
var scoreDisplay = new Text2('Score: ' + LK.getScore(), {
size: 50,
fill: 0xFFFFFF
});
scoreDisplay.anchor.set(1, 0); // Anchor to the top-right corner
LK.gui.topRight.addChild(scoreDisplay);
// Function to update and animate the score display
function updateScoreDisplay() {
scoreDisplay.setText('Score: ' + LK.getScore());
tween(scoreDisplay, {
scaleX: 1.5,
scaleY: 1.5,
fill: 0xFFD700 // Change color to gold during animation
}, {
duration: 200,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(scoreDisplay, {
scaleX: 1,
scaleY: 1,
fill: 0xFFFFFF // Revert color back to white
}, {
duration: 200,
easing: tween.easeIn
});
}
});
}
// Initialize current wave
var currentWave = 0;
// Initialize level
var level = 1;
// Create game title
var gameTitle = new Text2('Dungeon Cry', {
size: 50,
fill: 0xFFFFFF
});
gameTitle.anchor.set(0, 0);
LK.gui.topLeft.addChild(gameTitle);
// Animate the game title
tween(gameTitle, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 500,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(gameTitle, {
scaleX: 1,
scaleY: 1
}, {
duration: 500,
easing: tween.easeIn
});
}
});
// Create level display
var levelDisplay = new Text2('Level: ' + level, {
size: 50,
fill: 0xFFFFFF
});
levelDisplay.anchor.set(0.5, 0);
LK.gui.top.addChild(levelDisplay);
// Game update logic
game.update = function () {
// Update hero
hero.update();
// Define waves
var waves = [{
count: 5,
type: 'enemy',
speed: 5
}, {
count: 10,
type: 'enemy',
speed: 7
}, {
count: 15,
type: 'enemy',
speed: 10
}, {
count: 10,
type: 'mixed',
// Mix of skeletons and goblins
speed: 12
}];
var currentWave = 0;
var enemiesToSpawn = waves[currentWave].count;
// Update enemies
for (var i = enemies.length - 1; i >= 0; i--) {
enemies[i].update();
if (enemies[i].y > 2732) {
enemies[i].destroy();
enemies.splice(i, 1);
}
// Check for collision between enemy and hero
if (enemies[i].intersects(hero)) {
LK.showGameOver(); // End game when a goblin touches the hero
}
}
// Spawn new enemies
if (enemies.length == 0) {
if (level === 10) {
// Spawn BigBoss at level 10
var bigBoss = new BigBoss();
bigBoss.x = 2048 / 2;
bigBoss.y = 100;
enemies.push(bigBoss);
game.addChild(bigBoss);
LK.effects.flashObject(bigBoss, 0xFFFFFF, 500);
} else if (level === 11) {
// Change background and spawn new type of monsters
enemiesToSpawn = 10;
for (var i = 0; i < enemiesToSpawn; i++) {
var newMonster = new NewMonster();
newMonster.x = Math.random() * 2048;
newMonster.y = Math.random() * 1000;
enemies.push(newMonster);
game.addChild(newMonster);
LK.effects.flashObject(newMonster, 0xFFFFFF, 500);
}
} else if (level >= 15 && waves[currentWave].type === 'mixed') {
enemiesToSpawn = 10;
for (var i = 0; i < enemiesToSpawn; i++) {
var enemy;
if (i % 2 === 0) {
enemy = new Enemy(); // Goblin
} else {
enemy = new NewMonster(); // Skeleton
}
enemy.speed = waves[currentWave].speed + level;
enemy.x = Math.random() * 2048;
enemy.y = Math.random() * 1000;
enemies.push(enemy);
game.addChild(enemy);
LK.effects.flashObject(enemy, 0xFFFFFF, 500);
}
} else {
enemiesToSpawn = 10;
for (var i = 0; i < enemiesToSpawn; i++) {
var enemy = new Enemy();
enemy.speed = waves[currentWave].speed + level;
enemy.x = Math.random() * 2048;
enemy.y = Math.random() * 1000;
enemies.push(enemy);
game.addChild(enemy);
LK.effects.flashObject(enemy, 0xFFFFFF, 500);
}
}
currentWave++;
level++; // Increase the level
levelDisplay.setText('Level: ' + level); // Update the level display
}
// Update bullets
for (var j = bullets.length - 1; j >= 0; j--) {
bullets[j].update();
if (bullets[j].y < 0) {
bullets[j].destroy();
bullets.splice(j, 1);
}
}
// Collision detection
for (var k = bullets.length - 1; k >= 0; k--) {
for (var l = enemies.length - 1; l >= 0; l--) {
if (bullets[k].intersects(enemies[l])) {
bullets[k].destroy();
bullets.splice(k, 1);
if (enemies[l] && enemies[l] instanceof BigBoss) {
enemies[l].damage(10); // Deal 10 damage to BigBoss
if (enemies[l] && enemies[l].health <= 0) {
enemies.splice(l, 1); // Remove BigBoss from enemies array
level++; // Increase the level after BigBoss is defeated
levelDisplay.setText('Level: ' + level); // Update the level display
// Continue the game without triggering game over
}
} else if (enemies[l] && enemies[l].health !== undefined) {
// Check if enemy exists before accessing its properties
var enemyX = enemies[l].x;
var enemyY = enemies[l].y;
enemies[l].destroy();
enemies.splice(l, 1);
enemiesKilled++;
// Increase the score by 10
LK.setScore(LK.getScore() + 10);
updateScoreDisplay();
}
break;
}
}
}
};
// Handle game input
game.down = function (x, y, obj) {
var bullet = new Bullet();
bullet.x = hero.x;
bullet.y = hero.y;
bullets.push(bullet);
game.addChild(bullet);
// Play arrow sound when shooting
LK.getSound('arrow').play();
// Add flash effect to hero when shooting
LK.effects.flashObject(hero, 0xFFFFFF, 100);
};
game.move = function (x, y, obj) {
hero.x = x;
hero.y = y;
};
// Collision detection for bombs and hero
for (var i = game.children.length - 1; i >= 0; i--) {
var child = game.children[i];
if (child instanceof Bomb) {
if (child.lastWasIntersecting === undefined) {
child.lastWasIntersecting = false;
}
if (!child.lastWasIntersecting && child.intersects(hero)) {
child.destroy();
hero.damage(); // Call the damage method of the hero which will trigger game over
LK.showGameOver(); // Ensure game over is shown when hero is hit by a bomb
}
child.lastWasIntersecting = child.intersects(hero);
}
}
// Collision detection
for (var k = bullets.length - 1; k >= 0; k--) {
for (var l = enemies.length - 1; l >= 0; l--) {
if (bullets[k].intersects(enemies[l])) {
bullets[k].destroy();
bullets.splice(k, 1);
enemies[l].destroy();
enemies.splice(l, 1);
enemiesKilled++;
// Increase the score by 10
LK.setScore(LK.getScore() + 10);
updateScoreDisplay();
break;
}
}
} ===================================================================
--- original.js
+++ change.js
2d pixel goblin. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
create me a dark 2d pixel arrow. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
create me a 2d pixel dark archer. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
create me a 2d pixel bomb. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
create me a 2d pixel dark dungeon. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
gold coin 2d pixel. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
create me a big furious goblin with armor 2d and pixel. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
create a 2d pixel healthbar. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.