User prompt
stars should blink ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
give humans motion ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
make them snail and shell bigger by x2, humans should be bigger by x5. human appear separately and randomly and make them 3 different asset.
User prompt
make them more upper
User prompt
snail shell and humans, put them upper to ground.
User prompt
hiding in the shell last for 3 secs, no more
Code edit (1 edits merged)
Please save this source code
User prompt
Snail & Moonlight
Initial prompt
Create a 2D infinite side-scrolling mobile game called **“Snail & Moonlight”**. Concept: - The player controls a small snail that slowly crawls forward. - The camera follows the snail in a continuous rightward scroll. - The game is endless — the player survives as long as possible. Controls: - Tap and hold = the snail hides inside its shell (for protection). - Release = the snail comes out and keeps crawling. Main Gameplay: - The snail moves forward automatically. - Humans appear occasionally, walking or standing in the snail’s path. - If the snail is NOT hidden in its shell when it touches a human, the game ends. - If the snail is hidden, it is safe and the human passes over without harm. Dream Mechanic: - At random intervals, a soft beam of moonlight appears from the sky. - If the snail touches the moonlight (regardless of being hidden or not), the screen transitions into a special “dream mode”. Dream Mode: - Calm, floating environment with soft music and surreal visuals. - The snail floats automatically in a vertical scrolling dream world. - The player can collect glowing orbs for bonus points. - No enemies or threats — just a relaxing bonus section. - After 15 seconds, the snail returns to the normal nighttime road. Visual Style: - Nighttime setting: glowing grass, fireflies, stars. - Calm and minimal audio, with a soft change in mood when entering dreams. - Dream mode has pastel colors, bubbles, or floating objects. Game Loop: - Infinite scroll + random obstacles (humans) - Tap to hide mechanic - Periodic moonlight triggers alternate gameplay mode - High score based on distance and dream orb collection Requirements: - Mobile-friendly - Single-touch control only - Auto-movement and camera follow - Seamless transition between real world and dream world
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var DreamOrb = Container.expand(function () {
var self = Container.call(this);
var orbGraphics = self.attachAsset('dreamOrb', {
anchorX: 0.5,
anchorY: 0.5
});
self.collected = false;
self.update = function () {
// Gentle floating animation
self.y += Math.sin(LK.ticks * 0.05 + self.x * 0.01) * 0.3;
orbGraphics.rotation += 0.02;
// Glow effect
orbGraphics.alpha = 0.7 + Math.sin(LK.ticks * 0.1) * 0.3;
};
return self;
});
var Human = Container.expand(function () {
var self = Container.call(this);
var humanGraphics = self.attachAsset('human', {
anchorX: 0.5,
anchorY: 1
});
self.speed = 1;
self.update = function () {
if (!isDreamMode) {
self.x -= scrollSpeed;
}
};
return self;
});
var Snail = Container.expand(function () {
var self = Container.call(this);
var snailBody = self.attachAsset('snail', {
anchorX: 0.5,
anchorY: 1
});
var shell = self.attachAsset('shell', {
anchorX: 0.5,
anchorY: 1,
alpha: 0
});
self.isHidden = false;
self.speed = 2;
self.hide = function () {
if (!self.isHidden) {
self.isHidden = true;
snailBody.alpha = 0;
shell.alpha = 1;
LK.getSound('hide').play();
}
};
self.emerge = function () {
if (self.isHidden) {
self.isHidden = false;
snailBody.alpha = 1;
shell.alpha = 0;
}
};
self.update = function () {
if (!isDreamMode && !self.isHidden) {
self.x += self.speed;
distance += self.speed;
}
// Float up and down in dream mode
if (isDreamMode) {
self.y += Math.sin(LK.ticks * 0.1) * 0.5;
}
};
return self;
});
var Star = Container.expand(function () {
var self = Container.call(this);
var starGraphics = self.attachAsset('star', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
if (!isDreamMode) {
self.x -= scrollSpeed * 0.1; // Parallax effect
}
starGraphics.alpha = 0.5 + Math.sin(LK.ticks * 0.05 + self.x * 0.01) * 0.5;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x191970
});
/****
* Game Code
****/
var snail;
var humans = [];
var dreamOrbs = [];
var stars = [];
var ground;
var scrollSpeed = 2;
var distance = 0;
var isDreamMode = false;
var dreamModeTimer = 0;
var dreamModeMaxTime = 900; // 15 seconds at 60fps
var moonbeamTimer = 0;
var moonbeam = null;
var isPressed = false;
// UI
var scoreText = new Text2('0', {
size: 60,
fill: 0xFFFFFF
});
scoreText.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreText);
var distanceText = new Text2('Distance: 0m', {
size: 40,
fill: 0xFFFFFF
});
distanceText.anchor.set(0, 0);
distanceText.x = 20;
distanceText.y = 100;
LK.gui.topLeft.addChild(distanceText);
// Create ground
ground = game.addChild(LK.getAsset('ground', {
anchorX: 0,
anchorY: 1,
x: 0,
y: 2732
}));
// Create snail
snail = game.addChild(new Snail());
snail.x = 300;
snail.y = 2732 - 100;
// Create initial stars
for (var i = 0; i < 30; i++) {
var star = game.addChild(new Star());
star.x = Math.random() * 4096;
star.y = Math.random() * 1500;
stars.push(star);
}
function spawnHuman() {
var human = game.addChild(new Human());
human.x = 2048 + 100;
human.y = 2732 - 100;
humans.push(human);
}
function spawnDreamOrb() {
var orb = game.addChild(new DreamOrb());
orb.x = Math.random() * 1800 + 124;
orb.y = Math.random() * 2000 + 200;
dreamOrbs.push(orb);
}
function enterDreamMode() {
if (!isDreamMode) {
isDreamMode = true;
dreamModeTimer = 0;
// Change background color
tween(game, {
backgroundColor: 0x4B0082
}, {
duration: 1000
});
// Create moonbeam
moonbeam = game.addChild(LK.getAsset('moonbeam', {
anchorX: 0.5,
anchorY: 0,
x: snail.x,
y: 0,
alpha: 0.3
}));
// Spawn dream orbs
for (var i = 0; i < 8; i++) {
spawnDreamOrb();
}
}
}
function exitDreamMode() {
if (isDreamMode) {
isDreamMode = false;
// Change background back
tween(game, {
backgroundColor: 0x191970
}, {
duration: 1000
});
// Remove moonbeam
if (moonbeam) {
moonbeam.destroy();
moonbeam = null;
}
// Remove remaining dream orbs
for (var i = dreamOrbs.length - 1; i >= 0; i--) {
dreamOrbs[i].destroy();
dreamOrbs.splice(i, 1);
}
}
}
game.down = function (x, y, obj) {
isPressed = true;
snail.hide();
};
game.up = function (x, y, obj) {
isPressed = false;
snail.emerge();
};
game.update = function () {
// Update score display
var currentScore = LK.getScore();
scoreText.setText(currentScore.toString());
distanceText.setText('Distance: ' + Math.floor(distance / 50) + 'm');
// Check for moonlight beam trigger (random chance)
if (!isDreamMode && LK.ticks % 60 === 0 && Math.random() < 0.005) {
enterDreamMode();
}
// Handle dream mode
if (isDreamMode) {
dreamModeTimer++;
if (dreamModeTimer >= dreamModeMaxTime) {
exitDreamMode();
}
}
// Spawn humans randomly
if (!isDreamMode && LK.ticks % 180 === 0 && Math.random() < 0.7) {
spawnHuman();
}
// Update and check humans
for (var i = humans.length - 1; i >= 0; i--) {
var human = humans[i];
// Check collision with snail
if (!snail.isHidden && snail.intersects(human)) {
LK.showGameOver();
return;
}
// Remove off-screen humans
if (human.x < -100) {
human.destroy();
humans.splice(i, 1);
}
}
// Update and check dream orbs
for (var i = dreamOrbs.length - 1; i >= 0; i--) {
var orb = dreamOrbs[i];
if (!orb.collected && snail.intersects(orb)) {
orb.collected = true;
LK.setScore(LK.getScore() + 10);
LK.getSound('collect').play();
// Visual effect
tween(orb, {
alpha: 0,
scaleX: 2,
scaleY: 2
}, {
duration: 300,
onFinish: function onFinish() {
orb.destroy();
}
});
dreamOrbs.splice(i, 1);
}
}
// Update stars - add new ones as we scroll
if (LK.ticks % 300 === 0) {
var star = game.addChild(new Star());
star.x = 2200;
star.y = Math.random() * 1500;
stars.push(star);
}
// Remove off-screen stars
for (var i = stars.length - 1; i >= 0; i--) {
if (stars[i].x < -100) {
stars[i].destroy();
stars.splice(i, 1);
}
}
// Add distance points
if (!isDreamMode) {
LK.setScore(LK.getScore() + 1);
}
};
// Start background music
LK.playMusic('ambient'); ===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,290 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+
+/****
+* Classes
+****/
+var DreamOrb = Container.expand(function () {
+ var self = Container.call(this);
+ var orbGraphics = self.attachAsset('dreamOrb', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.collected = false;
+ self.update = function () {
+ // Gentle floating animation
+ self.y += Math.sin(LK.ticks * 0.05 + self.x * 0.01) * 0.3;
+ orbGraphics.rotation += 0.02;
+ // Glow effect
+ orbGraphics.alpha = 0.7 + Math.sin(LK.ticks * 0.1) * 0.3;
+ };
+ return self;
+});
+var Human = Container.expand(function () {
+ var self = Container.call(this);
+ var humanGraphics = self.attachAsset('human', {
+ anchorX: 0.5,
+ anchorY: 1
+ });
+ self.speed = 1;
+ self.update = function () {
+ if (!isDreamMode) {
+ self.x -= scrollSpeed;
+ }
+ };
+ return self;
+});
+var Snail = Container.expand(function () {
+ var self = Container.call(this);
+ var snailBody = self.attachAsset('snail', {
+ anchorX: 0.5,
+ anchorY: 1
+ });
+ var shell = self.attachAsset('shell', {
+ anchorX: 0.5,
+ anchorY: 1,
+ alpha: 0
+ });
+ self.isHidden = false;
+ self.speed = 2;
+ self.hide = function () {
+ if (!self.isHidden) {
+ self.isHidden = true;
+ snailBody.alpha = 0;
+ shell.alpha = 1;
+ LK.getSound('hide').play();
+ }
+ };
+ self.emerge = function () {
+ if (self.isHidden) {
+ self.isHidden = false;
+ snailBody.alpha = 1;
+ shell.alpha = 0;
+ }
+ };
+ self.update = function () {
+ if (!isDreamMode && !self.isHidden) {
+ self.x += self.speed;
+ distance += self.speed;
+ }
+ // Float up and down in dream mode
+ if (isDreamMode) {
+ self.y += Math.sin(LK.ticks * 0.1) * 0.5;
+ }
+ };
+ return self;
+});
+var Star = Container.expand(function () {
+ var self = Container.call(this);
+ var starGraphics = self.attachAsset('star', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.update = function () {
+ if (!isDreamMode) {
+ self.x -= scrollSpeed * 0.1; // Parallax effect
+ }
+ starGraphics.alpha = 0.5 + Math.sin(LK.ticks * 0.05 + self.x * 0.01) * 0.5;
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x191970
+});
+
+/****
+* Game Code
+****/
+var snail;
+var humans = [];
+var dreamOrbs = [];
+var stars = [];
+var ground;
+var scrollSpeed = 2;
+var distance = 0;
+var isDreamMode = false;
+var dreamModeTimer = 0;
+var dreamModeMaxTime = 900; // 15 seconds at 60fps
+var moonbeamTimer = 0;
+var moonbeam = null;
+var isPressed = false;
+// UI
+var scoreText = new Text2('0', {
+ size: 60,
+ fill: 0xFFFFFF
+});
+scoreText.anchor.set(0.5, 0);
+LK.gui.top.addChild(scoreText);
+var distanceText = new Text2('Distance: 0m', {
+ size: 40,
+ fill: 0xFFFFFF
+});
+distanceText.anchor.set(0, 0);
+distanceText.x = 20;
+distanceText.y = 100;
+LK.gui.topLeft.addChild(distanceText);
+// Create ground
+ground = game.addChild(LK.getAsset('ground', {
+ anchorX: 0,
+ anchorY: 1,
+ x: 0,
+ y: 2732
+}));
+// Create snail
+snail = game.addChild(new Snail());
+snail.x = 300;
+snail.y = 2732 - 100;
+// Create initial stars
+for (var i = 0; i < 30; i++) {
+ var star = game.addChild(new Star());
+ star.x = Math.random() * 4096;
+ star.y = Math.random() * 1500;
+ stars.push(star);
+}
+function spawnHuman() {
+ var human = game.addChild(new Human());
+ human.x = 2048 + 100;
+ human.y = 2732 - 100;
+ humans.push(human);
+}
+function spawnDreamOrb() {
+ var orb = game.addChild(new DreamOrb());
+ orb.x = Math.random() * 1800 + 124;
+ orb.y = Math.random() * 2000 + 200;
+ dreamOrbs.push(orb);
+}
+function enterDreamMode() {
+ if (!isDreamMode) {
+ isDreamMode = true;
+ dreamModeTimer = 0;
+ // Change background color
+ tween(game, {
+ backgroundColor: 0x4B0082
+ }, {
+ duration: 1000
+ });
+ // Create moonbeam
+ moonbeam = game.addChild(LK.getAsset('moonbeam', {
+ anchorX: 0.5,
+ anchorY: 0,
+ x: snail.x,
+ y: 0,
+ alpha: 0.3
+ }));
+ // Spawn dream orbs
+ for (var i = 0; i < 8; i++) {
+ spawnDreamOrb();
+ }
+ }
+}
+function exitDreamMode() {
+ if (isDreamMode) {
+ isDreamMode = false;
+ // Change background back
+ tween(game, {
+ backgroundColor: 0x191970
+ }, {
+ duration: 1000
+ });
+ // Remove moonbeam
+ if (moonbeam) {
+ moonbeam.destroy();
+ moonbeam = null;
+ }
+ // Remove remaining dream orbs
+ for (var i = dreamOrbs.length - 1; i >= 0; i--) {
+ dreamOrbs[i].destroy();
+ dreamOrbs.splice(i, 1);
+ }
+ }
+}
+game.down = function (x, y, obj) {
+ isPressed = true;
+ snail.hide();
+};
+game.up = function (x, y, obj) {
+ isPressed = false;
+ snail.emerge();
+};
+game.update = function () {
+ // Update score display
+ var currentScore = LK.getScore();
+ scoreText.setText(currentScore.toString());
+ distanceText.setText('Distance: ' + Math.floor(distance / 50) + 'm');
+ // Check for moonlight beam trigger (random chance)
+ if (!isDreamMode && LK.ticks % 60 === 0 && Math.random() < 0.005) {
+ enterDreamMode();
+ }
+ // Handle dream mode
+ if (isDreamMode) {
+ dreamModeTimer++;
+ if (dreamModeTimer >= dreamModeMaxTime) {
+ exitDreamMode();
+ }
+ }
+ // Spawn humans randomly
+ if (!isDreamMode && LK.ticks % 180 === 0 && Math.random() < 0.7) {
+ spawnHuman();
+ }
+ // Update and check humans
+ for (var i = humans.length - 1; i >= 0; i--) {
+ var human = humans[i];
+ // Check collision with snail
+ if (!snail.isHidden && snail.intersects(human)) {
+ LK.showGameOver();
+ return;
+ }
+ // Remove off-screen humans
+ if (human.x < -100) {
+ human.destroy();
+ humans.splice(i, 1);
+ }
+ }
+ // Update and check dream orbs
+ for (var i = dreamOrbs.length - 1; i >= 0; i--) {
+ var orb = dreamOrbs[i];
+ if (!orb.collected && snail.intersects(orb)) {
+ orb.collected = true;
+ LK.setScore(LK.getScore() + 10);
+ LK.getSound('collect').play();
+ // Visual effect
+ tween(orb, {
+ alpha: 0,
+ scaleX: 2,
+ scaleY: 2
+ }, {
+ duration: 300,
+ onFinish: function onFinish() {
+ orb.destroy();
+ }
+ });
+ dreamOrbs.splice(i, 1);
+ }
+ }
+ // Update stars - add new ones as we scroll
+ if (LK.ticks % 300 === 0) {
+ var star = game.addChild(new Star());
+ star.x = 2200;
+ star.y = Math.random() * 1500;
+ stars.push(star);
+ }
+ // Remove off-screen stars
+ for (var i = stars.length - 1; i >= 0; i--) {
+ if (stars[i].x < -100) {
+ stars[i].destroy();
+ stars.splice(i, 1);
+ }
+ }
+ // Add distance points
+ if (!isDreamMode) {
+ LK.setScore(LK.getScore() + 1);
+ }
+};
+// Start background music
+LK.playMusic('ambient');
\ No newline at end of file
2048x100 pixel ground layer with grass. In-Game asset. 2d. High contrast. No shadows
white shiny little star 2d pixel art. In-Game asset. 2d. High contrast. No shadows
bad regular casual middle aged man full body 2d pixel art. In-Game asset. 2d. High contrast. No shadows
bad regular casual middle aged woman full body 2d pixel art. In-Game asset. 2d. High contrast. No shadows
bad regular casual kid full body 2d pixel art. In-Game asset. 2d. High contrast. No shadows
desperate depressive cute snail 2d pixel art. In-Game asset. 2d. High contrast. No shadows
dream orb 2d pixel art. In-Game asset. 2d. High contrast. No shadows
desperate depressive cute snail is hiding in shell 2d pixel art. In-Game asset. 2d. High contrast. No shadows
bad regular frown casual old woman full body 2d pixel art. In-Game asset. 2d. High contrast. No shadows
bad regular frown casual old man full body 2d pixel art. In-Game asset. 2d. High contrast. No shadows
bad regular frown casual girl kid blonde hair braided full body 2d pixel art. In-Game asset. 2d. High contrast. No shadows