Code edit (1 edits merged)
Please save this source code
User prompt
make sure coin counter is displayed on the top right of the screen. adjust anchor so that it set correctly
User prompt
add a coint counter on the top right and make player collect coins when they collide
User prompt
when blocks are destroyed they can randomly drop coins or powerups
User prompt
Please fix the bug: 'ReferenceError: Block is not defined' in or related to this line: 'var newBlock = new Block();' Line Number: 213
User prompt
change enemy reference to block
User prompt
reduce a lot the ammout of stars in starfield
User prompt
center enemies on screen
User prompt
reduce enemy spacing on x
User prompt
reduce the side distance of enemies
Code edit (2 edits merged)
Please save this source code
User prompt
allow player to define a hitpoint per row per wave
User prompt
add more distance between row when more than one in a wave
User prompt
max enemies per line are 6, if wave has more enemies, the remaining enemies should be on top
User prompt
make sure to update the hitpoints of enemies with the number defined in the wave
User prompt
add a config setting to define how many enemies and how many hitpoints will those have in each wave
User prompt
first wave enemies will only have 1 hitpoint.
User prompt
enemies will be spawned by 6 one next to each other
User prompt
wait for 10 seconds between enemy waves
User prompt
each bullet will decrease one hit point and enemy will be destroyed when hitpoints is zero
User prompt
show hitpoints bellow each enemy
User prompt
add hitpoints to enemies
Code edit (1 edits merged)
Please save this source code
User prompt
eemies should be spawned in waves
User prompt
add starfield in the backgorund, moveing from down up
/****
* Classes
****/
// 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 = -10;
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 = 3;
self.update = function () {
self.y += self.speed;
};
});
//<Assets used in the game will automatically appear here>
// Fairy class
var Fairy = Container.expand(function () {
var self = Container.call(this);
var fairyGraphics = self.attachAsset('fairy', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 5;
self.update = function () {
// Fairy movement logic
};
});
// Star class
var Star = Container.expand(function () {
var self = Container.call(this);
var starGraphics = self.attachAsset('star', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 5;
self.update = function () {
self.y += self.speed;
if (self.y > 2732) {
self.y = -5;
self.x = Math.random() * 2048;
}
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000 //Init game with black background
});
/****
* Game Code
****/
// Initialize variables
var fairy;
var bullets = [];
var enemies = [];
var scoreTxt;
var score = 0;
var dragNode = null;
var isFairyHeld = false; // Track if the fairy is being held
// Initialize game elements
function initGame() {
// Create and position the fairy
fairy = game.addChild(new Fairy());
fairy.x = 2048 / 2;
fairy.y = 2732 - 200;
// Create score text
scoreTxt = new Text2('0', {
size: 150,
fill: "#ffffff"
});
// Create starfield
for (var i = 0; i < 500; i++) {
var star = game.addChild(new Star());
star.x = Math.random() * 2048;
star.y = Math.random() * 2732;
}
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Set up game event listeners
game.down = function (x, y, obj) {
dragNode = fairy;
isFairyHeld = true; // Set isFairyHeld to true when the fairy is held
handleMove(x, y, obj);
};
game.up = function (x, y, obj) {
dragNode = null;
isFairyHeld = false; // Set isFairyHeld to false when the fairy is released
};
game.move = handleMove;
// Update game every tick
game.update = updateGame;
}
// Handle move events
function handleMove(x, y, obj) {
if (dragNode) {
dragNode.x = x;
if (y > 2732 * 0.6) {
dragNode.y = y;
} else {
dragNode.y = 2732 * 0.6;
}
}
}
// Update game logic
function updateGame() {
// Update starfield
for (var i = game.children.length - 1; i >= 0; i--) {
if (game.children[i] instanceof Star) {
game.children[i].update();
}
}
// Update bullets
for (var i = bullets.length - 1; i >= 0; i--) {
bullets[i].update();
if (bullets[i].y < -50) {
bullets[i].destroy();
bullets.splice(i, 1);
}
}
// Update enemies
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);
}
}
// Check for collisions
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();
enemies[l].destroy();
bullets.splice(k, 1);
enemies.splice(l, 1);
score++;
scoreTxt.setText(score);
break;
}
}
}
// Spawn new bullets
if (LK.ticks % 20 == 0 && isFairyHeld) {
// Only spawn new bullets if the fairy is being held
var newBullet = new Bullet();
newBullet.x = fairy.x;
newBullet.y = fairy.y;
bullets.push(newBullet);
game.addChild(newBullet);
}
// Spawn new enemies
if (LK.ticks % 60 == 0) {
var newEnemy = new Enemy();
newEnemy.x = Math.random() * 2048;
newEnemy.y = -50;
enemies.push(newEnemy);
game.addChild(newEnemy);
}
}
// Initialize the game
initGame();
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