User prompt
The game should slow down a bit when the player gets the star assets
User prompt
add a new asset and it becomes a superpower
User prompt
add superpower to an asset other than coin
User prompt
Special powers like coins will appear at random times so that you don't get stuck in obstacles when you get them.
User prompt
Every time you reach 20 coins, a super power potion that helps you avoid obstacles will appear in a random place.
User prompt
Coins will randomly give you between 1 and 5 coins
User prompt
add coin counter top right
User prompt
Right and left movements can be made from anywhere on the screen
User prompt
coins should not go over obstacles
User prompt
slower at the beginning, faster as the score increases
Code edit (1 edits merged)
Please save this source code
User prompt
Ice Run
Initial prompt
make ice run game
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
// Coin class: collectible
var Coin = Container.expand(function () {
var self = Container.call(this);
var coinAsset = self.attachAsset('coin', {
anchorX: 0.5,
anchorY: 0.5
});
self.width = coinAsset.width;
self.height = coinAsset.height;
self.lane = 1; // will be set on spawn
self.speed = 16; // will be set by game for difficulty
self.update = function () {
self.y += self.speed;
// Optional: spin effect
self.rotation += 0.15;
};
return self;
});
// Obstacle class: cracks, snow piles, ice blocks
var Obstacle = Container.expand(function () {
var self = Container.call(this);
// Randomly pick obstacle type
var type = Math.floor(Math.random() * 3); // 0: crack, 1: snow, 2: block
var assetId = type === 0 ? 'crack' : type === 1 ? 'snow' : 'block';
var obstacleAsset = self.attachAsset(assetId, {
anchorX: 0.5,
anchorY: 0.5
});
self.type = assetId;
self.width = obstacleAsset.width;
self.height = obstacleAsset.height;
self.lane = 1; // will be set on spawn
self.speed = 16; // will be set by game for difficulty
self.update = function () {
self.y += self.speed;
};
return self;
});
// Player class: the sliding character
var Player = Container.expand(function () {
var self = Container.call(this);
// Attach player asset (blue ellipse for ice runner)
var playerAsset = self.attachAsset('player', {
anchorX: 0.5,
anchorY: 0.5
});
// Set up initial properties
self.width = playerAsset.width;
self.height = playerAsset.height;
self.lane = 1; // 0: left, 1: center, 2: right
// For smooth lane transitions
self.targetX = 0;
// Update method: smoothly move to targetX
self.update = function () {
// Smoothly move towards targetX
self.x += (self.targetX - self.x) * 0.25;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x99d6f9 // Light blue for icy background
});
/****
* Game Code
****/
// Tween plugin for smooth movement and animations
// --- Lane setup ---
var laneCount = 3;
var laneWidth = 400; // Each lane is 400px wide
var laneCenters = [2048 / 2 - laneWidth,
// left
2048 / 2,
// center
2048 / 2 + laneWidth // right
];
// --- Player setup ---
var player = new Player();
player.y = 2732 - 400; // Near bottom
player.lane = 1;
player.x = laneCenters[player.lane];
player.targetX = player.x;
game.addChild(player);
// --- Score and GUI ---
var score = 0;
var scoreTxt = new Text2('0', {
size: 120,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// --- Coin counter ---
var coinCount = 0;
var coinTxt = new Text2('0', {
size: 90,
fill: 0xFFE066
});
coinTxt.anchor.set(0.5, 0);
LK.gui.topRight.addChild(coinTxt);
// --- Game state ---
var obstacles = [];
var coins = [];
var gameSpeed = 16; // Initial speed
var ticksSinceLastObstacle = 0;
var ticksSinceLastCoin = 0;
var obstacleInterval = 60; // Frames between obstacles
var coinInterval = 90; // Frames between coins
var isDragging = false;
var dragStartX = 0;
var dragStartLane = 1;
// --- Asset initialization (shapes) ---
// --- Touch/drag controls ---
game.down = function (x, y, obj) {
// Only start drag if touch is on/near player
var dx = x - player.x;
var dy = y - player.y;
var dist = Math.sqrt(dx * dx + dy * dy);
if (dist < 200) {
isDragging = true;
dragStartX = x;
dragStartLane = player.lane;
}
};
game.move = function (x, y, obj) {
if (!isDragging) return;
// Calculate drag offset
var dx = x - dragStartX;
// If drag exceeds half lane width, move lane
var laneDelta = 0;
if (dx > laneWidth / 2) laneDelta = 1;
if (dx < -laneWidth / 2) laneDelta = -1;
var newLane = dragStartLane + laneDelta;
if (newLane < 0) newLane = 0;
if (newLane > 2) newLane = 2;
if (newLane !== player.lane) {
player.lane = newLane;
player.targetX = laneCenters[player.lane];
}
};
game.up = function (x, y, obj) {
isDragging = false;
};
// --- Main game update loop ---
game.update = function () {
// Increase difficulty over time
if (LK.ticks % 180 === 0 && gameSpeed < 40) {
gameSpeed += 1;
if (obstacleInterval > 30) obstacleInterval -= 2;
if (coinInterval > 50) coinInterval -= 2;
}
// Player update (smooth lane movement)
player.update();
// --- Spawn obstacles ---
ticksSinceLastObstacle++;
if (ticksSinceLastObstacle >= obstacleInterval) {
ticksSinceLastObstacle = 0;
var obs = new Obstacle();
obs.lane = Math.floor(Math.random() * laneCount);
obs.x = laneCenters[obs.lane];
obs.y = -120;
obs.speed = gameSpeed;
obstacles.push(obs);
game.addChild(obs);
}
// --- Spawn coins ---
ticksSinceLastCoin++;
if (ticksSinceLastCoin >= coinInterval) {
ticksSinceLastCoin = 0;
var coin = new Coin();
coin.lane = Math.floor(Math.random() * laneCount);
coin.x = laneCenters[coin.lane];
coin.y = -100;
coin.speed = gameSpeed;
coins.push(coin);
game.addChild(coin);
}
// --- Update obstacles ---
for (var i = obstacles.length - 1; i >= 0; i--) {
var obs = obstacles[i];
obs.update();
// Remove if off screen
if (obs.y > 2732 + 200) {
obs.destroy();
obstacles.splice(i, 1);
continue;
}
// Collision with player
if (obs.lane === player.lane) {
var dy = Math.abs(obs.y - player.y);
if (dy < obs.height / 2 + player.height / 2 - 30) {
// Game over
LK.effects.flashScreen(0xff0000, 800);
LK.showGameOver();
return;
}
}
}
// --- Update coins ---
for (var j = coins.length - 1; j >= 0; j--) {
var coin = coins[j];
coin.update();
// Remove if off screen
if (coin.y > 2732 + 120) {
coin.destroy();
coins.splice(j, 1);
continue;
}
// Collect coin
if (coin.lane === player.lane) {
var dy = Math.abs(coin.y - player.y);
if (dy < coin.height / 2 + player.height / 2 - 40) {
coinCount += 1;
coinTxt.setText(coinCount);
coin.destroy();
coins.splice(j, 1);
continue;
}
}
}
// --- Score increases with time survived ---
if (LK.ticks % 6 === 0) {
score += 1;
scoreTxt.setText(score);
}
}; ===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,237 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+
+/****
+* Classes
+****/
+// Coin class: collectible
+var Coin = Container.expand(function () {
+ var self = Container.call(this);
+ var coinAsset = self.attachAsset('coin', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.width = coinAsset.width;
+ self.height = coinAsset.height;
+ self.lane = 1; // will be set on spawn
+ self.speed = 16; // will be set by game for difficulty
+ self.update = function () {
+ self.y += self.speed;
+ // Optional: spin effect
+ self.rotation += 0.15;
+ };
+ return self;
+});
+// Obstacle class: cracks, snow piles, ice blocks
+var Obstacle = Container.expand(function () {
+ var self = Container.call(this);
+ // Randomly pick obstacle type
+ var type = Math.floor(Math.random() * 3); // 0: crack, 1: snow, 2: block
+ var assetId = type === 0 ? 'crack' : type === 1 ? 'snow' : 'block';
+ var obstacleAsset = self.attachAsset(assetId, {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.type = assetId;
+ self.width = obstacleAsset.width;
+ self.height = obstacleAsset.height;
+ self.lane = 1; // will be set on spawn
+ self.speed = 16; // will be set by game for difficulty
+ self.update = function () {
+ self.y += self.speed;
+ };
+ return self;
+});
+// Player class: the sliding character
+var Player = Container.expand(function () {
+ var self = Container.call(this);
+ // Attach player asset (blue ellipse for ice runner)
+ var playerAsset = self.attachAsset('player', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ // Set up initial properties
+ self.width = playerAsset.width;
+ self.height = playerAsset.height;
+ self.lane = 1; // 0: left, 1: center, 2: right
+ // For smooth lane transitions
+ self.targetX = 0;
+ // Update method: smoothly move to targetX
+ self.update = function () {
+ // Smoothly move towards targetX
+ self.x += (self.targetX - self.x) * 0.25;
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x99d6f9 // Light blue for icy background
+});
+
+/****
+* Game Code
+****/
+// Tween plugin for smooth movement and animations
+// --- Lane setup ---
+var laneCount = 3;
+var laneWidth = 400; // Each lane is 400px wide
+var laneCenters = [2048 / 2 - laneWidth,
+// left
+2048 / 2,
+// center
+2048 / 2 + laneWidth // right
+];
+// --- Player setup ---
+var player = new Player();
+player.y = 2732 - 400; // Near bottom
+player.lane = 1;
+player.x = laneCenters[player.lane];
+player.targetX = player.x;
+game.addChild(player);
+// --- Score and GUI ---
+var score = 0;
+var scoreTxt = new Text2('0', {
+ size: 120,
+ fill: 0xFFFFFF
+});
+scoreTxt.anchor.set(0.5, 0);
+LK.gui.top.addChild(scoreTxt);
+// --- Coin counter ---
+var coinCount = 0;
+var coinTxt = new Text2('0', {
+ size: 90,
+ fill: 0xFFE066
+});
+coinTxt.anchor.set(0.5, 0);
+LK.gui.topRight.addChild(coinTxt);
+// --- Game state ---
+var obstacles = [];
+var coins = [];
+var gameSpeed = 16; // Initial speed
+var ticksSinceLastObstacle = 0;
+var ticksSinceLastCoin = 0;
+var obstacleInterval = 60; // Frames between obstacles
+var coinInterval = 90; // Frames between coins
+var isDragging = false;
+var dragStartX = 0;
+var dragStartLane = 1;
+// --- Asset initialization (shapes) ---
+// --- Touch/drag controls ---
+game.down = function (x, y, obj) {
+ // Only start drag if touch is on/near player
+ var dx = x - player.x;
+ var dy = y - player.y;
+ var dist = Math.sqrt(dx * dx + dy * dy);
+ if (dist < 200) {
+ isDragging = true;
+ dragStartX = x;
+ dragStartLane = player.lane;
+ }
+};
+game.move = function (x, y, obj) {
+ if (!isDragging) return;
+ // Calculate drag offset
+ var dx = x - dragStartX;
+ // If drag exceeds half lane width, move lane
+ var laneDelta = 0;
+ if (dx > laneWidth / 2) laneDelta = 1;
+ if (dx < -laneWidth / 2) laneDelta = -1;
+ var newLane = dragStartLane + laneDelta;
+ if (newLane < 0) newLane = 0;
+ if (newLane > 2) newLane = 2;
+ if (newLane !== player.lane) {
+ player.lane = newLane;
+ player.targetX = laneCenters[player.lane];
+ }
+};
+game.up = function (x, y, obj) {
+ isDragging = false;
+};
+// --- Main game update loop ---
+game.update = function () {
+ // Increase difficulty over time
+ if (LK.ticks % 180 === 0 && gameSpeed < 40) {
+ gameSpeed += 1;
+ if (obstacleInterval > 30) obstacleInterval -= 2;
+ if (coinInterval > 50) coinInterval -= 2;
+ }
+ // Player update (smooth lane movement)
+ player.update();
+ // --- Spawn obstacles ---
+ ticksSinceLastObstacle++;
+ if (ticksSinceLastObstacle >= obstacleInterval) {
+ ticksSinceLastObstacle = 0;
+ var obs = new Obstacle();
+ obs.lane = Math.floor(Math.random() * laneCount);
+ obs.x = laneCenters[obs.lane];
+ obs.y = -120;
+ obs.speed = gameSpeed;
+ obstacles.push(obs);
+ game.addChild(obs);
+ }
+ // --- Spawn coins ---
+ ticksSinceLastCoin++;
+ if (ticksSinceLastCoin >= coinInterval) {
+ ticksSinceLastCoin = 0;
+ var coin = new Coin();
+ coin.lane = Math.floor(Math.random() * laneCount);
+ coin.x = laneCenters[coin.lane];
+ coin.y = -100;
+ coin.speed = gameSpeed;
+ coins.push(coin);
+ game.addChild(coin);
+ }
+ // --- Update obstacles ---
+ for (var i = obstacles.length - 1; i >= 0; i--) {
+ var obs = obstacles[i];
+ obs.update();
+ // Remove if off screen
+ if (obs.y > 2732 + 200) {
+ obs.destroy();
+ obstacles.splice(i, 1);
+ continue;
+ }
+ // Collision with player
+ if (obs.lane === player.lane) {
+ var dy = Math.abs(obs.y - player.y);
+ if (dy < obs.height / 2 + player.height / 2 - 30) {
+ // Game over
+ LK.effects.flashScreen(0xff0000, 800);
+ LK.showGameOver();
+ return;
+ }
+ }
+ }
+ // --- Update coins ---
+ for (var j = coins.length - 1; j >= 0; j--) {
+ var coin = coins[j];
+ coin.update();
+ // Remove if off screen
+ if (coin.y > 2732 + 120) {
+ coin.destroy();
+ coins.splice(j, 1);
+ continue;
+ }
+ // Collect coin
+ if (coin.lane === player.lane) {
+ var dy = Math.abs(coin.y - player.y);
+ if (dy < coin.height / 2 + player.height / 2 - 40) {
+ coinCount += 1;
+ coinTxt.setText(coinCount);
+ coin.destroy();
+ coins.splice(j, 1);
+ continue;
+ }
+ }
+ }
+ // --- Score increases with time survived ---
+ if (LK.ticks % 6 === 0) {
+ score += 1;
+ scoreTxt.setText(score);
+ }
+};
\ No newline at end of file
Pixel 2d coin. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
2d pixel snow. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
2d pixel ice block. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
2d pixel crack. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
2d pixel potion. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
Let it be turned back
2d pixel dried tree. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
2d pixel rock. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
Let it be in a way that can repeat itself when it moves