User prompt
Thats too fast make all 0.7 times what its now
User prompt
make the game go faster in general
User prompt
apply the "background" music to play when the game is playing in a loop
User prompt
apply the pick powerup and pick shield sounds to their respective places
User prompt
use jump sound when player jumps
User prompt
Use dash-fast when the player dashes
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'length')' in or related to this line: 'for (var i = 0; i < platforms.length; i++) {' Line Number: 225
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Graphics is not a constructor' in or related to this line: 'var dashBg = new Graphics();' Line Number: 293
Code edit (1 edits merged)
Please save this source code
Initial prompt
Neon Dash
/****
* Classes
****/
var DashEffect = Container.expand(function () {
var self = Container.call(this);
var effectGraphics = self.attachAsset('dashEffect', {
anchorX: 0.5,
anchorY: 0.5
});
self.lifetime = 10;
self.alpha = 0.8;
self.update = function () {
self.lifetime--;
self.alpha = self.lifetime / 10;
self.x -= 15;
if (self.lifetime <= 0) {
self.destroy();
return true;
}
return false;
};
});
var Enemy = Container.expand(function () {
var self = Container.call(this);
var enemyGraphics = self.attachAsset('enemyShape', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 7;
self.verticalSpeed = Math.random() * 4 - 2;
self.verticalDirection = 1;
self.verticalDistance = 0;
self.maxVerticalDistance = 100 + Math.random() * 200;
self.update = function (gameSpeed) {
self.x -= self.speed * gameSpeed;
// Vertical movement
self.verticalDistance += Math.abs(self.verticalSpeed);
if (self.verticalDistance > self.maxVerticalDistance) {
self.verticalDirection *= -1;
self.verticalDistance = 0;
}
self.y += self.verticalSpeed * self.verticalDirection;
// Keep within bounds
if (self.y < 60) {
self.y = 60;
self.verticalDirection *= -1;
} else if (self.y > 2732 - 100) {
self.y = 2732 - 100;
self.verticalDirection *= -1;
}
return self.x < -100;
};
});
var Obstacle = Container.expand(function () {
var self = Container.call(this);
var obstacleGraphics = self.attachAsset('obstacle', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 10;
self.update = function (gameSpeed) {
self.x -= self.speed * gameSpeed;
return self.x < -100;
};
});
var Particle = Container.expand(function () {
var self = Container.call(this);
var particleGraphics = self.attachAsset('particle', {
anchorX: 0.5,
anchorY: 0.5
});
self.lifetime = 30;
self.alpha = 1;
self.scale.set(1);
self.update = function () {
self.lifetime--;
self.alpha = self.lifetime / 30;
self.scale.set(1 - self.lifetime / 30 * 0.5);
if (self.lifetime <= 0) {
self.destroy();
return true;
}
return false;
};
});
var Player = Container.expand(function () {
var self = Container.call(this);
var playerGraphics = self.attachAsset('platform', {
anchorX: 0.5,
anchorY: 0.5,
width: 60,
height: 60
});
playerGraphics.tint = 0x00ffaa;
self.velocity = {
x: 0,
y: 0
};
self.speed = 15;
self.jumpForce = -20;
self.gravity = 1;
self.isJumping = false;
self.isDashing = false;
self.dashCooldown = 0;
self.dashDuration = 0;
self.hasShield = false;
self.shieldObj = null;
self.particles = [];
self.jump = function () {
if (!self.isJumping) {
self.velocity.y = self.jumpForce;
self.isJumping = true;
}
};
self.dash = function () {
if (self.dashCooldown <= 0) {
self.isDashing = true;
self.dashDuration = 15;
self.dashCooldown = 60;
// Create dash effect
var effect = new DashEffect();
effect.x = self.x - 50;
effect.y = self.y;
self.parent.addChild(effect);
}
};
self.activateShield = function () {
self.hasShield = true;
if (!self.shieldObj) {
self.shieldObj = self.addChild(new Shield());
}
};
self.deactivateShield = function () {
self.hasShield = false;
if (self.shieldObj) {
self.shieldObj.destroy();
self.shieldObj = null;
}
};
self.update = function () {
// Apply gravity
if (self.isJumping) {
self.velocity.y += self.gravity;
}
// Update position
self.y += self.velocity.y;
// Handle dash
if (self.isDashing) {
self.dashDuration--;
if (self.dashDuration <= 0) {
self.isDashing = false;
}
}
// Update dash cooldown
if (self.dashCooldown > 0) {
self.dashCooldown--;
}
// Floor collision
if (self.y > 2732 - 100) {
self.y = 2732 - 100;
self.velocity.y = 0;
self.isJumping = false;
}
// Ceiling collision
if (self.y < 60) {
self.y = 60;
self.velocity.y = 0;
}
// Create trail particles
if (LK.ticks % 3 === 0) {
var particle = new Particle();
particle.x = self.x - 30;
particle.y = self.y;
particle.tint = self.isDashing ? 0xffffff : 0x00ffaa;
self.parent.addChild(particle);
self.particles.push(particle);
}
// Update particles
for (var i = self.particles.length - 1; i >= 0; i--) {
if (self.particles[i].update()) {
self.particles.splice(i, 1);
}
}
};
});
var PowerUp = Container.expand(function () {
var self = Container.call(this);
var powerupGraphics = self.attachAsset('powerup', {
anchorX: 0.5,
anchorY: 0.5
});
self.type = Math.random() < 0.5 ? 'shield' : 'score';
powerupGraphics.tint = self.type === 'shield' ? 0x3399ff : 0xffff00;
self.speed = 8;
self.rotation = 0;
self.update = function (gameSpeed) {
self.x -= self.speed * gameSpeed;
self.rotation += 0.05;
return self.x < -100;
};
});
var ScorePopup = Container.expand(function (value, color) {
var self = Container.call(this);
var scoreTxt = new Text2("+" + value, {
size: 40,
fill: color || 0xffff00
});
scoreTxt.anchor.set(0.5);
self.addChild(scoreTxt);
self.lifetime = 30;
self.update = function () {
self.lifetime--;
self.y -= 2;
self.alpha = self.lifetime / 30;
if (self.lifetime <= 0) {
self.destroy();
return true;
}
return false;
};
});
var Shield = Container.expand(function () {
var self = Container.call(this);
var shieldGraphics = self.attachAsset('shield', {
anchorX: 0.5,
anchorY: 0.5
});
shieldGraphics.alpha = 0.5;
self.update = function () {
self.rotation += 0.02;
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000033
});
/****
* Game Code
****/
// Background
var background = game.attachAsset('background', {});
game.addChildAt(background, 0);
// Game variables
var player = game.addChild(new Player());
player.x = 300;
player.y = 2732 / 2;
var obstacles = [];
var powerups = [];
var enemies = [];
var effects = [];
var scorePopups = [];
var score = 0;
var distance = 0;
var gameSpeed = 1;
var isGameOver = false;
// UI elements
var scoreTxt = new Text2('SCORE: 0', {
size: 50,
fill: 0xffffff
});
scoreTxt.anchor.set(0, 0);
scoreTxt.x = 20;
scoreTxt.y = 20;
LK.gui.top.addChild(scoreTxt);
var distanceTxt = new Text2('DISTANCE: 0m', {
size: 50,
fill: 0xffffff
});
distanceTxt.anchor.set(0, 0);
distanceTxt.x = 20;
distanceTxt.y = 80;
LK.gui.top.addChild(distanceTxt);
var dashMeter = new Container();
dashMeter.x = 20;
dashMeter.y = 140;
LK.gui.top.addChild(dashMeter);
var dashBg = LK.getAsset('dashEffect', {
anchorX: 0,
anchorY: 0
});
dashBg.width = 200;
dashBg.height = 20;
dashBg.tint = 0x333333;
dashMeter.addChild(dashBg);
var dashFill = LK.getAsset('dashEffect', {
anchorX: 0,
anchorY: 0
});
dashFill.width = 200;
dashFill.height = 20;
dashFill.tint = 0x00ffaa;
dashMeter.addChild(dashFill);
var dashTxt = new Text2('DASH', {
size: 30,
fill: 0xffffff
});
dashTxt.anchor.set(0, 0.5);
dashTxt.x = 210;
dashTxt.y = 10;
dashMeter.addChild(dashTxt);
// Input handling
game.on('down', function (x, y, obj) {
if (isGameOver) {
return;
}
var event = obj;
var pos = game.toLocal(event.global);
if (pos.y < 2732 / 2) {
player.jump();
} else {
player.dash();
}
});
// Game loop
LK.on('tick', function () {
if (isGameOver) {
return;
}
// Update player
player.update();
// Update dash meter
dashFill.scale.x = (60 - player.dashCooldown) / 60;
// Update game speed
gameSpeed = 1 + distance / 5000;
// Update distance
distance += gameSpeed;
distanceTxt.setText('DISTANCE: ' + Math.floor(distance) + 'm');
// Spawn obstacles
if (LK.ticks % Math.floor(60 / gameSpeed) === 0 && Math.random() < 0.3) {
var obstacle = new Obstacle();
obstacle.x = 2048 + 100;
obstacle.y = 2732 - 100 - Math.random() * (2732 - 200);
obstacles.push(obstacle);
game.addChild(obstacle);
}
// Spawn powerups
if (LK.ticks % Math.floor(180 / gameSpeed) === 0 && Math.random() < 0.5) {
var powerup = new PowerUp();
powerup.x = 2048 + 100;
powerup.y = 100 + Math.random() * (2732 - 200);
powerups.push(powerup);
game.addChild(powerup);
}
// Spawn enemies
if (LK.ticks % Math.floor(120 / gameSpeed) === 0 && Math.random() < 0.4) {
var enemy = new Enemy();
enemy.x = 2048 + 100;
enemy.y = 100 + Math.random() * (2732 - 200);
enemies.push(enemy);
game.addChild(enemy);
}
// Update obstacles
for (var i = obstacles.length - 1; i >= 0; i--) {
if (obstacles[i].update(gameSpeed)) {
obstacles[i].destroy();
obstacles.splice(i, 1);
continue;
}
// Collision with player
if (obstacles[i].intersects(player)) {
if (player.isDashing) {
// Destroy obstacle when dashing
var points = 50;
score += points;
var popup = new ScorePopup(points, 0x00ffaa);
popup.x = obstacles[i].x;
popup.y = obstacles[i].y;
scorePopups.push(popup);
game.addChild(popup);
obstacles[i].destroy();
obstacles.splice(i, 1);
} else if (player.hasShield) {
// Shield protects from one hit
player.deactivateShield();
obstacles[i].destroy();
obstacles.splice(i, 1);
} else {
// Game over
gameOver();
}
}
}
// Update powerups
for (var j = powerups.length - 1; j >= 0; j--) {
if (powerups[j].update(gameSpeed)) {
powerups[j].destroy();
powerups.splice(j, 1);
continue;
}
// Collision with player
if (powerups[j].intersects(player)) {
if (powerups[j].type === 'shield') {
player.activateShield();
var shieldPopup = new ScorePopup("SHIELD", 0x3399ff);
shieldPopup.x = powerups[j].x;
shieldPopup.y = powerups[j].y;
scorePopups.push(shieldPopup);
game.addChild(shieldPopup);
} else {
var bonusPoints = 100;
score += bonusPoints;
var scoreBonus = new ScorePopup(bonusPoints);
scoreBonus.x = powerups[j].x;
scoreBonus.y = powerups[j].y;
scorePopups.push(scoreBonus);
game.addChild(scoreBonus);
}
powerups[j].destroy();
powerups.splice(j, 1);
}
}
// Update enemies
for (var k = enemies.length - 1; k >= 0; k--) {
if (enemies[k].update(gameSpeed)) {
enemies[k].destroy();
enemies.splice(k, 1);
continue;
}
// Collision with player
if (enemies[k].intersects(player)) {
if (player.isDashing) {
// Destroy enemy when dashing
var enemyPoints = 200;
score += enemyPoints;
var enemyPopup = new ScorePopup(enemyPoints, 0xff00ff);
enemyPopup.x = enemies[k].x;
enemyPopup.y = enemies[k].y;
scorePopups.push(enemyPopup);
game.addChild(enemyPopup);
enemies[k].destroy();
enemies.splice(k, 1);
} else if (player.hasShield) {
// Shield protects from one hit
player.deactivateShield();
enemies[k].destroy();
enemies.splice(k, 1);
} else {
// Game over
gameOver();
}
}
}
// Update shield
if (player.shieldObj) {
player.shieldObj.update();
}
// Update score popups
for (var m = scorePopups.length - 1; m >= 0; m--) {
if (scorePopups[m].update()) {
scorePopups.splice(m, 1);
}
}
// Update score
score += Math.floor(gameSpeed);
scoreTxt.setText('SCORE: ' + score);
LK.setScore(score);
});
function gameOver() {
isGameOver = true;
LK.showGameOver();
} ===================================================================
--- original.js
+++ change.js
@@ -277,17 +277,23 @@
var dashMeter = new Container();
dashMeter.x = 20;
dashMeter.y = 140;
LK.gui.top.addChild(dashMeter);
-var dashBg = new Graphics();
-dashBg.beginFill(0x333333);
-dashBg.drawRect(0, 0, 200, 20);
-dashBg.endFill();
+var dashBg = LK.getAsset('dashEffect', {
+ anchorX: 0,
+ anchorY: 0
+});
+dashBg.width = 200;
+dashBg.height = 20;
+dashBg.tint = 0x333333;
dashMeter.addChild(dashBg);
-var dashFill = new Graphics();
-dashFill.beginFill(0x00ffaa);
-dashFill.drawRect(0, 0, 200, 20);
-dashFill.endFill();
+var dashFill = LK.getAsset('dashEffect', {
+ anchorX: 0,
+ anchorY: 0
+});
+dashFill.width = 200;
+dashFill.height = 20;
+dashFill.tint = 0x00ffaa;
dashMeter.addChild(dashFill);
var dashTxt = new Text2('DASH', {
size: 30,
fill: 0xffffff
neon for obstacle in endless runner game, like a spiky obstacle but still many rectangle or angled surfaces, not round, pink neon colors. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows. neon. polygon shapes
flying neon enemy, blocky, sharp angles. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows