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,7 +1,43 @@
/****
* Classes
****/
+// Block class
+var Block = Container.expand(function () {
+ var self = Container.call(this);
+ var blockGraphics = self.attachAsset('block', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ tint: 0xffffff // Default tint, will be overridden by wave configuration
+ });
+ self.speed = 3;
+ self.hitpoints = 3; // Add hitpoints to blocks
+ self.update = function () {
+ self.y += self.speed;
+ // Logic to increase and decrease block sizes
+ if (LK.ticks % 120 < 60) {
+ self.scale.x += 0.002;
+ self.scale.y += 0.002;
+ } else {
+ self.scale.x -= 0.002;
+ self.scale.y -= 0.002;
+ }
+ // Create and update hitpoints display
+ if (!self.hitpointsDisplay) {
+ self.hitpointsDisplay = new Text2(self.hitpoints.toString(), {
+ size: 100,
+ fill: "#ffffff",
+ stroke: "#000000",
+ strokeThickness: 5
+ });
+ self.hitpointsDisplay.anchor.set(0.5, 0.5);
+ self.hitpointsDisplay.y = 0;
+ self.addChild(self.hitpointsDisplay);
+ } else if (LK.ticks % 10 === 0) {
+ self.hitpointsDisplay.setText(self.hitpoints.toString());
+ }
+ };
+});
// Bullet class
var Bullet = Container.expand(function () {
var self = Container.call(this);
var bulletGraphics = self.attachAsset('bullet', {
@@ -35,44 +71,8 @@
self.destroy();
}
};
});
-// Enemy class
-var Enemy = Container.expand(function () {
- var self = Container.call(this);
- var enemyGraphics = self.attachAsset('block', {
- anchorX: 0.5,
- anchorY: 0.5,
- tint: 0xffffff // Default tint, will be overridden by wave configuration
- });
- self.speed = 3;
- self.hitpoints = 3; // Add hitpoints to enemies
- self.update = function () {
- self.y += self.speed;
- // Logic to increase and decrease block sizes
- if (LK.ticks % 120 < 60) {
- self.scale.x += 0.002;
- self.scale.y += 0.002;
- } else {
- self.scale.x -= 0.002;
- self.scale.y -= 0.002;
- }
- // Create and update hitpoints display
- if (!self.hitpointsDisplay) {
- self.hitpointsDisplay = new Text2(self.hitpoints.toString(), {
- size: 100,
- fill: "#ffffff",
- stroke: "#000000",
- strokeThickness: 5
- });
- self.hitpointsDisplay.anchor.set(0.5, 0.5);
- self.hitpointsDisplay.y = 0;
- self.addChild(self.hitpointsDisplay);
- } else if (LK.ticks % 10 === 0) {
- self.hitpointsDisplay.setText(self.hitpoints.toString());
- }
- };
-});
//<Assets used in the game will automatically appear here>
// Fairy class
var Fairy = Container.expand(function () {
var self = Container.call(this);
@@ -247,16 +247,16 @@
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);
+ blocks.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;
+ for (var j = 0; j < blocks.length; j++) {
+ blocks[j].x += offsetX - blocks[j].width / 2;
}
}
function showUpgradeOptions() {
var options = [{
@@ -295,9 +295,9 @@
// Initialize variables
var bulletSpawnRate = 30; // Default bullet spawn rate
var fairy;
var bullets = [];
-var enemies = [];
+var blocks = [];
var scoreTxt;
var score = 0;
var dragNode = null;
var diamondCount = 0; // Initialize diamond counter
@@ -445,20 +445,20 @@
bullets[i].destroy();
bullets.splice(i, 1);
}
}
- for (var j = enemies.length - 1; j >= 0; j--) {
- enemies[j].update();
- if (enemies[j].y > 2732 + 50) {
- enemies[j].destroy();
- enemies.splice(j, 1);
+ for (var j = blocks.length - 1; j >= 0; j--) {
+ blocks[j].update();
+ if (blocks[j].y > 2732 + 50) {
+ blocks[j].destroy();
+ blocks.splice(j, 1);
}
- if (fairy.intersects(enemies[j])) {
+ if (fairy.intersects(blocks[j])) {
if (fairy.shield) {
fairy.shield.destroy();
fairy.shield = null;
- enemies[j].destroy();
- enemies.splice(j, 1);
+ blocks[j].destroy();
+ blocks.splice(j, 1);
} else {
var fairyX = fairy.x;
var fairyY = fairy.y;
// Create particle effect for fairy
@@ -486,27 +486,27 @@
LK.showGameOver();
}
}
for (var k = bullets.length - 1; k >= 0; k--) {
- if (bullets[k].intersects(enemies[j])) {
+ if (bullets[k].intersects(blocks[j])) {
bullets[k].destroy();
bullets.splice(k, 1);
- enemies[j].hitpoints -= bulletDamage;
- if (enemies[j].hitpoints <= 0) {
- var enemyX = enemies[j].x;
- var enemyY = enemies[j].y;
+ blocks[j].hitpoints -= bulletDamage;
+ if (blocks[j].hitpoints <= 0) {
+ var blockX = blocks[j].x;
+ var blockY = blocks[j].y;
// Create particle effect
for (var p = 0; p < 20; p++) {
var particle = LK.getAsset('star', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 1,
scaleX: 2,
scaleY: 2,
- tint: enemies[j].children[0].tint
+ tint: blocks[j].children[0].tint
});
- particle.x = enemyX;
- particle.y = enemyY;
+ particle.x = blockX;
+ particle.y = blockY;
particle.speedX = (Math.random() - 0.5) * 10;
particle.speedY = (Math.random() - 0.5) * 10;
particle.update = function () {
this.x += this.speedX;
@@ -517,24 +517,24 @@
}
};
game.addChild(particle);
}
- enemies[j].destroy();
- enemies.splice(j, 1);
- if (enemies[j]) {
- score += enemies[j].hitpoints * 10;
+ blocks[j].destroy();
+ blocks.splice(j, 1);
+ if (blocks[j]) {
+ score += blocks[j].hitpoints * 10;
}
scoreTxt.setText(score);
var dropChance = Math.random();
if (dropChance < 0.2) {
var newDiamond = new Diamond();
- newDiamond.x = enemyX;
- newDiamond.y = enemyY;
+ newDiamond.x = blockX;
+ newDiamond.y = blockY;
game.addChild(newDiamond);
} else if (dropChance < 0.2) {
var newPowerup = new Powerup();
- newPowerup.x = enemyX;
- newPowerup.y = enemyY;
+ newPowerup.x = blockX;
+ newPowerup.y = blockY;
game.addChild(newPowerup);
}
}
break;
@@ -550,33 +550,33 @@
diamondCounterTxt.setText('Diamonds: ' + diamondCount);
}
}
for (var k = bullets.length - 1; k >= 0; k--) {
- for (var l = enemies.length - 1; l >= 0; l--) {
- if (bullets[k].intersects(enemies[l]) && !(enemies[l] instanceof Boss)) {
+ for (var l = blocks.length - 1; l >= 0; l--) {
+ if (bullets[k].intersects(blocks[l]) && !(blocks[l] instanceof Boss)) {
bullets[k].destroy();
bullets.splice(k, 1);
- enemies[l].hitpoints--;
- if (enemies[l].hitpoints <= 0) {
- var enemyX = enemies[l].x;
- var enemyY = enemies[l].y;
- enemies[l].destroy();
- enemies.splice(l, 1);
- if (enemies[l]) {
- score += enemies[l].hitpoints * 10;
+ blocks[l].hitpoints--;
+ if (blocks[l].hitpoints <= 0) {
+ var blockX = blocks[l].x;
+ var blockY = blocks[l].y;
+ blocks[l].destroy();
+ blocks.splice(l, 1);
+ if (blocks[l]) {
+ score += blocks[l].hitpoints * 10;
}
scoreTxt.setText(score);
// Randomly drop coins or powerups
var dropChance = Math.random();
if (dropChance < 0.2) {
var newDiamond = new Diamond();
- newDiamond.x = enemyX;
- newDiamond.y = enemyY;
+ newDiamond.x = blockX;
+ newDiamond.y = blockY;
game.addChild(newDiamond);
} else if (dropChance < 0.2) {
var newPowerup = new Powerup();
- newPowerup.x = enemyX;
- newPowerup.y = enemyY;
+ newPowerup.x = blockX;
+ newPowerup.y = blockY;
game.addChild(newPowerup);
}
}
break;
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