User prompt
Make stingerEnemy damage you on contact
User prompt
For every 3 enemies, spawn 7 stingerEnemy
User prompt
Remove the strongEnemy
User prompt
Fix Bug: 'TypeError: undefined is not an object (evaluating 'newEnemy.updateSpeed')' in this line: 'newEnemy.updateSpeed(score);' Line Number: 374
User prompt
Make normal enemies spawn alongside the stingerEnemy
User prompt
Make the boss enemy appear every 10 waves and make it shoot multiple projectiles
User prompt
Create a new bossEnemy class that is slower but is wider and takes more hits to kill and is completely separate
User prompt
Remove the skip to wave 5 button
User prompt
Remove the debug menu
User prompt
Make stingerEnemy spawn every wave after wave 5
User prompt
Make stingerEnemy spawn in groups of 7 spread out
User prompt
Make stingerEnemy spawn in groups of 5
User prompt
Fix Bug: 'TypeError: undefined is not an object (evaluating 'newEnemy.updateSpeed')' in this line: 'newEnemy.updateSpeed(score);' Line Number: 417
User prompt
Fix Bug: 'TypeError: undefined is not an object (evaluating 'newEnemy.updateSpeed')' in this line: 'newEnemy.updateSpeed(score);' Line Number: 417
User prompt
Make stinger enemies slower, and make them spawn in groups of 4
User prompt
Make stinger enemies shoot in a downwards spread
User prompt
On wave five spawn an new stinger enemy that is completely separate from normal enimes
User prompt
Give the stinger enemy type more damage and bigger bullets
User prompt
Make he stronger enemy type only appear on wave 5,10,15 etc
User prompt
Remove the bomb and laser power up
User prompt
Add a stronger enemy type on wave 5
User prompt
Slow down the enimies rate of fire
User prompt
Change the background
User prompt
Make the spread go upwards
User prompt
Make the power ups work
/****
* Classes
****/
var StingerEnemy = Container.expand(function () {
var self = Container.call(this);
var enemyGraphics = self.createAsset('stingerEnemy', 'Stinger enemy character', 0.5, 0.5);
self.baseSpeed = 1.5;
self.strength = 10; // Stinger enemy with higher strength
self.updateSpeed = function (score) {
self.strength = 10 + Math.floor(score / 150); // Stinger enemies scale with score
self.speed = self.baseSpeed * self.strength;
};
self.move = function () {
self.y += self.speed;
};
});
// HeroBullet class
var HeroBullet = Container.expand(function () {
var self = Container.call(this);
var bulletGraphics = self.createAsset('heroBullet', 'Hero bullet', 0.5, 1);
self.speed = 10;
self.move = function () {
self.y -= self.speed;
};
});
// Hero class
var Hero = Container.expand(function () {
var self = Container.call(this);
var heroGraphics = self.createAsset('hero', 'Hero character', 0.5, 0.5);
self.speed = 5;
self.bulletCooldown = 0;
self.lives = 5; // Player starts with 5 lives
self.moveLeft = function () {
self.x = Math.max(self.width / 2, self.x - self.speed);
};
self.moveRight = function () {
self.x = Math.min(2048 - self.width / 2, self.x + self.speed);
};
self.shoot = function () {
if (self.bulletCooldown <= 0) {
var bullet = new HeroBullet();
bullet.x = self.x;
bullet.y = self.y - self.height / 2;
game.addChild(bullet);
bullets.push(bullet);
self.bulletCooldown = 20; // Cooldown period before next shot
}
};
self.powerUpTimer = 0;
self.powerUpActive = false;
self.enableSpreadShot = function () {
self.powerUpActive = true;
self.powerUpTimer = 3600; // 1 minute at 60FPS
self.shoot = function () {
if (self.bulletCooldown <= 0) {
var angles = [-Math.PI / 4, -Math.PI / 2, -3 * Math.PI / 4]; // Angles for upward spread shot
for (var i = 0; i < angles.length; i++) {
var bullet = new SpreadShotBullet(angles[i], 10);
bullet.x = self.x;
bullet.y = self.y - self.height / 2;
game.addChild(bullet);
bullets.push(bullet);
}
self.bulletCooldown = 20; // Cooldown period before next shot
}
};
};
self.updatePowerUpTimer = function () {
if (self.powerUpTimer > 0) {
self.powerUpTimer--;
if (self.powerUpTimer == 0) {
self.powerUpActive = false;
// Reset shoot function to default behavior
self.shoot = self.defaultShoot;
}
}
};
self.defaultShoot = function () {
if (self.bulletCooldown <= 0) {
var bullet = new HeroBullet();
bullet.x = self.x;
bullet.y = self.y - self.height / 2;
game.addChild(bullet);
bullets.push(bullet);
self.bulletCooldown = 20; // Cooldown period before next shot
}
};
self.shoot = self.defaultShoot;
self.update = function () {
if (self.bulletCooldown > 0) {
self.bulletCooldown--;
}
var joystickDirection = joystick.getDirection();
if (joystickDirection.x < -10) {
self.moveLeft();
} else if (joystickDirection.x > 10) {
self.moveRight();
}
};
});
// SpreadShotBullet class
var SpreadShotBullet = Container.expand(function (angle, speed) {
var self = Container.call(this);
var bulletGraphics = self.createAsset('heroBullet', 'Spread shot bullet', 0.5, 1);
self.speed = speed;
self.angle = angle;
self.move = function () {
self.x += self.speed * Math.cos(self.angle);
self.y += self.speed * Math.sin(self.angle);
};
});
// Enemy class
var Enemy = Container.expand(function () {
var self = Container.call(this);
var enemyGraphics = self.createAsset('enemy', 'Enemy character', 0.5, 0.5);
self.baseSpeed = 2;
self.strength = 1;
self.updateSpeed = function (score) {
self.strength = 1 + Math.floor(score / 50);
self.speed = self.baseSpeed * self.strength;
};
self.move = function () {
self.y += self.speed;
};
});
// StrongEnemy class
var StrongEnemy = Container.expand(function () {
var self = Container.call(this);
var enemyGraphics = self.createAsset('strongEnemy', 'Strong enemy character', 0.5, 0.5);
self.baseSpeed = 1;
self.strength = 5; // Stronger enemy with higher strength
self.updateSpeed = function (score) {
self.strength = 5 + Math.floor(score / 100); // Stronger enemies scale with score
self.speed = self.baseSpeed * self.strength;
};
self.move = function () {
self.y += self.speed;
};
});
// EnemyBullet class
var EnemyBullet = Container.expand(function () {
var self = Container.call(this);
var bulletGraphics = self.createAsset('enemyBullet', 'Enemy bullet', 0.5, 0);
self.speed = 5;
self.move = function () {
self.y += self.speed;
};
});
// PowerUp class
var PowerUp = Container.expand(function () {
var self = Container.call(this);
var powerUpGraphics = self.createAsset('powerUp', 'Power up', 0.5, 0.5);
self.type = 'spread'; // Default power-up type
self.speed = 2;
self.move = function () {
self.y += self.speed;
};
self.applyEffect = function (hero) {
// Apply the effect based on power-up type
switch (self.type) {
case 'spread':
hero.enableSpreadShot();
break;
}
};
});
// Joystick class
var Joystick = Container.expand(function () {
var self = Container.call(this);
var joystickGraphics = self.createAsset('joystickBase', 'Joystick base', 0.5, 0.5);
var joystickKnob = self.createAsset('joystickKnob', 'Joystick knob', 0.5, 0.5);
self.addChild(joystickKnob);
self.isDragging = false;
self.startPos = {
x: 0,
y: 0
};
self.currentPos = {
x: 0,
y: 0
};
self.delta = {
x: 0,
y: 0
};
self.on('down', function (obj) {
self.isDragging = true;
self.startPos = obj.event.getLocalPosition(self);
});
self.on('move', function (obj) {
if (self.isDragging) {
self.currentPos = obj.event.getLocalPosition(self);
self.delta.x = self.currentPos.x - self.startPos.x;
self.delta.y = self.currentPos.y - self.startPos.y;
joystickKnob.x = Math.max(-50, Math.min(50, self.delta.x));
joystickKnob.y = Math.max(-50, Math.min(50, self.delta.y));
}
});
self.on('up', function (obj) {
self.isDragging = false;
joystickKnob.x = 0;
joystickKnob.y = 0;
self.delta.x = 0;
self.delta.y = 0;
});
self.getDirection = function () {
return self.delta;
};
});
// ShootButton class
var ShootButton = Container.expand(function () {
var self = Container.call(this);
var buttonGraphics = self.createAsset('shootButton', 'Shoot button', 0.5, 0.5);
self.on('down', function () {
hero.shoot();
});
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000,
// Init game with black background
backgroundImage: 'spaceBackground' // Set background image to Space
});
/****
* Game Code
****/
var shootButton = game.addChild(new ShootButton());
shootButton.x = 2048 - 150; // Position from right
shootButton.y = 2732 - 150; // Position from bottom
var joystick = game.addChild(new Joystick());
joystick.x = 150; // Position from left
joystick.y = 2732 - 150; // Position from bottom
// Initialize important asset arrays
var bullets = [];
var enemies = [];
var enemyBullets = [];
var powerUps = []; // Store active power-ups
var score = 0;
var hero = game.addChild(new Hero());
hero.x = 1024; // Center of the screen
hero.y = 2732 - 200; // Near the bottom of the screen
// Score display
var scoreTxt = new Text2('0', {
size: 150,
fill: "#ffffff"
});
// Lives display
var livesTxt = new Text2('Lives: 5', {
size: 100,
fill: "#ffffff"
});
livesTxt.anchor.set(0, 0);
LK.gui.topLeft.addChild(livesTxt);
// Score and Wave display
var scoreAndWaveTxt = new Text2('Score: 0 | Wave: 1', {
size: 100,
fill: "#ffffff"
});
scoreAndWaveTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreAndWaveTxt);
// Game tick event
LK.on('tick', function () {
// Update hero
hero.update();
// Move and check bullets
for (var i = bullets.length - 1; i >= 0; i--) {
bullets[i].move();
if (bullets[i].y < -bullets[i].height) {
bullets[i].destroy();
bullets.splice(i, 1);
} else {
// Check for bullet collision with enemies
for (var j = enemies.length - 1; j >= 0; j--) {
if (bullets[i].intersects(enemies[j])) {
if (Math.random() < 0.2) {
// 20% chance to drop a power-up
var powerUpTypes = ['spread'];
var powerUp = new PowerUp();
powerUp.type = powerUpTypes[Math.floor(Math.random() * powerUpTypes.length)];
powerUp.x = enemies[j].x;
powerUp.y = enemies[j].y;
game.addChild(powerUp);
powerUps.push(powerUp);
}
enemies[j].destroy();
enemies.splice(j, 1);
bullets[i].destroy();
bullets.splice(i, 1);
score += 10;
scoreTxt.setText(score.toString());
break;
}
}
}
}
// Move and check enemy bullets
for (var k = enemyBullets.length - 1; k >= 0; k--) {
enemyBullets[k].move();
if (enemyBullets[k].y > 2732 + enemyBullets[k].height) {
enemyBullets[k].destroy();
enemyBullets.splice(k, 1);
} else if (enemyBullets[k].intersects(hero)) {
hero.lives--;
if (hero.lives <= 0) {
// Game over condition
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
} else {
// Flash hero red to indicate hit and update lives display
LK.effects.flashObject(hero, 0xff0000, 500);
livesTxt.setText('Lives: ' + hero.lives);
}
enemyBullets[k].destroy();
enemyBullets.splice(k, 1);
}
}
// Move and check power-ups
for (var m = powerUps.length - 1; m >= 0; m--) {
powerUps[m].move();
if (powerUps[m].y > 2732 + powerUps[m].height) {
powerUps[m].destroy();
powerUps.splice(m, 1);
} else if (powerUps[m].intersects(hero)) {
powerUps[m].applyEffect(hero);
powerUps[m].destroy();
powerUps.splice(m, 1);
}
}
// Update hero's power-up timer
hero.updatePowerUpTimer();
// Move enemies and potentially shoot
for (var l = enemies.length - 1; l >= 0; l--) {
enemies[l].move();
if (Math.random() < 0.005) {
// Random chance to shoot, rate reduced to half
var enemyBullet = new EnemyBullet();
enemyBullet.x = enemies[l].x;
enemyBullet.y = enemies[l].y + enemies[l].height / 2;
game.addChild(enemyBullet);
enemyBullets.push(enemyBullet);
}
}
// Wave system
var waveInterval = 600; // 10 seconds per wave
var enemiesPerWave = 5 + Math.floor(score / 100); // Increase number of enemies per wave based on score
var currentWave = Math.floor(LK.ticks / waveInterval) + 1;
scoreAndWaveTxt.setText('Score: ' + score + ' | Wave: ' + currentWave);
if (LK.ticks % waveInterval == 0) {
var currentWave = Math.floor(LK.ticks / waveInterval) + 1;
for (var i = 0; i < enemiesPerWave; i++) {
var newEnemy;
if (currentWave > 5) {
// Spawn a group of StingerEnemies spread out
for (var n = 0; n < 7; n++) {
var stingerEnemy = new StingerEnemy();
stingerEnemy.updateSpeed(score);
stingerEnemy.x = 2048 / 8 * (n + 1) - stingerEnemy.width / 2;
stingerEnemy.y = -stingerEnemy.height / 2 - i * stingerEnemy.height * 1.5;
enemies.push(stingerEnemy);
game.addChild(stingerEnemy);
}
} else {
newEnemy = new Enemy();
}
newEnemy.updateSpeed(score);
newEnemy.x = Math.random() * (2048 - newEnemy.width) + newEnemy.width / 2;
newEnemy.y = -newEnemy.height / 2 - i * newEnemy.height;
enemies.push(newEnemy);
game.addChild(newEnemy);
}
}
}); ===================================================================
--- original.js
+++ change.js
@@ -230,20 +230,8 @@
****/
var shootButton = game.addChild(new ShootButton());
shootButton.x = 2048 - 150; // Position from right
shootButton.y = 2732 - 150; // Position from bottom
-var skipToWave5Button = game.addChild(new Text2('Skip to Wave 5', {
- size: 100,
- fill: '#ffffff'
-}));
-skipToWave5Button.anchor.set(0.5, 0);
-skipToWave5Button.x = 150; // Position from left
-skipToWave5Button.y = 2732 - 650; // Position above the debug menu
-skipToWave5Button.on('down', function () {
- score = (Math.floor((5 - 1) * 600 / 60) - 1) * 10; // Set score to just before wave 5
- scoreTxt.setText(score.toString());
- scoreAndWaveTxt.setText('Score: ' + score + ' | Wave: 5');
-});
var joystick = game.addChild(new Joystick());
joystick.x = 150; // Position from left
joystick.y = 2732 - 150; // Position from bottom
// Initialize important asset arrays
A laser. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A laser bullet. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A plus sign. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A mechanical wasp. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A turret. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.