User prompt
Increase slide speed
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'tween(self, {' Line Number: 261
User prompt
Slide faster is not working
User prompt
Swipe right side any where on the screen to slide
User prompt
Add swipe to slide faster for 200 ms and get back normal ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Remove hold to slide
User prompt
replace hold to slided to swipe right to slide 1 sec fasster
User prompt
swipe to slide fast for a second is not working properly
User prompt
player hit by the enemey cube for three times to game over
User prompt
replace hold to slide to right swipe to faster slide (slide 1 sec faster)
User prompt
swipe right to move 2 sec faster
User prompt
replace hold to slide to swipe to slide
User prompt
double jump should be little higher jump
User prompt
aadd double bounce to the player for double clicl
User prompt
i need enemy obstacle on the top parellel like player shooting the cubes towards the player from upside if the cubes hit the player game over
User prompt
search lights always follows thge player
User prompt
i need the cube should rotate while moving ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
particles also rotate along with cube
User prompt
cube need to rotate slowly while moving ↪💡 Consider importing and using the following plugins: @upit/tween.v1
Code edit (1 edits merged)
Please save this source code
User prompt
Sqube Darkness
Initial prompt
Key Features of Sqube Darkness: You play as a small cube (sqube) running across platforms. The game is set in a shadowy world, where the background and obstacles are dark, and the cube is often the only clear object. The gameplay involves: Running, jumping, sliding. Avoiding obstacles like spikes and lasers. Sometimes, using the shadows to hide from enemies (like searchlights or shooters). The game has a procedurally generated endless level, meaning every run is different. 🎨 Aesthetic: Monochrome color palette: Mostly black, white, and gray tones. Minimal UI and a smooth, satisfying movement system. Cool audio effects and smooth transitions.
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ var Obstacle = Container.expand(function (type) { var self = Container.call(this); self.type = type || 'spike'; self.speed = 10; if (self.type === 'spike') { var spikeGraphic = self.attachAsset('spike', { anchorX: 0.5, anchorY: 1.0 }); self.width = spikeGraphic.width; self.height = spikeGraphic.height; } else if (self.type === 'laser') { var laserGraphic = self.attachAsset('laser', { anchorX: 0.0, anchorY: 0.5, alpha: 0.7 }); self.width = laserGraphic.width; self.height = laserGraphic.height; // Laser activation self.active = false; self.warningTime = 30; self.activeTime = 60; self.timer = self.warningTime; // Warning effect self.flash = function () { if (self.timer % 5 === 0) { laserGraphic.alpha = laserGraphic.alpha === 0.3 ? 0.7 : 0.3; } }; } else if (self.type === 'searchlight') { var searchlightGraphic = self.attachAsset('searchlight', { anchorX: 0.5, anchorY: 0.0, alpha: 0.5 }); self.width = searchlightGraphic.width; self.height = searchlightGraphic.height; } self.update = function () { self.x -= self.speed; // Laser special behavior if (self.type === 'laser') { self.timer--; if (self.timer > 0 && !self.active) { // Warning phase self.flash(); } else if (!self.active) { // Activate self.active = true; laserGraphic.alpha = 1; self.timer = self.activeTime; } else if (self.timer <= 0) { // Deactivate self.destroy(); return true; } } // Remove if off screen if (self.x < -self.width) { self.destroy(); return true; // Signal to remove from the array } return false; }; return self; }); var Platform = Container.expand(function () { var self = Container.call(this); var platformGraphic = self.attachAsset('platform', { anchorX: 0.5, anchorY: 0.0 }); self.width = platformGraphic.width; self.height = platformGraphic.height; self.speed = 10; self.update = function () { self.x -= self.speed; // Remove if off screen if (self.x < -self.width) { self.destroy(); return true; // Signal to remove from the array } return false; }; return self; }); var Player = Container.expand(function () { var self = Container.call(this); // Player states self.isJumping = false; self.isSliding = false; self.isHiding = false; self.isDead = false; self.velocity = { x: 0, y: 0 }; self.gravity = 1.2; self.jumpForce = -25; self.groundY = 2200; // Visual components var cube = self.attachAsset('player', { anchorX: 0.5, anchorY: 0.5 }); // Set initial rotation and rotation speed self.rotationSpeed = 0.05; self.currentRotation = 0; // Particle system for the player's trail self.particles = []; // Player controls self.jump = function () { if (!self.isJumping && !self.isDead) { self.velocity.y = self.jumpForce; self.isJumping = true; // Increase rotation speed temporarily when jumping tween(self, { rotationSpeed: 0.15 }, { duration: 300, easing: tween.easeOut, onFinish: function onFinish() { tween(self, { rotationSpeed: 0.05 }, { duration: 500, easing: tween.easeIn }); } }); LK.getSound('jump').play(); } }; self.slide = function () { if (!self.isSliding && !self.isJumping && !self.isDead) { self.isSliding = true; cube.scaleY = 0.5; cube.y = 25; // Increase rotation speed during slide tween(self, { rotationSpeed: 0.2 }, { duration: 200, easing: tween.easeOut }); LK.getSound('slide').play(); // Cancel slide after a duration LK.setTimeout(function () { if (self.isSliding) { self.isSliding = false; cube.scaleY = 1; cube.y = 0; // Return to normal rotation speed tween(self, { rotationSpeed: 0.05 }, { duration: 300, easing: tween.easeIn }); } }, 800); } }; self.hide = function (shadow) { if (!self.isDead && shadow) { self.isHiding = true; cube.alpha = 0.3; LK.getSound('hide').play(); } }; self.unhide = function () { self.isHiding = false; cube.alpha = 1; }; self.die = function () { if (!self.isDead) { self.isDead = true; // Stop rotation by tweening to zero tween(self, { rotationSpeed: 0 }, { duration: 100 }); LK.getSound('death').play(); LK.effects.flashScreen(0xff0000, 500); // Create death particles for (var i = 0; i < 20; i++) { var particle = LK.getAsset('particle', { anchorX: 0.5, anchorY: 0.5, x: self.x, y: self.y }); // Random velocity for each particle var angle = Math.random() * Math.PI * 2; var speed = 5 + Math.random() * 10; particle.vx = Math.cos(angle) * speed; particle.vy = Math.sin(angle) * speed; game.addChild(particle); deathParticles.push(particle); } LK.setTimeout(function () { LK.showGameOver(); }, 1000); } }; // Physics update self.updatePhysics = function () { if (self.isDead) { return; } // Apply gravity self.velocity.y += self.gravity; // Update position self.y += self.velocity.y; // Check floor collision if (self.y >= self.groundY) { self.y = self.groundY; self.velocity.y = 0; self.isJumping = false; } // Update cube rotation when moving if (gameRunning && !self.isDead) { self.currentRotation += self.rotationSpeed; cube.rotation = self.currentRotation; } // Create trail particles if (gameRunning && LK.ticks % 5 === 0) { var particle = LK.getAsset('particle', { anchorX: 0.5, anchorY: 0.5, x: self.x - 30, y: self.y + (self.isSliding ? 25 : 0) }); particle.alpha = 0.7; particle.life = 30; game.addChild(particle); self.particles.push(particle); } // Update particles for (var i = self.particles.length - 1; i >= 0; i--) { var p = self.particles[i]; p.alpha -= 0.02; p.scaleX -= 0.02; p.scaleY -= 0.02; p.life--; if (p.life <= 0 || p.alpha <= 0) { p.destroy(); self.particles.splice(i, 1); } } }; return self; }); var Shadow = Container.expand(function () { var self = Container.call(this); var shadowGraphic = self.attachAsset('shadow', { anchorX: 0.5, anchorY: 0.5, alpha: 0.5 }); self.width = shadowGraphic.width; self.height = shadowGraphic.height; self.speed = 10; self.update = function () { self.x -= self.speed; // Remove if off screen if (self.x < -self.width) { self.destroy(); return true; // Signal to remove from the array } return false; }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x111111 }); /**** * Game Code ****/ // Game state var gameRunning = false; var speed = 10; var score = 0; var highScore = storage.highScore || 0; var platformY = 2200; var spawnDistance = 800; var nextSpawnX = 2048 + 200; var difficultyTimer = 0; var difficultyInterval = 1000; // Game elements var player; var platforms = []; var obstacles = []; var shadows = []; var deathParticles = []; // UI elements var scoreTxt; var highScoreTxt; var tapToStartTxt; // Initialize the game function initGame() { gameRunning = false; speed = 10; score = 0; platformY = 2200; spawnDistance = 800; nextSpawnX = 2048 + 200; difficultyTimer = 0; // Clear existing elements while (platforms.length > 0) { platforms[0].destroy(); platforms.shift(); } while (obstacles.length > 0) { obstacles[0].destroy(); obstacles.shift(); } while (shadows.length > 0) { shadows[0].destroy(); shadows.shift(); } while (deathParticles.length > 0) { deathParticles[0].destroy(); deathParticles.shift(); } // Create player player = new Player(); player.x = 400; player.y = platformY; game.addChild(player); // Create initial platform createPlatform(0, platformY, 2048 + 500); // Create UI if (!scoreTxt) { scoreTxt = new Text2('Score: 0', { size: 60, fill: 0xFFFFFF }); scoreTxt.anchor.set(0, 0); LK.gui.topRight.addChild(scoreTxt); scoreTxt.x = -250; scoreTxt.y = 50; } if (!highScoreTxt) { highScoreTxt = new Text2('High Score: ' + highScore, { size: 40, fill: 0xAAAAAA }); highScoreTxt.anchor.set(0, 0); LK.gui.topRight.addChild(highScoreTxt); highScoreTxt.x = -250; highScoreTxt.y = 120; } // Create start instruction tapToStartTxt = new Text2('Tap to Start\nTap to Jump\nHold to Slide\nHide in Shadows', { size: 70, fill: 0xFFFFFF }); tapToStartTxt.anchor.set(0.5, 0.5); LK.gui.center.addChild(tapToStartTxt); // Start the background music LK.playMusic('gameBgm', { fade: { start: 0, end: 0.4, duration: 1000 } }); } // Create a platform at the specified position function createPlatform(x, y, width) { var platform = new Platform(); platform.x = x; platform.y = y; if (width) { platform.width = width; platform.getChildAt(0).width = width; } game.addChild(platform); platforms.push(platform); return platform; } // Create an obstacle function createObstacle(type, x, y) { var obstacle = new Obstacle(type); obstacle.x = x; obstacle.y = y; if (type === 'laser') { obstacle.y = Math.random() * 1500 + 500; } game.addChild(obstacle); obstacles.push(obstacle); return obstacle; } // Create a shadow area function createShadow(x, y) { var shadow = new Shadow(); shadow.x = x; shadow.y = y; game.addChild(shadow); shadows.push(shadow); return shadow; } // Spawn game elements function spawnElements() { if (nextSpawnX <= 2048 + 200) { // Decide what to spawn var rand = Math.random(); // Always spawn a platform var platform = createPlatform(nextSpawnX, platformY); // Maybe spawn an obstacle if (rand < 0.7) { if (rand < 0.4) { // Spawn spike createObstacle('spike', nextSpawnX, platformY); } else if (rand < 0.6) { // Spawn searchlight createObstacle('searchlight', nextSpawnX, 0); } else { // Spawn laser createObstacle('laser', 0, 0); } } // Maybe spawn a shadow if (Math.random() < 0.3) { createShadow(nextSpawnX, platformY - 40); } nextSpawnX += spawnDistance; } nextSpawnX -= speed; } // Check for collisions function checkCollisions() { if (player.isDead) { return; } // Check obstacle collisions for (var i = 0; i < obstacles.length; i++) { var obstacle = obstacles[i]; if (obstacle.type === 'laser' && !obstacle.active) { continue; // Skip inactive lasers } if (player.intersects(obstacle)) { // If in a shadow and it's a searchlight, you're safe if (obstacle.type === 'searchlight' && player.isHiding) { continue; } player.die(); break; } } // Check shadow interactions var inShadow = false; for (var j = 0; j < shadows.length; j++) { if (player.intersects(shadows[j])) { inShadow = true; break; } } if (inShadow) { player.hide(); } else { player.unhide(); } } // Update score function updateScore() { if (!gameRunning || player.isDead) { return; } score++; if (score > highScore) { highScore = score; storage.highScore = highScore; highScoreTxt.setText('High Score: ' + highScore); } if (score % 10 === 0) { scoreTxt.setText('Score: ' + score); } } // Increase difficulty over time function updateDifficulty() { difficultyTimer++; if (difficultyTimer >= difficultyInterval) { difficultyTimer = 0; // Increase speed speed += 0.5; for (var i = 0; i < platforms.length; i++) { platforms[i].speed = speed; } for (var j = 0; j < obstacles.length; j++) { obstacles[j].speed = speed; } for (var k = 0; k < shadows.length; k++) { shadows[k].speed = speed; } // Decrease spawn distance spawnDistance = Math.max(400, spawnDistance - 10); } } // Main update function game.update = function () { if (gameRunning) { // Update game elements player.updatePhysics(); // Spawn new elements spawnElements(); // Update existing elements for (var i = platforms.length - 1; i >= 0; i--) { if (platforms[i].update()) { platforms.splice(i, 1); } } for (var j = obstacles.length - 1; j >= 0; j--) { if (obstacles[j].update()) { obstacles.splice(j, 1); } } for (var k = shadows.length - 1; k >= 0; k--) { if (shadows[k].update()) { shadows.splice(k, 1); } } // Update death particles for (var l = deathParticles.length - 1; l >= 0; l--) { var p = deathParticles[l]; p.x += p.vx; p.y += p.vy; p.vx *= 0.95; p.vy *= 0.95; p.vy += 0.5; // gravity p.alpha -= 0.02; if (p.alpha <= 0) { p.destroy(); deathParticles.splice(l, 1); } } // Check for collisions checkCollisions(); // Update score (every 10 ticks) if (LK.ticks % 10 === 0) { updateScore(); } // Update difficulty updateDifficulty(); } }; // Event handlers game.down = function (x, y, obj) { if (!gameRunning) { // Start the game gameRunning = true; tapToStartTxt.destroy(); scoreTxt.setText('Score: 0'); } else if (!player.isDead) { player.jump(); } }; var holdTimer = null; var holdStarted = false; game.up = function (x, y, obj) { if (holdTimer) { LK.clearTimeout(holdTimer); holdTimer = null; } holdStarted = false; }; game.move = function (x, y, obj) { if (gameRunning && !player.isDead && !holdStarted) { holdStarted = true; holdTimer = LK.setTimeout(function () { player.slide(); }, 200); } }; // Initialize the game initGame();
===================================================================
--- original.js
+++ change.js
@@ -112,31 +112,62 @@
var cube = self.attachAsset('player', {
anchorX: 0.5,
anchorY: 0.5
});
- cube.rotation = 0; // Initialize rotation
+ // Set initial rotation and rotation speed
+ self.rotationSpeed = 0.05;
+ self.currentRotation = 0;
// Particle system for the player's trail
self.particles = [];
// Player controls
self.jump = function () {
if (!self.isJumping && !self.isDead) {
self.velocity.y = self.jumpForce;
self.isJumping = true;
+ // Increase rotation speed temporarily when jumping
+ tween(self, {
+ rotationSpeed: 0.15
+ }, {
+ duration: 300,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ tween(self, {
+ rotationSpeed: 0.05
+ }, {
+ duration: 500,
+ easing: tween.easeIn
+ });
+ }
+ });
LK.getSound('jump').play();
}
};
self.slide = function () {
if (!self.isSliding && !self.isJumping && !self.isDead) {
self.isSliding = true;
cube.scaleY = 0.5;
cube.y = 25;
+ // Increase rotation speed during slide
+ tween(self, {
+ rotationSpeed: 0.2
+ }, {
+ duration: 200,
+ easing: tween.easeOut
+ });
LK.getSound('slide').play();
// Cancel slide after a duration
LK.setTimeout(function () {
if (self.isSliding) {
self.isSliding = false;
cube.scaleY = 1;
cube.y = 0;
+ // Return to normal rotation speed
+ tween(self, {
+ rotationSpeed: 0.05
+ }, {
+ duration: 300,
+ easing: tween.easeIn
+ });
}
}, 800);
}
};
@@ -153,8 +184,14 @@
};
self.die = function () {
if (!self.isDead) {
self.isDead = true;
+ // Stop rotation by tweening to zero
+ tween(self, {
+ rotationSpeed: 0
+ }, {
+ duration: 100
+ });
LK.getSound('death').play();
LK.effects.flashScreen(0xff0000, 500);
// Create death particles
for (var i = 0; i < 20; i++) {
@@ -191,8 +228,13 @@
self.y = self.groundY;
self.velocity.y = 0;
self.isJumping = false;
}
+ // Update cube rotation when moving
+ if (gameRunning && !self.isDead) {
+ self.currentRotation += self.rotationSpeed;
+ cube.rotation = self.currentRotation;
+ }
// Create trail particles
if (gameRunning && LK.ticks % 5 === 0) {
var particle = LK.getAsset('particle', {
anchorX: 0.5,
@@ -201,9 +243,8 @@
y: self.y + (self.isSliding ? 25 : 0)
});
particle.alpha = 0.7;
particle.life = 30;
- particle.rotation = cube.rotation; // Match the cube's rotation
game.addChild(particle);
self.particles.push(particle);
}
// Update particles
@@ -211,20 +252,14 @@
var p = self.particles[i];
p.alpha -= 0.02;
p.scaleX -= 0.02;
p.scaleY -= 0.02;
- p.rotation += 0.01; // Continue rotating like the cube
p.life--;
if (p.life <= 0 || p.alpha <= 0) {
p.destroy();
self.particles.splice(i, 1);
}
}
- // Slowly rotate the cube while moving
- if (gameRunning && !self.isDead) {
- var rotationSpeed = 0.01; // Adjust this value to change rotation speed
- cube.rotation += rotationSpeed;
- }
};
return self;
});
var Shadow = Container.expand(function () {
square re cube with 2 eyes and spike teeths inside In-Game asset. 2d. High contrast. No shadows
square white cube with 2 eyes and spike smily teeths inside In-Game asset. 2d. High contrast. No shadows
square yellowgreen cube with 2 eyes and smily face inside In-Game asset. 2d. High contrast. No shadows
background image for sqube darkness game. In-Game asset. 2d. High contrast. No shadows