/****
* 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 () {
// All dream orbs fall downward
if (!self.fallSpeed) {
self.fallSpeed = 2 + Math.random() * 3; // Set random fall speed if not set
}
self.y += self.fallSpeed;
// Add gentle horizontal drift while falling
self.x += Math.sin(LK.ticks * 0.03) * 0.5;
orbGraphics.rotation += 0.02;
// Transparent smooth glow effect
orbGraphics.alpha = 0.6 + Math.sin(LK.ticks * 0.05) * 0.4;
orbGraphics.tint = 0xFFFFFF;
// Pulse scaling for smooth glow attraction
var pulseScale = 1 + Math.sin(LK.ticks * 0.06) * 0.2;
orbGraphics.scaleX = pulseScale;
orbGraphics.scaleY = pulseScale;
};
return self;
});
var Human = Container.expand(function () {
var self = Container.call(this);
var humanTypes = ['human1', 'human2', 'human3', 'human4', 'human5', 'human6'];
var randomType = humanTypes[Math.floor(Math.random() * humanTypes.length)];
var humanGraphics = self.attachAsset(randomType, {
anchorX: 0.5,
anchorY: 1,
scaleX: 1.8,
scaleY: 1.8
});
self.speed = 3;
self.update = function () {
// Humans move left relative to world
self.x -= self.speed;
};
// Add walking animation when human is created
self.startWalkingAnimation = function () {
// Create a subtle walking bob animation
tween(humanGraphics, {
y: humanGraphics.y - 10
}, {
duration: 800,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(humanGraphics, {
y: humanGraphics.y + 10
}, {
duration: 800,
easing: tween.easeInOut,
onFinish: function onFinish() {
if (self.parent) {
// Only continue if human still exists
self.startWalkingAnimation();
}
}
});
}
});
// Add slight horizontal sway
tween(humanGraphics, {
rotation: 0.05
}, {
duration: 1200,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(humanGraphics, {
rotation: -0.05
}, {
duration: 1200,
easing: tween.easeInOut,
onFinish: function onFinish() {
if (self.parent) {
// Only continue if human still exists
tween(humanGraphics, {
rotation: 0
}, {
duration: 600,
easing: tween.easeInOut
});
}
}
});
}
});
};
// Start the walking animation immediately
self.startWalkingAnimation();
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.walkSoundTimer = 0;
self.hide = function () {
if (!self.isHidden) {
self.isHidden = true;
snailBody.alpha = 0;
shell.alpha = 1;
hideTimer = 0; // Reset timer when hiding
LK.getSound('hide').play();
}
};
self.emerge = function () {
if (self.isHidden) {
self.isHidden = false;
snailBody.alpha = 1;
shell.alpha = 0;
hideTimer = 0; // Reset timer when emerging
}
};
// Start walking animation immediately
self.startWalkingAnimation = function () {
// Create subtle walking bob animation
tween(snailBody, {
y: snailBody.y - 8
}, {
duration: 600,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(snailBody, {
y: snailBody.y + 8
}, {
duration: 600,
easing: tween.easeInOut,
onFinish: function onFinish() {
if (self.parent) {
self.startWalkingAnimation();
}
}
});
}
});
// Add slight shell bounce
tween(shell, {
y: shell.y - 5
}, {
duration: 800,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(shell, {
y: shell.y + 5
}, {
duration: 800,
easing: tween.easeInOut,
onFinish: function onFinish() {
if (self.parent) {
// Continue shell animation
}
}
});
}
});
};
self.update = function () {
if (!self.isHidden) {
// Normal movement - snail moves right
self.x += self.speed;
distance += self.speed;
// Play walking sound effect continuously
self.walkSoundTimer++;
if (self.walkSoundTimer >= 30) {
// Play every 0.5 seconds (30 ticks at 60fps)
LK.getSound('walk').play();
self.walkSoundTimer = 0;
}
} else {
// Reset walk sound timer when hidden
self.walkSoundTimer = 0;
}
};
// Start walking animation immediately
self.startWalkingAnimation();
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 () {
// Stars don't move - they stay in world position for 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 cameraX = 0;
var worldOffset = 0;
var isPressed = false;
var hideTimer = 0;
var maxHideTime = 180; // 3 seconds at 60fps
// UI
var distanceText = new Text2('Distance: 0m', {
size: 60,
fill: 0xFFFFFF,
font: "'GillSans-Bold',Impact,'Arial Black',Tahoma"
});
distanceText.anchor.set(0.5, 0);
LK.gui.top.addChild(distanceText);
var scoreText = new Text2('Score: 0', {
size: 60,
fill: 0xFFFFFF,
font: "'GillSans-Bold',Impact,'Arial Black',Tahoma"
});
scoreText.anchor.set(0.5, 0);
scoreText.y = 80; // Position below distance text
LK.gui.top.addChild(scoreText);
// Create ground array for infinite scrolling
var grounds = [];
// Create initial ground segments - extend further to the left
for (var i = -3; i < 6; i++) {
var groundSegment = game.addChild(LK.getAsset('ground', {
anchorX: 0,
anchorY: 1,
x: i * 2048,
y: 2732
}));
grounds.push(groundSegment);
}
// Create snail
snail = game.addChild(new Snail());
snail.x = 300;
snail.y = 2732 - 500; // Moved much higher above ground
// 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 = cameraX + 2048 + Math.random() * 500; // Spawn from right side of screen
human.y = 2732 - 500; // Moved much higher above ground
humans.push(human);
}
function spawnDreamOrb() {
var orb = game.addChild(new DreamOrb());
// Spawn orbs ahead of snail in visible area
orb.x = snail.x + 800 + Math.random() * 1200; // Spawn ahead of snail
orb.y = Math.random() * 1500 + 300; // Upper portion of screen
dreamOrbs.push(orb);
}
function spawnFallingDreamOrb() {
var orb = game.addChild(new DreamOrb());
// Spawn from sky above visible area
orb.x = snail.x + (Math.random() - 0.5) * 2048; // Around snail position
orb.y = -100; // Start above screen
dreamOrbs.push(orb);
}
game.down = function (x, y, obj) {
isPressed = true;
snail.hide();
};
game.up = function (x, y, obj) {
isPressed = false;
snail.emerge();
};
game.update = function () {
// No hide timer - snail can stay hidden indefinitely
// Update distance and score displays
distanceText.setText('Distance: ' + Math.floor(distance / 50) + 'm');
scoreText.setText('Score: ' + LK.getScore());
// Spawn dream orbs periodically
if (LK.ticks % 600 === 0 && dreamOrbs.length < 2) {
// Every 10 seconds, max 2 orbs
spawnDreamOrb();
}
// Sometimes spawn falling dream orbs from sky
if (Math.random() < 0.001) {
// Small chance each frame for bonus orbs
spawnFallingDreamOrb();
}
// Spawn humans more rarely, but increase rate with distance
var spawnRate = 0.0005 + Math.floor(distance / 50) * 0.0002; // Increase spawn rate every 50 distance units
if (humans.length < 3 && Math.random() < spawnRate) {
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 (behind camera)
if (human.x < cameraX - 500) {
// Stop any running animations before destroying
tween.stop(human.children[0]); // Stop animations on the human graphics
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);
} else if (orb.x < cameraX - 500 || orb.y > 2732 + 100) {
// Remove orbs that are too far behind camera or have fallen below ground
orb.destroy();
dreamOrbs.splice(i, 1);
}
}
// Camera tracking - follow snail
var targetCameraX = snail.x - 1024; // Keep snail in left-center of screen
cameraX += (targetCameraX - cameraX) * 0.1; // Smooth camera movement
// Update all game objects position relative to camera
game.x = -cameraX;
// Infinite world generation - add new stars ahead
if (LK.ticks % 300 === 0) {
var star = game.addChild(new Star());
star.x = snail.x + 2000 + Math.random() * 1000; // Spawn ahead of snail
star.y = Math.random() * 1500;
stars.push(star);
}
// Remove off-screen stars (behind camera)
for (var i = stars.length - 1; i >= 0; i--) {
if (stars[i].x < cameraX - 500) {
stars[i].destroy();
stars.splice(i, 1);
}
}
// Infinite ground generation
var rightmostGroundX = -Infinity;
for (var i = 0; i < grounds.length; i++) {
if (grounds[i].x > rightmostGroundX) {
rightmostGroundX = grounds[i].x;
}
}
// Add new ground segments ahead of camera
while (rightmostGroundX < cameraX + 4096) {
var newGround = game.addChild(LK.getAsset('ground', {
anchorX: 0,
anchorY: 1,
x: rightmostGroundX + 2048,
y: 2732
}));
grounds.push(newGround);
rightmostGroundX += 2048;
}
// Remove ground segments behind camera
for (var i = grounds.length - 1; i >= 0; i--) {
if (grounds[i].x < cameraX - 2048) {
grounds[i].destroy();
grounds.splice(i, 1);
}
}
// Distance is tracked automatically through snail movement
};
// Start background music
LK.playMusic('ambient'); /****
* 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 () {
// All dream orbs fall downward
if (!self.fallSpeed) {
self.fallSpeed = 2 + Math.random() * 3; // Set random fall speed if not set
}
self.y += self.fallSpeed;
// Add gentle horizontal drift while falling
self.x += Math.sin(LK.ticks * 0.03) * 0.5;
orbGraphics.rotation += 0.02;
// Transparent smooth glow effect
orbGraphics.alpha = 0.6 + Math.sin(LK.ticks * 0.05) * 0.4;
orbGraphics.tint = 0xFFFFFF;
// Pulse scaling for smooth glow attraction
var pulseScale = 1 + Math.sin(LK.ticks * 0.06) * 0.2;
orbGraphics.scaleX = pulseScale;
orbGraphics.scaleY = pulseScale;
};
return self;
});
var Human = Container.expand(function () {
var self = Container.call(this);
var humanTypes = ['human1', 'human2', 'human3', 'human4', 'human5', 'human6'];
var randomType = humanTypes[Math.floor(Math.random() * humanTypes.length)];
var humanGraphics = self.attachAsset(randomType, {
anchorX: 0.5,
anchorY: 1,
scaleX: 1.8,
scaleY: 1.8
});
self.speed = 3;
self.update = function () {
// Humans move left relative to world
self.x -= self.speed;
};
// Add walking animation when human is created
self.startWalkingAnimation = function () {
// Create a subtle walking bob animation
tween(humanGraphics, {
y: humanGraphics.y - 10
}, {
duration: 800,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(humanGraphics, {
y: humanGraphics.y + 10
}, {
duration: 800,
easing: tween.easeInOut,
onFinish: function onFinish() {
if (self.parent) {
// Only continue if human still exists
self.startWalkingAnimation();
}
}
});
}
});
// Add slight horizontal sway
tween(humanGraphics, {
rotation: 0.05
}, {
duration: 1200,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(humanGraphics, {
rotation: -0.05
}, {
duration: 1200,
easing: tween.easeInOut,
onFinish: function onFinish() {
if (self.parent) {
// Only continue if human still exists
tween(humanGraphics, {
rotation: 0
}, {
duration: 600,
easing: tween.easeInOut
});
}
}
});
}
});
};
// Start the walking animation immediately
self.startWalkingAnimation();
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.walkSoundTimer = 0;
self.hide = function () {
if (!self.isHidden) {
self.isHidden = true;
snailBody.alpha = 0;
shell.alpha = 1;
hideTimer = 0; // Reset timer when hiding
LK.getSound('hide').play();
}
};
self.emerge = function () {
if (self.isHidden) {
self.isHidden = false;
snailBody.alpha = 1;
shell.alpha = 0;
hideTimer = 0; // Reset timer when emerging
}
};
// Start walking animation immediately
self.startWalkingAnimation = function () {
// Create subtle walking bob animation
tween(snailBody, {
y: snailBody.y - 8
}, {
duration: 600,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(snailBody, {
y: snailBody.y + 8
}, {
duration: 600,
easing: tween.easeInOut,
onFinish: function onFinish() {
if (self.parent) {
self.startWalkingAnimation();
}
}
});
}
});
// Add slight shell bounce
tween(shell, {
y: shell.y - 5
}, {
duration: 800,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(shell, {
y: shell.y + 5
}, {
duration: 800,
easing: tween.easeInOut,
onFinish: function onFinish() {
if (self.parent) {
// Continue shell animation
}
}
});
}
});
};
self.update = function () {
if (!self.isHidden) {
// Normal movement - snail moves right
self.x += self.speed;
distance += self.speed;
// Play walking sound effect continuously
self.walkSoundTimer++;
if (self.walkSoundTimer >= 30) {
// Play every 0.5 seconds (30 ticks at 60fps)
LK.getSound('walk').play();
self.walkSoundTimer = 0;
}
} else {
// Reset walk sound timer when hidden
self.walkSoundTimer = 0;
}
};
// Start walking animation immediately
self.startWalkingAnimation();
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 () {
// Stars don't move - they stay in world position for 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 cameraX = 0;
var worldOffset = 0;
var isPressed = false;
var hideTimer = 0;
var maxHideTime = 180; // 3 seconds at 60fps
// UI
var distanceText = new Text2('Distance: 0m', {
size: 60,
fill: 0xFFFFFF,
font: "'GillSans-Bold',Impact,'Arial Black',Tahoma"
});
distanceText.anchor.set(0.5, 0);
LK.gui.top.addChild(distanceText);
var scoreText = new Text2('Score: 0', {
size: 60,
fill: 0xFFFFFF,
font: "'GillSans-Bold',Impact,'Arial Black',Tahoma"
});
scoreText.anchor.set(0.5, 0);
scoreText.y = 80; // Position below distance text
LK.gui.top.addChild(scoreText);
// Create ground array for infinite scrolling
var grounds = [];
// Create initial ground segments - extend further to the left
for (var i = -3; i < 6; i++) {
var groundSegment = game.addChild(LK.getAsset('ground', {
anchorX: 0,
anchorY: 1,
x: i * 2048,
y: 2732
}));
grounds.push(groundSegment);
}
// Create snail
snail = game.addChild(new Snail());
snail.x = 300;
snail.y = 2732 - 500; // Moved much higher above ground
// 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 = cameraX + 2048 + Math.random() * 500; // Spawn from right side of screen
human.y = 2732 - 500; // Moved much higher above ground
humans.push(human);
}
function spawnDreamOrb() {
var orb = game.addChild(new DreamOrb());
// Spawn orbs ahead of snail in visible area
orb.x = snail.x + 800 + Math.random() * 1200; // Spawn ahead of snail
orb.y = Math.random() * 1500 + 300; // Upper portion of screen
dreamOrbs.push(orb);
}
function spawnFallingDreamOrb() {
var orb = game.addChild(new DreamOrb());
// Spawn from sky above visible area
orb.x = snail.x + (Math.random() - 0.5) * 2048; // Around snail position
orb.y = -100; // Start above screen
dreamOrbs.push(orb);
}
game.down = function (x, y, obj) {
isPressed = true;
snail.hide();
};
game.up = function (x, y, obj) {
isPressed = false;
snail.emerge();
};
game.update = function () {
// No hide timer - snail can stay hidden indefinitely
// Update distance and score displays
distanceText.setText('Distance: ' + Math.floor(distance / 50) + 'm');
scoreText.setText('Score: ' + LK.getScore());
// Spawn dream orbs periodically
if (LK.ticks % 600 === 0 && dreamOrbs.length < 2) {
// Every 10 seconds, max 2 orbs
spawnDreamOrb();
}
// Sometimes spawn falling dream orbs from sky
if (Math.random() < 0.001) {
// Small chance each frame for bonus orbs
spawnFallingDreamOrb();
}
// Spawn humans more rarely, but increase rate with distance
var spawnRate = 0.0005 + Math.floor(distance / 50) * 0.0002; // Increase spawn rate every 50 distance units
if (humans.length < 3 && Math.random() < spawnRate) {
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 (behind camera)
if (human.x < cameraX - 500) {
// Stop any running animations before destroying
tween.stop(human.children[0]); // Stop animations on the human graphics
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);
} else if (orb.x < cameraX - 500 || orb.y > 2732 + 100) {
// Remove orbs that are too far behind camera or have fallen below ground
orb.destroy();
dreamOrbs.splice(i, 1);
}
}
// Camera tracking - follow snail
var targetCameraX = snail.x - 1024; // Keep snail in left-center of screen
cameraX += (targetCameraX - cameraX) * 0.1; // Smooth camera movement
// Update all game objects position relative to camera
game.x = -cameraX;
// Infinite world generation - add new stars ahead
if (LK.ticks % 300 === 0) {
var star = game.addChild(new Star());
star.x = snail.x + 2000 + Math.random() * 1000; // Spawn ahead of snail
star.y = Math.random() * 1500;
stars.push(star);
}
// Remove off-screen stars (behind camera)
for (var i = stars.length - 1; i >= 0; i--) {
if (stars[i].x < cameraX - 500) {
stars[i].destroy();
stars.splice(i, 1);
}
}
// Infinite ground generation
var rightmostGroundX = -Infinity;
for (var i = 0; i < grounds.length; i++) {
if (grounds[i].x > rightmostGroundX) {
rightmostGroundX = grounds[i].x;
}
}
// Add new ground segments ahead of camera
while (rightmostGroundX < cameraX + 4096) {
var newGround = game.addChild(LK.getAsset('ground', {
anchorX: 0,
anchorY: 1,
x: rightmostGroundX + 2048,
y: 2732
}));
grounds.push(newGround);
rightmostGroundX += 2048;
}
// Remove ground segments behind camera
for (var i = grounds.length - 1; i >= 0; i--) {
if (grounds[i].x < cameraX - 2048) {
grounds[i].destroy();
grounds.splice(i, 1);
}
}
// Distance is tracked automatically through snail movement
};
// Start background music
LK.playMusic('ambient');
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