User prompt
Fix Bug: 'ReferenceError: Can't find variable: HeroBullet' in this line: 'var bullet = new HeroBullet();' Line Number: 19
User prompt
Power ups make you shoot in a spread
User prompt
Make enimies drop power ups that make you stronger for 1 minute e.g spread shot, laser, bomb
User prompt
Remove the boss system
User prompt
Give all enemies health bars that increase by one every 3 waves
User prompt
Create a separate asset for the boss
User prompt
Add a skip to wave 5 button above the debug menu
User prompt
Move the debug menu up higher
User prompt
Add a debug menu above the joystick
User prompt
Add a bossfight on wave five that shoots a spread of projectiles
User prompt
Fix Bug: 'ReferenceError: Can't find variable: waveTxt' in this line: 'waveTxt.setText('Wave: ' + currentWave);' Line Number: 250
User prompt
Add a wave display
User prompt
Show the wave in the top left
User prompt
Make a boss spawn every 5 waves instead of at 50 score
User prompt
Add a wave system
User prompt
Fix Bug: 'TypeError: undefined is not an object (evaluating 'self.lives = 3')' in this line: 'self.lives = 3;' Line Number: 65
User prompt
Fix Bug: 'TypeError: undefined is not an object (evaluating 'self.lives = 3')' in this line: 'self.lives = 3;' Line Number: 65
User prompt
Make a boss that fires in a spread and has 3 lives, but only comes out every time you get 50 points
User prompt
Give the player 5 lives
User prompt
Make the enemies get stronger for every 50 points you get
User prompt
Change the games background to look like mars
User prompt
Make the background look like Earth
User prompt
Add a shoot button on the right of the screen
User prompt
Joystick for movement
Initial prompt
Hyper Shootout
/****
* Classes
****/
// 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.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();
}
};
});
// 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;
};
});
// 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;
};
});
// 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;
};
});
// DebugMenu class
var DebugMenu = Container.expand(function () {
var self = Container.call(this);
var menuGraphics = self.createAsset('debugMenu', 'Debug menu', 0.5, 0.5);
self.addChild(menuGraphics);
// Add buttons and functionality for the debug menu here
// Example button to add lives
var addLivesButton = self.createAsset('addLivesButton', 'Add Lives', 0.5, 0.5);
addLivesButton.on('down', function () {
hero.lives += 1;
livesTxt.setText('Lives: ' + hero.lives);
});
self.addChild(addLivesButton);
});
// 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: 'marsBackground' // Set background image to Mars
});
/****
* Game Code
****/
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 debugMenu = game.addChild(new DebugMenu());
debugMenu.x = 150; // Position from left
debugMenu.y = 2732 - 500; // Position higher above the joystick
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 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])) {
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 enemies and potentially shoot
for (var l = enemies.length - 1; l >= 0; l--) {
enemies[l].move();
if (Math.random() < 0.01) {
// Random chance to shoot
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) {
for (var i = 0; i < enemiesPerWave; i++) {
var 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
@@ -50,53 +50,16 @@
var self = Container.call(this);
var enemyGraphics = self.createAsset('enemy', 'Enemy character', 0.5, 0.5);
self.baseSpeed = 2;
self.strength = 1;
- self.healthBar = game.addChild(new HealthBar());
- self.health = 100;
- self.updateHealth = function (currentWave) {
- self.health += Math.floor(currentWave / 3) * 100;
- self.healthBar.setHealth(self.health);
- };
self.updateSpeed = function (score) {
self.strength = 1 + Math.floor(score / 50);
self.speed = self.baseSpeed * self.strength;
};
self.move = function () {
self.y += self.speed;
- self.healthBar.x = self.x;
- self.healthBar.y = self.y - 20;
};
});
-// Boss class
-var Boss = Enemy.expand(function () {
- var self = Enemy.call(this);
- var bossGraphics = self.createAsset('boss', 'Boss character', 0.5, 0.5);
- self.lives = 3;
- self.shootSpread = function () {
- for (var angle = -45; angle <= 45; angle += 15) {
- var bullet = new EnemyBullet();
- bullet.x = self.x;
- bullet.y = self.y + self.height / 2;
- bullet.speedX = Math.sin(angle * Math.PI / 180) * bullet.speed;
- bullet.speedY = Math.cos(angle * Math.PI / 180) * bullet.speed;
- bullet.move = function () {
- this.x += this.speedX;
- this.y += this.speedY;
- };
- game.addChild(bullet);
- enemyBullets.push(bullet);
- }
- };
-});
-// HealthBar class
-var HealthBar = Container.expand(function () {
- var self = Container.call(this);
- var barGraphics = self.createAsset('healthBar', 'Health bar', 0, 0.5);
- self.setHealth = function (health) {
- barGraphics.scale.x = health / 100;
- };
-});
// EnemyBullet class
var EnemyBullet = Container.expand(function () {
var self = Container.call(this);
var bulletGraphics = self.createAsset('enemyBullet', 'Enemy bullet', 0.5, 0);
@@ -244,9 +207,8 @@
} else {
// Check for bullet collision with enemies
for (var j = enemies.length - 1; j >= 0; j--) {
if (bullets[i].intersects(enemies[j])) {
- enemies[j].healthBar.destroy();
enemies[j].destroy();
enemies.splice(j, 1);
bullets[i].destroy();
bullets.splice(i, 1);
@@ -298,39 +260,11 @@
if (LK.ticks % waveInterval == 0) {
for (var i = 0; i < enemiesPerWave; i++) {
var newEnemy = new Enemy();
newEnemy.updateSpeed(score);
- newEnemy.updateHealth(currentWave);
newEnemy.x = Math.random() * (2048 - newEnemy.width) + newEnemy.width / 2;
newEnemy.y = -newEnemy.height / 2 - i * newEnemy.height;
enemies.push(newEnemy);
game.addChild(newEnemy);
}
}
- // Boss spawn logic
- var wavesCount = Math.floor(LK.ticks / waveInterval);
- var bossSpawned = false;
- // Boss spawn and behavior logic
- if (currentWave === 5 && !bossSpawned) {
- var boss = new Boss();
- boss.updateSpeed(score);
- boss.x = 1024; // Center of the screen
- boss.y = -boss.height / 2;
- enemies.push(boss);
- game.addChild(boss);
- bossSpawned = true;
- }
- if (bossSpawned) {
- for (var m = enemies.length - 1; m >= 0; m--) {
- if (enemies[m] instanceof Boss) {
- if (LK.ticks % 60 === 0) {
- enemies[m].shootSpread();
- }
- if (enemies[m].y > 2732) {
- enemies[m].destroy();
- enemies.splice(m, 1);
- bossSpawned = false;
- }
- }
- }
- }
});
\ No newline at end of file
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.