User prompt
Reduce drone speed by 25%
User prompt
Add a pulse effect to drone on hit with bullet.
User prompt
Increase knock back on Drone by bullet
User prompt
Add a slight push back to drones when they are hit with a bullet
User prompt
Please fix the bug: 'Timeout.tick error: undefined is not an object (evaluating 'enemies[k].scale')' in or related to this line: 'enemies[k].scale.x = 1.0;' Line Number: 318
User prompt
Add a slight knock back and a small scale pulse when bullet hits the drone.
User prompt
When a Drone is destroyed by HeroBullets, have it split into three pieces. Send those pieces flying outwards with a small amount of momentum before fading away and getting destroyed.
User prompt
Increase firing rate of hero bullets by 25%
User prompt
When hero bullets hit the drones, subtract the bullet power from the drone hit points, when the drones hit points are less than or equal to 0, destroy them.
User prompt
I want to add a Type and a Power variable to HeroBullet for later power up implementation.
User prompt
Add a variable to the drone class called HitPoints. Set to 3.
User prompt
I’m seeing some drones being destroyed without any interaction with, bullets, the player or leaving the bottom of the screen. Possible causes?
Code edit (1 edits merged)
Please save this source code
User prompt
Bring enemy outer X spawn parameters in 5% on either side.
User prompt
Enemies can not be destroyed until they are on screen
User prompt
Change enemy spawn area X axis range to be within Road area. Spawn enemies in groups of 2-3
User prompt
Make sure high definition asset used for game logo
User prompt
Do the same for game.move
User prompt
In game.down add a check for game started before using dragNode or hero.rotation.
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'hero.rotation = x > hero.x ? Math.PI / 180 * -1 : Math.PI / 180 * 1;' Line Number: 329
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'dragNode = {' Line Number: 327
User prompt
Move play underneath game logo on title screen.
User prompt
Make sure Game logo and play button are initialized after all scrolling backgrounds.
User prompt
Add two states for game. isTitle and isStarted. Create a title screen during which isTitle is true and isStarted is false, with the game logo in the center of the screen. Create a play button class using the appropriate asset and place below game logo on title screen. During title screen, only initialize RoadScroll, both railings and city background. When play button is pressed, start game and have player run out from bottom of screen.
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'hero.rotation = x > hero.x ? Math.PI / 180 * -1 : Math.PI / 180 * 1;' Line Number: 361
/****
* Classes
****/
// Enemy class representing the enemy robots
var Drone = Container.expand(function () {
var self = Container.call(this);
var droneGraphics = self.attachAsset('Drone', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 3;
self.update = function () {
self.y += self.speed;
if (self.y > 2732) {
self.destroy();
}
};
});
// Dust class for dust particles
var Dust = Container.expand(function () {
var self = Container.call(this);
var dustGraphics = self.attachAsset('Dust', {
anchorX: 0.5,
anchorY: 0.5
});
dustGraphics.alpha = 0.75;
self.speed = Math.random() * 3 + 1;
self.rotationSpeed = Math.random() * 0.02 - 0.01; // Random rotation speed between -0.01 and 0.01
self.direction = Math.random() * Math.PI * 0.5;
self.update = function () {
self.y += self.speed;
self.x += Math.sin(self.direction) * self.speed; // Add slight X travel based on direction
self.rotation += self.rotationSpeed; // Add rotation
dustGraphics.alpha -= 0.01; // fade out at a medium pace
if (self.y > 2732 || dustGraphics.alpha <= 0) {
self.destroy();
}
};
});
// Assets will be automatically created and loaded by the LK engine based on their usage in the code.
// Hero class representing the player's spaceship
var Hero = Container.expand(function () {
var self = Container.call(this);
self.prevX = self.x; // Initialize prevX with the current x position
var heroGraphics = self.attachAsset('hero', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 10;
self.update = function () {
if (self.y > 2375) {
self.y -= self.speed;
}
// Add rotation based on movement direction
if (self.x > self.prevX) {
self.rotation += Math.PI / 180 * 1; // Rotate 1 degree to the right
if (self.rotation > Math.PI / 180 * 5) {
self.rotation = Math.PI / 180 * 5;
}
} else if (self.x < self.prevX) {
self.rotation -= Math.PI / 180 * 1; // Rotate 1 degree to the left
if (self.rotation < Math.PI / 180 * -5) {
self.rotation = Math.PI / 180 * -5;
}
} else {
if (self.rotation > 0) {
self.rotation -= Math.PI / 180 * 1;
if (self.rotation < 0) {
self.rotation = 0;
}
} else if (self.rotation < 0) {
self.rotation += Math.PI / 180 * 1;
if (self.rotation > 0) {
self.rotation = 0;
}
}
}
self.prevX = self.x; // Store the current x position for the next frame
// Add scale change to simulate footsteps
if (LK.ticks % 24 < 12) {
self.scale.x = 1.02;
} else {
self.scale.x = 0.98;
}
};
});
// Bullet class for hero's bullets
var HeroBullet = Container.expand(function () {
var self = Container.call(this);
var bulletGraphics = self.attachAsset('heroBullet', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = -15;
self.update = function () {
self.y += self.speed;
if (self.y < 0) {
self.destroy();
}
};
});
// RailingLeft class for the scrolling left railing
var RailingLeft = Container.expand(function (assetType) {
var self = Container.call(this);
var railingGraphics = self.attachAsset(assetType, {
anchorX: 0.5,
anchorY: 0
});
self.speed = 2;
self.update = function () {
self.y += self.speed;
if (self.y >= 2732) {
self.y = -2732;
}
};
});
// RailingRight class for the scrolling right railing
var RailingRight = Container.expand(function (assetType) {
var self = Container.call(this);
var railingGraphics = self.attachAsset(assetType, {
anchorX: 0.5,
anchorY: 0
});
self.speed = 2;
self.update = function () {
self.y += self.speed;
if (self.y >= 2732) {
self.y = -2732;
}
};
});
// RoadScroll class for the scrolling road
var RoadScroll = Container.expand(function (assetType) {
var self = Container.call(this);
var roadGraphics = self.attachAsset(assetType, {
anchorX: 0.5,
anchorY: 0
});
if (assetType === 'CityBackgroundHD') {
self.speed = 1;
} else {
self.speed = 2;
}
self.update = function () {
self.y += self.speed;
if (self.y >= 2732) {
self.y = -2732;
}
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000 //Init game with black background
});
/****
* Game Code
****/
// Initialize the city background for parallax effect
var cityBackground1 = game.addChild(new RoadScroll('CityBackgroundHD'));
var cityBackground2 = game.addChild(new RoadScroll('CityBackgroundHD'));
cityBackground1.x = 2048 / 2;
cityBackground2.x = 2048 / 2;
cityBackground1.y = 0;
cityBackground2.y = -2732;
// Add game logo
var gameLogo = LK.getAsset('GameLogo', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 546.4 // 20% down from the top of the screen
});
game.addChild(gameLogo);
// Add play button
var playButton = LK.getAsset('PlayButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 600
});
game.addChild(playButton);
// Play button interaction
playButton.down = function (x, y, obj) {
// Remove title screen elements
game.removeChild(gameLogo);
game.removeChild(playButton);
// Set game state
isStarted = true;
isTitle = false;
// Initialize player and enemies
hero = game.addChild(new Hero());
hero.x = 2048 / 2;
hero.y = 2732 + hero.height;
hero.update = function () {
if (hero.y > 2375) {
hero.y -= hero.speed;
}
};
};
// Initialize the road instances
var road1 = game.addChild(new RoadScroll('Road'));
var road2 = game.addChild(new RoadScroll('Road2'));
road2.x = 2048 / 2;
road1.x = 2048 / 2;
road1.y = 0;
road2.y = -2732;
// Initialize the left railing instances
var railingLeft1 = game.addChild(new RailingLeft('RailingStart'));
var railingLeft2 = game.addChild(new RailingLeft('RailingEnd'));
railingLeft1.x = 2048 * 0.16;
railingLeft2.x = 2048 * 0.16;
railingLeft1.y = 0;
railingLeft2.y = -2732;
// Initialize the right railing instances
var railingRight1 = game.addChild(new RailingRight('RailingEnd'));
var railingRight2 = game.addChild(new RailingRight('RailingStart'));
railingRight1.x = 2048 * 0.81; // Moved left by 3%
railingRight2.x = 2048 * 0.81; // Moved left by 3%
railingRight1.y = 0;
railingRight2.y = -2732;
// Initialize game state variables
var isStarted = false;
var isTitle = true; // Set initial game state to isTitle
// Initialize title screen elements
var gameLogo = LK.getAsset('GameLogo', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 300
});
game.addChild(gameLogo);
var playButton = LK.getAsset('PlayButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 600
});
game.addChild(playButton);
// Play button interaction
playButton.down = function (x, y, obj) {
// Remove title screen elements
game.removeChild(gameLogo);
game.removeChild(playButton);
// Set game state
isStarted = true;
isTitle = false;
// Initialize player and enemies
hero = game.addChild(new Hero());
hero.x = 2048 / 2;
hero.y = 2732 + hero.height;
hero.update = function () {
if (hero.y > 2375) {
hero.y -= hero.speed;
}
};
};
var hero;
var enemies = [];
var heroBullets = [];
// Function to handle game updates
game.update = function () {
if (isStarted) {
// Update the city background instances for parallax effect
cityBackground1.update();
cityBackground2.update();
// Update the road instances
road1.update();
road2.update();
// Update the left railing instances
railingLeft1.update();
railingLeft2.update();
// Update the right railing instances
railingRight1.update();
railingRight2.update();
if (dragNode) {
hero.x = dragNode.x;
hero.y = dragNode.y;
}
// Update enemies
for (var i = enemies.length - 1; i >= 0; i--) {
enemies[i].update();
if (enemies[i].intersects(hero)) {
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
}
}
// Update hero bullets
for (var j = heroBullets.length - 1; j >= 0; j--) {
heroBullets[j].update();
for (var k = enemies.length - 1; k >= 0; k--) {
if (heroBullets[j].intersects(enemies[k])) {
enemies[k].destroy();
heroBullets[j].destroy();
enemies.splice(k, 1);
heroBullets.splice(j, 1);
LK.setScore(LK.getScore() + 1);
scoreTxt.setText(LK.getScore());
break;
}
}
}
// Spawn Drones from the top of the screen
if (LK.ticks % 120 == 0) {
var newDrone = new Drone();
newDrone.x = Math.random() * 2048; // Random x position across the width of the screen
newDrone.y = -newDrone.height; // Start just outside the top of the screen
enemies.push(newDrone);
game.addChild(newDrone);
}
// Fire bullets
if (LK.ticks % 30 == 0) {
var newBullet = new HeroBullet();
newBullet.x = hero.x;
newBullet.y = hero.y - hero.height / 2;
heroBullets.push(newBullet);
game.addChild(newBullet);
}
// Generate dust particles in sync with player pulsing
if (LK.ticks % 24 == 0) {
var newDust = new Dust();
newDust.x = hero.x - hero.width / 4; // Move dust spawn position right half as much as the last move
newDust.y = hero.y + hero.height / 2 * 0.93; // Move dust spawn point up 3% more
game.addChild(newDust);
} else if (LK.ticks % 24 == 12) {
var newDust = new Dust();
newDust.x = hero.x + hero.width / 4; // Create another dust spawn point an equal distance in from the right of the player asset
newDust.y = hero.y + hero.height / 2 * 0.93; // Move dust spawn point up 3% more
game.addChild(newDust);
}
}
};
// Handle touch input for hero movement
var dragNode = null;
game.down = function (x, y, obj) {
if (!isTitle) {
dragNode = {
x: hero.x,
y: hero.y
};
}
// Add a tilt-back effect during initial movement
if (hero) {
hero.rotation = x > hero.x ? Math.PI / 180 * -1 : Math.PI / 180 * 1;
}
};
game.move = function (x, y, obj) {
if (dragNode) {
// Add a slight delay to the drag control to make the player feel like it has more weight
dragNode.x += (x - dragNode.x) * 0.1;
dragNode.y = hero.y; // Lock the y position to the hero's initial y position
}
};
game.up = function (x, y, obj) {
dragNode = null;
};
// Display score
var scoreTxt = new Text2('0', {
size: 150,
fill: "#ffffff"
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
scoreTxt.setText(LK.getScore());
// Update the left railing instances
railingLeft1.update();
railingLeft2.update();
View of a futuristic soldier from directly overhead. White armor with blue glowing cyberpunk details. Holding weapon forward.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
The lights of a futuristic city in the dark at night. Very high above it looking straight down like from an airplane or a map. Background for an endlessly scrolling game.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A big button that say Play to start playing a game. Use neon cyberpunk style.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Overhead view. A hovering robot with a tapered midsection with two bulky arms with claw like hands and a giant red “eye” on top of its body. Looking straight down. Cyberpunk, black with red glowing highlights.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Overhead view. A heavily armored attack robot. Two arms with large gauntlet type fists. Four large red glowing eyes. Three distinct parts, body and two arms. Symmetrical design. Birds Eye view above them looking down on their head. Simple shapes. Low detail. Cyberpunk, black with red glowing highlights.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A red glowing line. Bright red core with subtle outer glow. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A blue transparent dome type shield. Simple graphics. Low details. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A ring of nuclear fire seen from overhead. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A thin robot with goggles riding a hover-bike. Twin blaster guns mounted on front. Top down view. Birds Eye view. Cyberpunk with red glowing highlights... Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Battle drone, circular. White with blue glowing highlights. Birds Eye view from overhead. Cyberpunk. Simple shapes.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
GameTheme
Music
TitleTheme
Music
HeroBlaster
Sound effect
Explosion
Sound effect
PowerUp
Sound effect
CloneSoldier
Sound effect
WeaponPowerUp
Sound effect
Drone
Sound effect
BinaryStorm
Sound effect
LaserCharge
Sound effect
LaserFire
Sound effect
BruiserStomp
Sound effect
RaiderSwoop
Sound effect
ShieldLevelUp
Sound effect
HeroHit
Sound effect
HeroScream
Sound effect