User prompt
Play the game according to your own settings, make it fun but a little difficult, and adjust the jumping accordingly, but make it beautiful.
User prompt
Reduce jump by 1x
User prompt
The game should be difficult but not that hard, the jump is tripled
User prompt
It is not possible to jump more or
User prompt
It is not possible to jump more or
User prompt
Let the game go from coding to difficulty and have sections, 1 is very easy, 2 is easy, 3 is difficult and so on, and have sections and difficulty on top.
User prompt
Please fix the bug: 'TypeError: LK.effects.shake is not a function' in or related to this line: 'LK.effects.shake(game, 12, 120);' Line Number: 106
User prompt
Please fix the bug: 'TypeError: LK.effects.shakeScreen is not a function' in or related to this line: 'LK.effects.shakeScreen(12, 120);' Line Number: 106
User prompt
Let the jipping be better, let the game be more fun and give a fun feeling like in that game.
Code edit (1 edits merged)
Please save this source code
User prompt
Dash of Geometry
Initial prompt
Let it be like geometry dash, let it be very beautiful and have a menu screen with lots of effects.
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
// Particle class for jump/dash effects
var Particle = Container.expand(function () {
var self = Container.call(this);
var p = self.attachAsset('particle', {
anchorX: 0.5,
anchorY: 0.5
});
self.life = 30 + Math.random() * 20;
self.vx = (Math.random() - 0.5) * 16;
self.vy = -8 - Math.random() * 8;
self.alpha = 1;
self.update = function () {
self.x += self.vx;
self.y += self.vy;
self.vy += 1.2;
self.life--;
self.alpha -= 0.03;
if (self.life <= 0 || self.alpha <= 0) {
self.destroy();
}
};
return self;
});
// Player class
var Player = Container.expand(function () {
var self = Container.call(this);
var cube = self.attachAsset('playerCube', {
anchorX: 0.5,
anchorY: 1
});
self.width = cube.width;
self.height = cube.height;
self.velY = 0;
self.isGrounded = false;
self.jumpPower = -38;
self.gravity = 3.2;
self.alive = true;
self.jumpQueued = false;
// For jump effect
self.jumpEffect = function () {
tween(self, {
scaleX: 1.2,
scaleY: 0.8
}, {
duration: 80,
easing: tween.cubicOut,
onFinish: function onFinish() {
tween(self, {
scaleX: 1,
scaleY: 1
}, {
duration: 120,
easing: tween.cubicIn
});
}
});
};
// Called every tick
self.update = function () {
if (!self.alive) return;
// Gravity
self.velY += self.gravity;
self.y += self.velY;
// Clamp to ground
if (self.y > groundY) {
self.y = groundY;
self.velY = 0;
self.isGrounded = true;
} else {
self.isGrounded = false;
}
// Jump if queued
if (self.jumpQueued && self.isGrounded) {
self.velY = self.jumpPower;
self.isGrounded = false;
self.jumpQueued = false;
self.jumpEffect();
spawnJumpParticles(self.x, self.y - self.height / 2);
}
};
// Call to queue a jump
self.jump = function () {
if (self.isGrounded && self.alive) {
self.jumpQueued = true;
}
};
// Call on death
self.die = function () {
self.alive = false;
tween(self, {
rotation: Math.PI * 2,
alpha: 0
}, {
duration: 600,
easing: tween.cubicIn
});
};
return self;
});
// Obstacle (spike) class
var Spike = Container.expand(function () {
var self = Container.call(this);
var spike = self.attachAsset('spike', {
anchorX: 0.5,
anchorY: 1
});
self.width = spike.width;
self.height = spike.height;
self.speed = 22;
self.update = function () {
self.x -= self.speed;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x181c2a
});
/****
* Game Code
****/
// Music
// Particle (small circle)
// Background effect (ellipse)
// Obstacle (spike)
// Ground platform
// Main player cube
// Game constants
var groundY = 2200;
var playerStartX = 420;
var playerStartY = groundY;
var gameSpeed = 22;
var spikeMinGap = 420;
var spikeMaxGap = 820;
var spikeTimer = 0;
var spikeGap = 0;
var score = 0;
var isGameActive = false;
var particles = [];
var spikes = [];
var bgEllipses = [];
var lastTick = 0;
// Background ellipses for visual effect
for (var i = 0; i < 3; i++) {
var bg = LK.getAsset('bgEllipse', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024 + (i - 1) * 900,
y: 1200 + i * 200,
scaleX: 1.2 + i * 0.2,
scaleY: 1.1 + i * 0.1,
alpha: 0.18 + i * 0.07
});
game.addChild(bg);
bgEllipses.push(bg);
}
// Ground
var ground = LK.getAsset('ground', {
anchorX: 0,
anchorY: 0,
x: 0,
y: groundY
});
game.addChild(ground);
// Player
var player = new Player();
player.x = playerStartX;
player.y = playerStartY;
game.addChild(player);
// Score text
var scoreTxt = new Text2('0', {
size: 120,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Animated title for menu
var titleTxt = new Text2('Dash of Geometry', {
size: 160,
fill: 0x00EAFF
});
titleTxt.anchor.set(0.5, 0.5);
titleTxt.x = 1024;
titleTxt.y = 900;
titleTxt.alpha = 1;
LK.gui.center.addChild(titleTxt);
// Tap to start text
var tapTxt = new Text2('Tap to Start', {
size: 80,
fill: 0xFFFFFF
});
tapTxt.anchor.set(0.5, 0.5);
tapTxt.x = 1024;
tapTxt.y = 1200;
tapTxt.alpha = 0.8;
LK.gui.center.addChild(tapTxt);
// Animate menu texts
tween(titleTxt, {
y: 820
}, {
duration: 900,
easing: tween.elasticOut
});
tween(tapTxt, {
alpha: 1
}, {
duration: 800,
easing: tween.cubicInOut
});
// Hide score at menu
scoreTxt.visible = false;
// Start game function
function startGame() {
// Remove menu
LK.gui.center.removeChild(titleTxt);
LK.gui.center.removeChild(tapTxt);
// Reset state
isGameActive = true;
score = 0;
scoreTxt.setText(score);
scoreTxt.visible = true;
// Reset player
player.x = playerStartX;
player.y = playerStartY;
player.velY = 0;
player.alive = true;
player.rotation = 0;
player.alpha = 1;
player.scaleX = 1;
player.scaleY = 1;
// Remove spikes
for (var i = spikes.length - 1; i >= 0; i--) {
spikes[i].destroy();
spikes.splice(i, 1);
}
// Remove particles
for (var i = particles.length - 1; i >= 0; i--) {
particles[i].destroy();
particles.splice(i, 1);
}
// Reset spike timer
spikeTimer = 0;
spikeGap = spikeMinGap + Math.random() * (spikeMaxGap - spikeMinGap);
// Play music
LK.playMusic('bgmusic', {
fade: {
start: 0,
end: 1,
duration: 1200
}
});
}
// End game function
function endGame() {
isGameActive = false;
player.die();
LK.effects.flashScreen(0xff2d55, 600);
LK.stopMusic();
LK.setTimeout(function () {
LK.showGameOver();
}, 900);
}
// Particle spawn on jump
function spawnJumpParticles(x, y) {
for (var i = 0; i < 8; i++) {
var p = new Particle();
p.x = x;
p.y = y + 40;
particles.push(p);
game.addChild(p);
}
}
// Particle spawn on score
function spawnScoreParticles(x, y) {
for (var i = 0; i < 12; i++) {
var p = new Particle();
p.x = x;
p.y = y;
p.vx = (Math.random() - 0.5) * 24;
p.vy = -12 - Math.random() * 10;
p.alpha = 1;
particles.push(p);
game.addChild(p);
}
}
// Main game update
game.update = function () {
// Animate background ellipses
for (var i = 0; i < bgEllipses.length; i++) {
var bg = bgEllipses[i];
bg.x -= 0.7 + i * 0.2;
if (bg.x < -400) {
bg.x = 2048 + 400;
}
}
// Menu animation
if (!isGameActive) {
// Pulse tap text
tapTxt.alpha = 0.7 + 0.3 * Math.sin(LK.ticks / 20);
titleTxt.rotation = Math.sin(LK.ticks / 60) * 0.04;
return;
}
// Player update
player.update();
// Spikes update
for (var i = spikes.length - 1; i >= 0; i--) {
var s = spikes[i];
s.update();
// Remove off-screen spikes
if (s.x < -s.width) {
s.destroy();
spikes.splice(i, 1);
continue;
}
// Collision with player
if (player.alive && player.intersects(s)) {
endGame();
return;
}
// Score when passed
if (!s.scored && s.x + s.width / 2 < player.x - player.width / 2) {
s.scored = true;
score++;
scoreTxt.setText(score);
spawnScoreParticles(player.x, player.y - player.height / 2);
// Win condition
if (score >= 30) {
LK.effects.flashScreen(0x00eaff, 800);
LK.showYouWin();
return;
}
}
}
// Particles update
for (var i = particles.length - 1; i >= 0; i--) {
var p = particles[i];
p.update();
if (p.life <= 0 || p.alpha <= 0) {
p.destroy();
particles.splice(i, 1);
}
}
// Spawn spikes
spikeTimer += gameSpeed;
if (spikeTimer > spikeGap) {
spikeTimer = 0;
spikeGap = spikeMinGap + Math.random() * (spikeMaxGap - spikeMinGap);
var s = new Spike();
s.x = 2048 + s.width / 2;
s.y = groundY;
s.scored = false;
spikes.push(s);
game.addChild(s);
}
};
// Tap to jump or start
game.down = function (x, y, obj) {
if (!isGameActive) {
startGame();
} else {
player.jump();
}
};
// Prevent drag
game.move = function (x, y, obj) {};
// On game over, show menu again
LK.on('gameover', function () {
// Show menu
LK.gui.center.addChild(titleTxt);
LK.gui.center.addChild(tapTxt);
scoreTxt.visible = false;
tween(titleTxt, {
y: 900
}, {
duration: 600,
easing: tween.elasticOut
});
tween(tapTxt, {
alpha: 1
}, {
duration: 600,
easing: tween.cubicInOut
});
});
// On win, show menu again
LK.on('youwin', function () {
LK.gui.center.addChild(titleTxt);
LK.gui.center.addChild(tapTxt);
scoreTxt.visible = false;
tween(titleTxt, {
y: 900
}, {
duration: 600,
easing: tween.elasticOut
});
tween(tapTxt, {
alpha: 1
}, {
duration: 600,
easing: tween.cubicInOut
});
}); ===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,414 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+
+/****
+* Classes
+****/
+// Particle class for jump/dash effects
+var Particle = Container.expand(function () {
+ var self = Container.call(this);
+ var p = self.attachAsset('particle', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.life = 30 + Math.random() * 20;
+ self.vx = (Math.random() - 0.5) * 16;
+ self.vy = -8 - Math.random() * 8;
+ self.alpha = 1;
+ self.update = function () {
+ self.x += self.vx;
+ self.y += self.vy;
+ self.vy += 1.2;
+ self.life--;
+ self.alpha -= 0.03;
+ if (self.life <= 0 || self.alpha <= 0) {
+ self.destroy();
+ }
+ };
+ return self;
+});
+// Player class
+var Player = Container.expand(function () {
+ var self = Container.call(this);
+ var cube = self.attachAsset('playerCube', {
+ anchorX: 0.5,
+ anchorY: 1
+ });
+ self.width = cube.width;
+ self.height = cube.height;
+ self.velY = 0;
+ self.isGrounded = false;
+ self.jumpPower = -38;
+ self.gravity = 3.2;
+ self.alive = true;
+ self.jumpQueued = false;
+ // For jump effect
+ self.jumpEffect = function () {
+ tween(self, {
+ scaleX: 1.2,
+ scaleY: 0.8
+ }, {
+ duration: 80,
+ easing: tween.cubicOut,
+ onFinish: function onFinish() {
+ tween(self, {
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 120,
+ easing: tween.cubicIn
+ });
+ }
+ });
+ };
+ // Called every tick
+ self.update = function () {
+ if (!self.alive) return;
+ // Gravity
+ self.velY += self.gravity;
+ self.y += self.velY;
+ // Clamp to ground
+ if (self.y > groundY) {
+ self.y = groundY;
+ self.velY = 0;
+ self.isGrounded = true;
+ } else {
+ self.isGrounded = false;
+ }
+ // Jump if queued
+ if (self.jumpQueued && self.isGrounded) {
+ self.velY = self.jumpPower;
+ self.isGrounded = false;
+ self.jumpQueued = false;
+ self.jumpEffect();
+ spawnJumpParticles(self.x, self.y - self.height / 2);
+ }
+ };
+ // Call to queue a jump
+ self.jump = function () {
+ if (self.isGrounded && self.alive) {
+ self.jumpQueued = true;
+ }
+ };
+ // Call on death
+ self.die = function () {
+ self.alive = false;
+ tween(self, {
+ rotation: Math.PI * 2,
+ alpha: 0
+ }, {
+ duration: 600,
+ easing: tween.cubicIn
+ });
+ };
+ return self;
+});
+// Obstacle (spike) class
+var Spike = Container.expand(function () {
+ var self = Container.call(this);
+ var spike = self.attachAsset('spike', {
+ anchorX: 0.5,
+ anchorY: 1
+ });
+ self.width = spike.width;
+ self.height = spike.height;
+ self.speed = 22;
+ self.update = function () {
+ self.x -= self.speed;
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
+ backgroundColor: 0x181c2a
+});
+
+/****
+* Game Code
+****/
+// Music
+// Particle (small circle)
+// Background effect (ellipse)
+// Obstacle (spike)
+// Ground platform
+// Main player cube
+// Game constants
+var groundY = 2200;
+var playerStartX = 420;
+var playerStartY = groundY;
+var gameSpeed = 22;
+var spikeMinGap = 420;
+var spikeMaxGap = 820;
+var spikeTimer = 0;
+var spikeGap = 0;
+var score = 0;
+var isGameActive = false;
+var particles = [];
+var spikes = [];
+var bgEllipses = [];
+var lastTick = 0;
+// Background ellipses for visual effect
+for (var i = 0; i < 3; i++) {
+ var bg = LK.getAsset('bgEllipse', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 1024 + (i - 1) * 900,
+ y: 1200 + i * 200,
+ scaleX: 1.2 + i * 0.2,
+ scaleY: 1.1 + i * 0.1,
+ alpha: 0.18 + i * 0.07
+ });
+ game.addChild(bg);
+ bgEllipses.push(bg);
+}
+// Ground
+var ground = LK.getAsset('ground', {
+ anchorX: 0,
+ anchorY: 0,
+ x: 0,
+ y: groundY
+});
+game.addChild(ground);
+// Player
+var player = new Player();
+player.x = playerStartX;
+player.y = playerStartY;
+game.addChild(player);
+// Score text
+var scoreTxt = new Text2('0', {
+ size: 120,
+ fill: 0xFFFFFF
+});
+scoreTxt.anchor.set(0.5, 0);
+LK.gui.top.addChild(scoreTxt);
+// Animated title for menu
+var titleTxt = new Text2('Dash of Geometry', {
+ size: 160,
+ fill: 0x00EAFF
+});
+titleTxt.anchor.set(0.5, 0.5);
+titleTxt.x = 1024;
+titleTxt.y = 900;
+titleTxt.alpha = 1;
+LK.gui.center.addChild(titleTxt);
+// Tap to start text
+var tapTxt = new Text2('Tap to Start', {
+ size: 80,
+ fill: 0xFFFFFF
+});
+tapTxt.anchor.set(0.5, 0.5);
+tapTxt.x = 1024;
+tapTxt.y = 1200;
+tapTxt.alpha = 0.8;
+LK.gui.center.addChild(tapTxt);
+// Animate menu texts
+tween(titleTxt, {
+ y: 820
+}, {
+ duration: 900,
+ easing: tween.elasticOut
+});
+tween(tapTxt, {
+ alpha: 1
+}, {
+ duration: 800,
+ easing: tween.cubicInOut
+});
+// Hide score at menu
+scoreTxt.visible = false;
+// Start game function
+function startGame() {
+ // Remove menu
+ LK.gui.center.removeChild(titleTxt);
+ LK.gui.center.removeChild(tapTxt);
+ // Reset state
+ isGameActive = true;
+ score = 0;
+ scoreTxt.setText(score);
+ scoreTxt.visible = true;
+ // Reset player
+ player.x = playerStartX;
+ player.y = playerStartY;
+ player.velY = 0;
+ player.alive = true;
+ player.rotation = 0;
+ player.alpha = 1;
+ player.scaleX = 1;
+ player.scaleY = 1;
+ // Remove spikes
+ for (var i = spikes.length - 1; i >= 0; i--) {
+ spikes[i].destroy();
+ spikes.splice(i, 1);
+ }
+ // Remove particles
+ for (var i = particles.length - 1; i >= 0; i--) {
+ particles[i].destroy();
+ particles.splice(i, 1);
+ }
+ // Reset spike timer
+ spikeTimer = 0;
+ spikeGap = spikeMinGap + Math.random() * (spikeMaxGap - spikeMinGap);
+ // Play music
+ LK.playMusic('bgmusic', {
+ fade: {
+ start: 0,
+ end: 1,
+ duration: 1200
+ }
+ });
+}
+// End game function
+function endGame() {
+ isGameActive = false;
+ player.die();
+ LK.effects.flashScreen(0xff2d55, 600);
+ LK.stopMusic();
+ LK.setTimeout(function () {
+ LK.showGameOver();
+ }, 900);
+}
+// Particle spawn on jump
+function spawnJumpParticles(x, y) {
+ for (var i = 0; i < 8; i++) {
+ var p = new Particle();
+ p.x = x;
+ p.y = y + 40;
+ particles.push(p);
+ game.addChild(p);
+ }
+}
+// Particle spawn on score
+function spawnScoreParticles(x, y) {
+ for (var i = 0; i < 12; i++) {
+ var p = new Particle();
+ p.x = x;
+ p.y = y;
+ p.vx = (Math.random() - 0.5) * 24;
+ p.vy = -12 - Math.random() * 10;
+ p.alpha = 1;
+ particles.push(p);
+ game.addChild(p);
+ }
+}
+// Main game update
+game.update = function () {
+ // Animate background ellipses
+ for (var i = 0; i < bgEllipses.length; i++) {
+ var bg = bgEllipses[i];
+ bg.x -= 0.7 + i * 0.2;
+ if (bg.x < -400) {
+ bg.x = 2048 + 400;
+ }
+ }
+ // Menu animation
+ if (!isGameActive) {
+ // Pulse tap text
+ tapTxt.alpha = 0.7 + 0.3 * Math.sin(LK.ticks / 20);
+ titleTxt.rotation = Math.sin(LK.ticks / 60) * 0.04;
+ return;
+ }
+ // Player update
+ player.update();
+ // Spikes update
+ for (var i = spikes.length - 1; i >= 0; i--) {
+ var s = spikes[i];
+ s.update();
+ // Remove off-screen spikes
+ if (s.x < -s.width) {
+ s.destroy();
+ spikes.splice(i, 1);
+ continue;
+ }
+ // Collision with player
+ if (player.alive && player.intersects(s)) {
+ endGame();
+ return;
+ }
+ // Score when passed
+ if (!s.scored && s.x + s.width / 2 < player.x - player.width / 2) {
+ s.scored = true;
+ score++;
+ scoreTxt.setText(score);
+ spawnScoreParticles(player.x, player.y - player.height / 2);
+ // Win condition
+ if (score >= 30) {
+ LK.effects.flashScreen(0x00eaff, 800);
+ LK.showYouWin();
+ return;
+ }
+ }
+ }
+ // Particles update
+ for (var i = particles.length - 1; i >= 0; i--) {
+ var p = particles[i];
+ p.update();
+ if (p.life <= 0 || p.alpha <= 0) {
+ p.destroy();
+ particles.splice(i, 1);
+ }
+ }
+ // Spawn spikes
+ spikeTimer += gameSpeed;
+ if (spikeTimer > spikeGap) {
+ spikeTimer = 0;
+ spikeGap = spikeMinGap + Math.random() * (spikeMaxGap - spikeMinGap);
+ var s = new Spike();
+ s.x = 2048 + s.width / 2;
+ s.y = groundY;
+ s.scored = false;
+ spikes.push(s);
+ game.addChild(s);
+ }
+};
+// Tap to jump or start
+game.down = function (x, y, obj) {
+ if (!isGameActive) {
+ startGame();
+ } else {
+ player.jump();
+ }
+};
+// Prevent drag
+game.move = function (x, y, obj) {};
+// On game over, show menu again
+LK.on('gameover', function () {
+ // Show menu
+ LK.gui.center.addChild(titleTxt);
+ LK.gui.center.addChild(tapTxt);
+ scoreTxt.visible = false;
+ tween(titleTxt, {
+ y: 900
+ }, {
+ duration: 600,
+ easing: tween.elasticOut
+ });
+ tween(tapTxt, {
+ alpha: 1
+ }, {
+ duration: 600,
+ easing: tween.cubicInOut
+ });
+});
+// On win, show menu again
+LK.on('youwin', function () {
+ LK.gui.center.addChild(titleTxt);
+ LK.gui.center.addChild(tapTxt);
+ scoreTxt.visible = false;
+ tween(titleTxt, {
+ y: 900
+ }, {
+ duration: 600,
+ easing: tween.elasticOut
+ });
+ tween(tapTxt, {
+ alpha: 1
+ }, {
+ duration: 600,
+ easing: tween.cubicInOut
+ });
});
\ No newline at end of file