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 ****/ //<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 = 10; 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 = 10; 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 }); 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); }; }); /**** * 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 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); // 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); } var fastEnemySpawnRate = 1 / 16 + 1 / 16 * Math.max(1, score / 1200); if (LK.ticks % Math.floor(60 / fastEnemySpawnRate) == 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 (mouseDown && LK.ticks - lastShot >= 24) { // 24 ticks is approximately 0.4 seconds player.shoot(); lastShot = LK.ticks; } 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); enemies[j].destroy(); enemies.splice(j, 1); // 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); // Reset score to 0 and update score text score = 0; scoreTxt.setText(score.toString()); } } };
===================================================================
--- original.js
+++ change.js
@@ -33,13 +33,13 @@
});
// FastEnemy class
var FastEnemy = Container.expand(function () {
var self = Container.call(this);
- var enemyGraphics = self.attachAsset('fastEnemy', {
+ var fastEnemyGraphics = self.attachAsset('fastEnemy', {
anchorX: 0.5,
anchorY: 0.5
});
- self.speed = 4; // Moves twice as fast as normal enemy
+ self.speed = 10;
self.update = function () {
var dx = player.x - self.x;
var dy = player.y - self.y;
var angle = Math.atan2(dy, dx);
@@ -75,14 +75,8 @@
/****
* Game Code
****/
-var powerUpActive = false;
-var powerUpEndTime = 0;
-function activatePowerUp() {
- powerUpActive = true;
- powerUpEndTime = LK.ticks + 360; // 6 seconds at 60 FPS
-}
// Initialize player
var player = new Player();
player.x = 2048 / 2;
player.y = 2732 / 2;
@@ -117,14 +111,9 @@
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;
- if (Math.random() < 1 / 12) {
- enemy = new FastEnemy();
- } else {
- enemy = new Enemy();
- }
+ var enemy = new Enemy();
var side = Math.floor(Math.random() * 4);
switch (side) {
case 0:
// top
@@ -149,16 +138,42 @@
}
enemies.push(enemy);
game.addChild(enemy);
}
- var fireRate = powerUpActive ? 12 : 24; // Double fire rate if power-up is active
- if (mouseDown && LK.ticks - lastShot >= fireRate) {
+ var fastEnemySpawnRate = 1 / 16 + 1 / 16 * Math.max(1, score / 1200);
+ if (LK.ticks % Math.floor(60 / fastEnemySpawnRate) == 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 (mouseDown && LK.ticks - lastShot >= 24) {
+ // 24 ticks is approximately 0.4 seconds
player.shoot();
lastShot = LK.ticks;
}
- if (powerUpActive && LK.ticks >= powerUpEndTime) {
- powerUpActive = false;
- }
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();
@@ -167,11 +182,8 @@
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) {
- activatePowerUp();
- }
enemies[j].destroy();
enemies.splice(j, 1);
// Increase score and update score text
score += 10;
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