User prompt
Remove the power up character sprite and just use the normal sprite always
User prompt
When characterpowerup is visible hide character and vise versa
User prompt
Double width and height of player
Code edit (3 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: playerGraphics is not defined' in or related to this line: 'playerGraphics.visible = false; // Hide normal character when power up is active' Line Number: 299
Code edit (1 edits merged)
Please save this source code
User prompt
Double the width and height of the player
User prompt
Hide the normal character asset when the power up is active
User prompt
Hide character when the power act is active
User prompt
Hide powerupCharacter when the power up is not active
User prompt
The powerupplayer sprite is always in the background. Remove it when the powerup is not active
Code edit (1 edits merged)
Please save this source code
User prompt
half the height and width and double the speed of the bullets
User prompt
When big enemy dies, kill all enemies (adding 10 points for each enemy dead) and show a big explosion across the screen
User prompt
Display a small health bar floating a few pixels above big enemy. They should take 10 hits to kill
User prompt
Add anther enemy type which is twice the width and height of a normal enemy and has a different sprite. Its speed is 0.6 times a normal enemy. It spawns randomly once every 50 seconds on average
User prompt
Display max score at the bottom middle of the screen. Only update this when an enemy touches the player
User prompt
Multiply fast enemy speed by 1+Math.Min(1, score/1200)
User prompt
When FastEnemy collides with bullet, apply powerup for 6 seconds which changes player sprite and doubles the rate of fire for the player
User prompt
When FastEnemy collides with bullet, apply powerup for 6 seconds which changes player sprite and doubles rate of fire.
User prompt
Add another enemy type FastEnemy, with a new sprite which moves 6 times as fast. They spawn randomly but on average once every 16-8*(Math.min(1, score/1200) seconds
User prompt
When bullet hits fastenemy, apply a powerup for 6 seconds which doubles fire rate and changes the players spirte
User prompt
When the fast enemy collides with a bullet, the player gets a power up for 6 seconds only. This doubles fire rate, and changes their sprite
User prompt
Add another enemy type with a new sprite which moves 5 times as fast. Their spawn rate function is 1/16 + 1/16 * Math.Max(1, score/1200)
User prompt
If the player kills fast enemy give them a temporory powerup which lasts 6 seconds. The power up doubles fire rate
/****
* Classes
****/
// BigEnemy class
var BigEnemy = Container.expand(function () {
var self = Container.call(this);
var bigEnemyGraphics = self.attachAsset('bigEnemy', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 1.2; // 0.6 times the speed of a normal enemy
self.health = 10;
self.healthBar = self.attachAsset('healthBar', {
anchorX: 0.5,
anchorY: 1.0,
y: -self.height / 2 - 10
});
self.update = function () {
self.healthBar.width = self.health / 10 * 400; // Update health bar width based on health
var dx = player.x - self.x;
var dy = player.y - self.y;
var angle = Math.atan2(dy, dx);
self.x += self.speed * Math.cos(angle);
self.y += self.speed * Math.sin(angle);
};
});
//<Assets used in the game will automatically appear here>
// 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 = 20;
self.update = function () {
self.x += self.speed * Math.cos(self.rotation);
self.y += self.speed * Math.sin(self.rotation);
};
});
// 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 = 2;
self.update = function () {
var dx = player.x - self.x;
var dy = player.y - self.y;
var angle = Math.atan2(dy, dx);
self.x += self.speed * Math.cos(angle);
self.y += self.speed * Math.sin(angle);
};
});
// FastEnemy class
var FastEnemy = Container.expand(function () {
var self = Container.call(this);
var fastEnemyGraphics = self.attachAsset('fastEnemy', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 12 * (1 + 0.85 * Math.min(1, score / 1200)); // 6 times faster than regular enemy, multiplied by 1 + Math.min(1, score/1200)
self.update = function () {
var dx = player.x - self.x;
var dy = player.y - self.y;
var angle = Math.atan2(dy, dx);
self.x += self.speed * Math.cos(angle);
self.y += self.speed * Math.sin(angle);
};
});
// Player class
var Player = Container.expand(function () {
var self = Container.call(this);
var playerGraphics = self.attachAsset('character', {
anchorX: 0.5,
anchorY: 0.5,
width: 200,
height: 73.58
});
self.rotation = 0;
self.bullets = [];
self.shoot = function () {
var bullet = new Bullet();
bullet.x = self.x;
bullet.y = self.y;
bullet.rotation = self.rotation;
self.bullets.push(bullet);
game.addChild(bullet);
};
self.poweredUp = false;
self.powerUpTimer = 0;
self.update = function () {
// Removed power-up character sprite logic
};
});
// PowerUp class
var PowerUp = Container.expand(function () {
var self = Container.call(this);
var powerUpGraphics = self.attachAsset('powerUpCharacter', {
anchorX: 0.5,
anchorY: 0.5
});
self.duration = 360; // 6 seconds at 60 FPS
self.update = function () {
self.duration--;
if (self.duration <= 0) {
self.destroy();
}
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000 //Init game with black background
});
/****
* Game Code
****/
// Initialize player
var player = new Player();
player.x = 2048 / 2;
player.y = 2732 / 2;
game.addChild(player);
// Initialize score
var score = 0;
var maxScore = 0;
var scoreTxt = new Text2(score.toString(), {
size: 100,
fill: "#ffffff"
});
scoreTxt.anchor.set(0.5, 0); // Sets anchor to the top middle of the text.
LK.gui.top.addChild(scoreTxt);
var maxScoreTxt = new Text2(maxScore.toString(), {
size: 100,
fill: "#ffffff"
});
maxScoreTxt.anchor.set(0.5, 1); // Sets anchor to the bottom middle of the text.
LK.gui.bottom.addChild(maxScoreTxt);
// Handle mouse move to rotate player
game.move = function (x, y, obj) {
var localPos = game.toLocal(obj.global);
var dx = localPos.x - player.x;
var dy = localPos.y - player.y;
player.rotation = Math.atan2(dy, dx);
};
// Handle mouse down to shoot
var lastShot = 0;
var mouseDown = false;
game.down = function (x, y, obj) {
mouseDown = true;
};
game.up = function (x, y, obj) {
mouseDown = false;
};
// Update game state
// Initialize enemies array
var enemies = [];
game.update = function () {
// Create enemies at random points along the edge
var spawnRate = 1.5 + 1.5 * Math.min(1, score / 1200);
if (LK.ticks % Math.floor(60 / spawnRate) == 0) {
var enemy = new Enemy();
var side = Math.floor(Math.random() * 4);
switch (side) {
case 0:
// top
enemy.x = Math.random() * 2048;
enemy.y = 0;
break;
case 1:
// right
enemy.x = 2048;
enemy.y = Math.random() * 2732;
break;
case 2:
// bottom
enemy.x = Math.random() * 2048;
enemy.y = 2732;
break;
case 3:
// left
enemy.x = 0;
enemy.y = Math.random() * 2732;
break;
}
enemies.push(enemy);
game.addChild(enemy);
}
if (LK.ticks % Math.floor(60 * (16 - 8 * Math.min(1, score / 1200))) == 0) {
var fastEnemy = new FastEnemy();
var side = Math.floor(Math.random() * 4);
switch (side) {
case 0:
// top
fastEnemy.x = Math.random() * 2048;
fastEnemy.y = 0;
break;
case 1:
// right
fastEnemy.x = 2048;
fastEnemy.y = Math.random() * 2732;
break;
case 2:
// bottom
fastEnemy.x = Math.random() * 2048;
fastEnemy.y = 2732;
break;
case 3:
// left
fastEnemy.x = 0;
fastEnemy.y = Math.random() * 2732;
break;
}
enemies.push(fastEnemy);
game.addChild(fastEnemy);
}
if (LK.ticks % Math.floor(60 * 50) == 0) {
var bigEnemy = new BigEnemy();
var side = Math.floor(Math.random() * 4);
switch (side) {
case 0:
// top
bigEnemy.x = Math.random() * 2048;
bigEnemy.y = 0;
break;
case 1:
// right
bigEnemy.x = 2048;
bigEnemy.y = Math.random() * 2732;
break;
case 2:
// bottom
bigEnemy.x = Math.random() * 2048;
bigEnemy.y = 2732;
break;
case 3:
// left
bigEnemy.x = 0;
bigEnemy.y = Math.random() * 2732;
break;
}
enemies.push(bigEnemy);
game.addChild(bigEnemy);
}
if (mouseDown) {
var shootInterval = player.poweredUp ? 12 : 24; // Double rate of fire when powered up
if (LK.ticks - lastShot >= shootInterval) {
player.shoot();
lastShot = LK.ticks;
}
}
player.update();
for (var i = player.bullets.length - 1; i >= 0; i--) {
player.bullets[i].update();
if (player.bullets[i].x < 0 || player.bullets[i].x > 2048 || player.bullets[i].y < 0 || player.bullets[i].y > 2732) {
player.bullets[i].destroy();
player.bullets.splice(i, 1);
} else {
for (var j = enemies.length - 1; j >= 0; j--) {
if (player.bullets[i].intersects(enemies[j])) {
player.bullets[i].destroy();
player.bullets.splice(i, 1);
// Removed power-up character sprite attachment logic
if (enemies[j] instanceof BigEnemy) {
enemies[j].health -= 1;
if (enemies[j].health <= 0) {
// Kill all enemies and add points
for (var k = enemies.length - 1; k >= 0; k--) {
if (!(enemies[k] instanceof BigEnemy)) {
enemies[k].destroy();
enemies.splice(k, 1);
score += 10;
}
}
// Show explosion effect
LK.effects.flashScreen(0xff0000, 1000);
// Destroy BigEnemy
enemies[j].destroy();
enemies.splice(j, 1);
}
} else {
enemies[j].destroy();
enemies.splice(j, 1);
}
// Removed power-up character sprite attachment logic
// Increase score and update score text
score += 10;
scoreTxt.setText(score.toString());
break;
}
}
}
}
for (var j = enemies.length - 1; j >= 0; j--) {
if (player.intersects(enemies[j])) {
enemies[j].destroy();
enemies.splice(j, 1);
// Update max score if current score is higher
if (score > maxScore) {
maxScore = score;
maxScoreTxt.setText(maxScore.toString());
}
// Reset score to 0 and update score text
score = 0;
scoreTxt.setText(score.toString());
}
}
}; ===================================================================
--- original.js
+++ change.js
@@ -91,21 +91,9 @@
};
self.poweredUp = false;
self.powerUpTimer = 0;
self.update = function () {
- if (self.poweredUp) {
- self.powerUpTimer--;
- if (self.powerUpTimer <= 0) {
- self.poweredUp = false;
- self.attachAsset('character', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.visible = true;
- }
- } else {
- self.visible = true;
- }
+ // Removed power-up character sprite logic
};
});
// PowerUp class
var PowerUp = Container.expand(function () {
@@ -276,17 +264,9 @@
for (var j = enemies.length - 1; j >= 0; j--) {
if (player.bullets[i].intersects(enemies[j])) {
player.bullets[i].destroy();
player.bullets.splice(i, 1);
- if (enemies[j] instanceof FastEnemy) {
- player.poweredUp = true;
- player.powerUpTimer = 360; // 6 seconds at 60 FPS
- player.attachAsset('powerUpCharacter', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- player.visible = false;
- }
+ // Removed power-up character sprite attachment logic
if (enemies[j] instanceof BigEnemy) {
enemies[j].health -= 1;
if (enemies[j].health <= 0) {
// Kill all enemies and add points
@@ -306,16 +286,9 @@
} else {
enemies[j].destroy();
enemies.splice(j, 1);
}
- if (enemies[j] instanceof FastEnemy) {
- player.poweredUp = true;
- player.powerUpTimer = 360; // 6 seconds at 60 FPS
- player.attachAsset('powerUpCharacter', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- }
+ // Removed power-up character sprite attachment logic
// Increase score and update score text
score += 10;
scoreTxt.setText(score.toString());
break;
Fireball with angry face. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows. 8 bit
Grinning creepy ball shaped clown face. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows. 8 bit
Burning ball shaped creepy grinning devil. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows. 8 bit
Creepy Jester clown with a fat circular belly, grinning and carying a trident. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows. 8 bit
Dark night sky. Dim stars. DMT psychedelic. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows. 8 bit