User prompt
build a level structure in the game. each level will have a defined number of waves, enemy2 and a boss.
User prompt
improve game performance
User prompt
Please fix the bug: 'ReferenceError: enemies is not defined' in or related to this line: 'enemies.push(newBlock);' Line Number: 504
User prompt
rename enemies to blocks
User prompt
create levels to make the game more interesting
Code edit (1 edits merged)
Please save this source code
User prompt
spawn fairy 200 pixels higher
User prompt
when fairy image is mirrored move fairy particles 30 pixels to the right
User prompt
move fairy particles 30 pixels to the left
User prompt
make sure ghost image is also mirrored when going right
User prompt
Please fix the bug: 'ReferenceError: Boss is not defined' in or related to this line: 'if (bullets[k].intersects(enemies[l]) && !(enemies[l] instanceof Boss)) {' Line Number: 571
User prompt
make sure boss enemy tupe uses the asset selected int he wave configuration
Code edit (1 edits merged)
Please save this source code
User prompt
When a wave has boss type, also allow to select the asset this boss will use
User prompt
if enemy type is boss, it should move in the top 1/3 of the screen and shoot bullets downards
Code edit (1 edits merged)
Please save this source code
User prompt
add an attribute to define what type of enemy it is in the waveconfig
User prompt
do not respawn enemies after powerup menu
User prompt
Please fix the bug: 'ReferenceError: enemies is not defined' in or related to this line: 'if (enemies.length === 0) {' Line Number: 612
User prompt
rename enemies to blocks
User prompt
use shield asset for shield up
User prompt
shield should be destroy and destroy an enemy on touch
User prompt
shield should move in the same places like the fairy
User prompt
when shield up is selected...ad a shield around the fairy that lasts until fairy hits with an enemy
Code edit (1 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -1,21 +1,7 @@
/****
* Classes
****/
-// Boss class
-var Boss = Container.expand(function () {
- var self = Container.call(this);
- var bossGraphics = self.attachAsset('boss1', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.speed = 2;
- self.hitpoints = 10; // Boss has more hitpoints
- self.update = function () {
- self.y += self.speed;
- // Boss-specific behavior can be added here
- };
-});
// Bullet class
var Bullet = Container.expand(function () {
var self = Container.call(this);
var bulletGraphics = self.attachAsset('bullet', {
@@ -127,13 +113,8 @@
if (self.particles[i].alpha <= 0) {
self.particles.splice(i, 1);
}
}
- // Update shield position to follow the fairy
- if (self.shield) {
- self.shield.x = self.x;
- self.shield.y = self.y;
- }
// Fairy movement logic
};
});
// Powerup class
@@ -166,56 +147,8 @@
self.x = Math.random() * 2048;
}
};
});
-var UpgradeOption = Container.expand(function (text, onClick) {
- var self = Container.call(this);
- var assetId;
- if (text === "Increase Fire Rate") {
- assetId = 'fireRateButton';
- } else if (text === "Increase Damage") {
- assetId = 'damageButton';
- } else if (text === "Increase Health") {
- assetId = 'healthButton';
- }
- if (assetId) {
- var optionGraphics = self.attachAsset(assetId, {
- anchorX: 0.5,
- anchorY: 0.5
- });
- }
- var optionText = new Text2(text, {
- size: 100,
- fill: "#ffffff",
- stroke: "#000000",
- strokeThickness: 5
- });
- optionText.anchor.set(0.5, 0.5);
- self.addChild(optionText);
- self.interactive = true;
- self.on('down', function (x, y, obj) {
- // Remove upgrade options from the game
- for (var i = game.children.length - 1; i >= 0; i--) {
- if (game.children[i] instanceof UpgradeOption) {
- game.children[i].destroy();
- }
- }
- // Apply the upgrade
- onClick();
- // Multiply hitpoints of blocks by 2
- for (var i = 0; i < waveConfig.length; i++) {
- for (var j = 0; j < waveConfig[i].hitpoints.length; j++) {
- waveConfig[i].hitpoints[j] *= 2;
- }
- }
- // Resume game and spawning waves
- bulletDamage += 1;
- game.paused = false;
- if (!game.paused) {
- spawnNextWave();
- }
- });
-});
/****
* Initialize Game
****/
@@ -225,90 +158,9 @@
/****
* Game Code
****/
-function shieldUp() {
- // Logic to add shield to the fairy
- if (!fairy.shield) {
- fairy.shield = LK.getAsset('shield', {
- anchorX: 0.5,
- anchorY: 0.5,
- alpha: 0.5
- });
- fairy.shield.x = fairy.x;
- fairy.shield.y = fairy.y;
- game.addChild(fairy.shield);
- }
- game.paused = false;
-}
-var bulletDamage = 1; // Initialize bullet damage to 1
-function spawnNextWave() {
- if (waveCount > waveConfig.length) {
- waveCount = 1; // Reset wave count to 1 if all waves are complete
- // Add 1 hit point to each enemy
- for (var i = 0; i < waveConfig.length; i++) {
- for (var j = 0; j < waveConfig[i].hitpoints.length; j++) {
- waveConfig[i].hitpoints[j]++;
- }
- }
- }
- var currentWave = waveConfig[waveCount - 1];
- var maxEnemiesPerLine = 3;
- var enemySpacing = 2048 / (maxEnemiesPerLine + 1); // Adjust spacing to center enemies
- var totalRows = Math.ceil(currentWave.enemies / maxEnemiesPerLine);
- for (var i = 0; i < currentWave.enemies; i++) {
- var newBlock = new Enemy();
- var row = Math.floor(i / maxEnemiesPerLine);
- newBlock.hitpoints = currentWave.hitpoints[row] || currentWave.hitpoints[currentWave.hitpoints.length - 1];
- newBlock.x = i % maxEnemiesPerLine * enemySpacing + enemySpacing / 2 - newBlock.width / 2;
- newBlock.y = row * 220 - 50; // Increase row spacing by 20 pixels
- newBlock.children[0].tint = currentWave.tints[row] || currentWave.tints[currentWave.tints.length - 1];
- enemies.push(newBlock);
- game.addChild(newBlock);
- }
- // Center the rows of enemies
- var totalWidth = (Math.min(currentWave.enemies, maxEnemiesPerLine) - 1) * enemySpacing;
- var offsetX = (2048 - totalWidth) / 2;
- for (var j = 0; j < enemies.length; j++) {
- enemies[j].x += offsetX - enemies[j].width / 2;
- }
-}
-function showUpgradeOptions() {
- var options = [{
- text: "Increase Fire Rate",
- onClick: function onClick() {
- increaseFireRate();
- }
- }, {
- text: "Increase Damage",
- onClick: function onClick() {
- increaseDamage();
- }
- }, {
- text: "Shield Up",
- onClick: function onClick() {
- shieldUp();
- }
- }];
- var optionSpacing = 300;
- for (var i = 0; i < options.length; i++) {
- var option = new UpgradeOption(options[i].text, options[i].onClick);
- option.x = 2048 / 2;
- option.y = 2732 / 2 - optionSpacing + i * optionSpacing;
- game.addChild(option);
- }
-}
-function increaseFireRate() {
- // Logic to increase fire rate
- bulletSpawnRate = Math.max(10, bulletSpawnRate - 5); // Increase fire rate by decreasing spawn rate interval
- game.paused = false;
-}
-function increaseDamage() {
- // Logic to increase damage
- game.paused = false;
-}
// Initialize variables
-var bulletSpawnRate = 30; // Default bullet spawn rate
var fairy;
var bullets = [];
var enemies = [];
var scoreTxt;
@@ -361,9 +213,19 @@
scoreTxt.anchor.set(0.5, 0);
// Create coin counter text
game.addChild(scoreTxt);
// Create coin counter text
- // Removed the menu overlay from the top of the screen
+ var overlay = LK.getAsset('menu', {
+ width: 2048,
+ height: 250,
+ color: 0x000000,
+ alpha: 0.5,
+ anchorX: 0.5,
+ anchorY: 0
+ });
+ overlay.x = 2048 / 2;
+ overlay.y = 0;
+ game.addChild(overlay);
var diamondCounterContainer = new Container();
var diamondIcon = LK.getAsset('diamond', {
anchorX: 1,
anchorY: 0,
@@ -422,8 +284,11 @@
game.addChildAt(ghostFairy, game.getChildIndex(dragNode));
} else {
game.addChild(ghostFairy);
}
+ if (dragNode.scale.x === -1) {
+ ghostFairy.scale.x = -1;
+ }
// Remove the ghost image after 0.5 seconds
LK.setTimeout(function () {
ghostFairy.destroy();
}, 250);
@@ -466,46 +331,39 @@
enemies[j].destroy();
enemies.splice(j, 1);
}
if (fairy.intersects(enemies[j])) {
- if (fairy.shield) {
- fairy.shield.destroy();
- fairy.shield = null;
- enemies[j].destroy();
- enemies.splice(j, 1);
- } else {
- var fairyX = fairy.x;
- var fairyY = fairy.y;
- // Create particle effect for fairy
- for (var p = 0; p < 10; p++) {
- var particle = LK.getAsset('star', {
- anchorX: 0.5,
- anchorY: 0.5,
- alpha: 1
- });
- particle.x = fairyX;
- particle.y = fairyY;
- particle.speedX = (Math.random() - 0.5) * 10;
- particle.speedY = (Math.random() - 0.5) * 10;
- particle.update = function () {
- this.x += this.speedX;
- this.y += this.speedY;
- this.alpha -= 0.02;
- if (this.alpha <= 0) {
- this.destroy();
- }
- };
- game.addChild(particle);
- }
- LK.effects.flashScreen(0xff0000, 1000);
- LK.showGameOver();
+ var fairyX = fairy.x;
+ var fairyY = fairy.y;
+ // Create particle effect for fairy
+ for (var p = 0; p < 10; p++) {
+ var particle = LK.getAsset('star', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ alpha: 1
+ });
+ particle.x = fairyX;
+ particle.y = fairyY;
+ particle.speedX = (Math.random() - 0.5) * 10;
+ particle.speedY = (Math.random() - 0.5) * 10;
+ particle.update = function () {
+ this.x += this.speedX;
+ this.y += this.speedY;
+ this.alpha -= 0.02;
+ if (this.alpha <= 0) {
+ this.destroy();
+ }
+ };
+ game.addChild(particle);
}
+ LK.effects.flashScreen(0xff0000, 1000);
+ LK.showGameOver();
}
for (var k = bullets.length - 1; k >= 0; k--) {
if (bullets[k].intersects(enemies[j])) {
bullets[k].destroy();
bullets.splice(k, 1);
- enemies[j].hitpoints -= bulletDamage;
+ enemies[j].hitpoints--;
if (enemies[j].hitpoints <= 0) {
var enemyX = enemies[j].x;
var enemyY = enemies[j].y;
// Create particle effect
@@ -597,9 +455,9 @@
}
}
}
// Spawn new bullets
- if (LK.ticks % bulletSpawnRate == 0 && isFairyHeld) {
+ if (LK.ticks % 30 == 0 && isFairyHeld) {
// Only spawn new bullets if the fairy is being held
var newBullet = new Bullet();
newBullet.x = fairy.x;
newBullet.y = fairy.y - fairy.height / 2;
@@ -613,12 +471,14 @@
}
if (waveCount <= waveConfig.length || enemies.length === 0) {
if (waveCount > waveConfig.length) {
waveCount = 1; // Reset wave count to 1 if all waves are complete
- // Pause the game and show upgrade options
- game.paused = true;
- showUpgradeOptions();
- return; // Prevent spawning new waves until an upgrade is chosen
+ // Add 1 hit point to each enemy
+ for (var i = 0; i < waveConfig.length; i++) {
+ for (var j = 0; j < waveConfig[i].hitpoints.length; j++) {
+ waveConfig[i].hitpoints[j]++;
+ }
+ }
}
var currentWave = waveConfig[waveCount - 1];
var maxEnemiesPerLine = 3;
var enemySpacing = 2048 / (maxEnemiesPerLine + 1); // Adjust spacing to center enemies
8-bit. cartoon. white star.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
cartoon 8 bit fairy dust. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Cartoon, 8bit, fireball. Black border. Cicular.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
cartoon, 8 bit, shield. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
8bit, cartoon, axe. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
dark electric ball, 8bit, cartoon.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
8bit, cartoon, treasure chest frame. very big empty center. only a fine border of chest. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
shoot
Sound effect
boom
Sound effect
Hit
Sound effect
backgroundmusic
Sound effect
bossbullet
Sound effect
bossappear
Sound effect
hit
Sound effect
diamondcollect
Sound effect
hooray
Sound effect
nono
Sound effect
letsgo
Sound effect
death
Sound effect
yes
Sound effect