/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Platform = Container.expand(function (type) {
var self = Container.call(this);
self.type = type || 'regular';
self.broken = false;
var assetName = 'platform';
if (self.type === 'moving') assetName = 'movingPlatform';else if (self.type === 'breakable') assetName = 'breakablePlatform';else if (self.type === 'spring') assetName = 'springPlatform';
var platformGraphics = self.attachAsset(assetName, {
anchorX: 0.5,
anchorY: 0.5
});
self.direction = Math.random() > 0.5 ? 1 : -1;
self.speed = 2;
self.update = function () {
if (self.type === 'moving' && !self.broken) {
self.x += self.direction * self.speed;
if (self.x < 100 || self.x > 1948) {
self.direction *= -1;
}
}
};
self.onPlayerLand = function () {
if (self.type === 'breakable' && !self.broken) {
self.broken = true;
tween(self, {
alpha: 0
}, {
duration: 200
});
LK.getSound('break').play();
} else if (self.type === 'spring') {
player.springJump();
tween(self, {
scaleY: 0.5
}, {
duration: 100,
onFinish: function onFinish() {
tween(self, {
scaleY: 1
}, {
duration: 100
});
}
});
}
};
return self;
});
var Player = Container.expand(function () {
var self = Container.call(this);
var playerGraphics = self.attachAsset('player', {
anchorX: 0.5,
anchorY: 0.5
});
self.velocityY = 0;
self.gravity = 0.8;
self.jumpStrength = -26;
self.horizontalSpeed = 8;
self.isJumping = true;
self.update = function () {
// Apply gravity
self.velocityY += self.gravity;
self.y += self.velocityY;
// Horizontal movement boundaries
if (self.x < 40) self.x = 40;
if (self.x > 2008) self.x = 2008;
// Check platform collisions only when falling
if (self.velocityY > 0) {
for (var i = 0; i < platforms.length; i++) {
var platform = platforms[i];
if (self.intersects(platform) && self.y < platform.y) {
self.jump();
platform.onPlayerLand();
break;
}
}
}
};
self.jump = function () {
self.velocityY = self.jumpStrength;
self.isJumping = true;
LK.getSound('jump').play();
};
self.springJump = function () {
self.velocityY = self.jumpStrength * 1.5;
self.isJumping = true;
LK.getSound('spring').play();
};
return self;
});
var RisingBall = Container.expand(function (hasCage) {
var self = Container.call(this);
self.hasCage = hasCage || false;
self.riseSpeed = 0.45;
if (self.hasCage) {
var cage = self.attachAsset('ballCage', {
anchorX: 0.5,
anchorY: 0.5
});
cage.alpha = 0.7;
var ball = self.attachAsset('character', {
anchorX: 0.5,
anchorY: 0.5
});
ball.alpha = 0.8;
} else {
var ball = self.attachAsset('risingBall', {
anchorX: 0.5,
anchorY: 0.5
});
ball.alpha = 0.8;
}
self.update = function () {
// Base speed increases with game progression (height climbed)
var progressMultiplier = 1 + Math.max(0, (2732 - player.y) / 2000);
// Slow down progression at high levels (towards the end)
var endGameHeight = 2732 - player.y;
if (endGameHeight > 1500) {
// Reduce multiplier for late game - moderate reduction
var lateGameReduction = Math.min(0.4, (endGameHeight - 1500) / 1000);
progressMultiplier *= 1 - lateGameReduction;
}
// Additional speed boost based on player's upward velocity
var velocityMultiplier = 1;
if (player.velocityY < -10) {
// Player is rising quickly - moderate speed boost
velocityMultiplier = 1.5 + Math.abs(player.velocityY) / 15;
}
// Combine both multipliers for final speed
var totalSpeed = self.riseSpeed * progressMultiplier * velocityMultiplier;
self.y -= totalSpeed;
// Prevent balls from going below bottom of screen
if (self.y > cameraY + 2732) {
self.y = cameraY + 2732;
}
// Reset position when too far above camera
if (self.y < cameraY - 1000) {
self.y = cameraY + 3000;
}
};
return self;
});
var WinKey = Container.expand(function () {
var self = Container.call(this);
var keyGraphics = self.attachAsset('winKey', {
anchorX: 0.5,
anchorY: 0.5
});
// Add visual effects to make the key stand out
self.animationTime = 0;
self.update = function () {
// Floating animation
self.animationTime += 0.1;
keyGraphics.y = Math.sin(self.animationTime) * 10;
// Rotation animation
keyGraphics.rotation += 0.05;
// Pulsing scale effect
var scale = 1 + Math.sin(self.animationTime * 2) * 0.2;
keyGraphics.scaleX = scale;
keyGraphics.scaleY = scale;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB
});
/****
* Game Code
****/
var player;
var platforms = [];
var cameraY = 0;
var highestY = 2732;
var platformSpacing = 200;
var lastPlatformY = 2732;
var risingBalls = [];
var winKey = null;
var keySpawned = false;
// UI Elements
var heightText = new Text2('Height: 0m', {
size: 60,
fill: 0xFFFFFF
});
heightText.anchor.set(0.5, 0);
LK.gui.top.addChild(heightText);
// Initialize player
player = game.addChild(new Player());
player.x = 1024;
player.y = 2500;
// Create starting platform directly below player
var startPlatform = new Platform('regular');
startPlatform.x = 1024;
startPlatform.y = 2600;
platforms.push(startPlatform);
game.addChild(startPlatform);
// Create rising balls on right side, positioned side by side with more distance
var rightCagedBall = new RisingBall(true);
rightCagedBall.x = 1750;
rightCagedBall.y = 2400;
risingBalls.push(rightCagedBall);
game.addChild(rightCagedBall);
var rightFreeBall = new RisingBall(false);
rightFreeBall.x = 1950;
rightFreeBall.y = 2400;
risingBalls.push(rightFreeBall);
game.addChild(rightFreeBall);
// Create initial platforms
for (var i = 0; i < 15; i++) {
createPlatform();
}
function createPlatform() {
var currentLevel = Math.floor((2732 - lastPlatformY) / 10);
var platformType = 'regular';
var rand = Math.random();
// Platform type probabilities
if (rand < 0.1) platformType = 'spring';else if (rand < 0.25) platformType = 'breakable';else if (rand < 0.4) platformType = 'moving';
var platform = new Platform(platformType);
platform.x = Math.random() * 1600 + 224; // Keep platforms within bounds
platform.y = lastPlatformY - platformSpacing;
// Increase difficulty with height - reduced spacing for jumpability
var heightFactor = Math.max(0, (2732 - lastPlatformY) / 1000);
// Cap platform spacing after level 2200 to keep gaps jumpable
if (currentLevel > 2200) {
// Use spacing from level 2200 and don't increase further
var cappedHeightFactor = Math.max(0, (2732 - (2732 - 2200 * 10)) / 1000);
platformSpacing = 60 + Math.random() * 30 + cappedHeightFactor * 15;
} else {
platformSpacing = 60 + Math.random() * 30 + heightFactor * 15;
}
platforms.push(platform);
game.addChild(platform);
lastPlatformY = platform.y;
}
// Drag controls
var isDragging = false;
game.down = function (x, y, obj) {
isDragging = true;
player.x = x;
};
game.move = function (x, y, obj) {
if (isDragging) {
player.x = x;
}
};
game.up = function (x, y, obj) {
isDragging = false;
};
game.update = function () {
// Update camera to follow player
var targetCameraY = player.y - 1500;
if (targetCameraY < cameraY) {
cameraY = targetCameraY;
game.y = -cameraY;
}
// Update highest point reached
if (player.y < highestY) {
highestY = player.y;
var height = Math.floor((2732 - highestY) / 10);
LK.setScore(height);
heightText.setText('Height: ' + height + 'm');
// Spawn win key at level 5000
if (height >= 5000 && !keySpawned) {
winKey = new WinKey();
winKey.x = 1024; // Center of screen
winKey.y = player.y - 200; // Above player
game.addChild(winKey);
keySpawned = true;
}
}
// Check for key collection
if (winKey && player.intersects(winKey)) {
LK.showYouWin("Congratulations! You've rescued your girlfriend!");
return;
}
// Generate new platforms as player climbs
while (lastPlatformY > cameraY - 500) {
createPlatform();
}
// Remove platforms that are too far below
for (var i = platforms.length - 1; i >= 0; i--) {
var platform = platforms[i];
if (platform.y > cameraY + 3000) {
platform.destroy();
platforms.splice(i, 1);
}
}
// Check if caged ball goes off screen top
for (var i = 0; i < risingBalls.length; i++) {
var ball = risingBalls[i];
if (ball.hasCage && ball.y < cameraY - 100) {
var height = Math.floor((2732 - highestY) / 10);
if (height >= 5000) {
LK.showGameOver("Mehmet kidnapped Emre");
} else {
LK.showGameOver("Mehmet kidnapped Emre");
}
return;
}
}
// Game over if player falls below screen
if (player.y > cameraY + 2732 + 200) {
var height = Math.floor((2732 - highestY) / 10);
if (height >= 5000) {
LK.showGameOver("Mehmet kidnapped Emre");
} else {
LK.showGameOver("Mehmet kidnapped Emre");
}
}
}; /****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Platform = Container.expand(function (type) {
var self = Container.call(this);
self.type = type || 'regular';
self.broken = false;
var assetName = 'platform';
if (self.type === 'moving') assetName = 'movingPlatform';else if (self.type === 'breakable') assetName = 'breakablePlatform';else if (self.type === 'spring') assetName = 'springPlatform';
var platformGraphics = self.attachAsset(assetName, {
anchorX: 0.5,
anchorY: 0.5
});
self.direction = Math.random() > 0.5 ? 1 : -1;
self.speed = 2;
self.update = function () {
if (self.type === 'moving' && !self.broken) {
self.x += self.direction * self.speed;
if (self.x < 100 || self.x > 1948) {
self.direction *= -1;
}
}
};
self.onPlayerLand = function () {
if (self.type === 'breakable' && !self.broken) {
self.broken = true;
tween(self, {
alpha: 0
}, {
duration: 200
});
LK.getSound('break').play();
} else if (self.type === 'spring') {
player.springJump();
tween(self, {
scaleY: 0.5
}, {
duration: 100,
onFinish: function onFinish() {
tween(self, {
scaleY: 1
}, {
duration: 100
});
}
});
}
};
return self;
});
var Player = Container.expand(function () {
var self = Container.call(this);
var playerGraphics = self.attachAsset('player', {
anchorX: 0.5,
anchorY: 0.5
});
self.velocityY = 0;
self.gravity = 0.8;
self.jumpStrength = -26;
self.horizontalSpeed = 8;
self.isJumping = true;
self.update = function () {
// Apply gravity
self.velocityY += self.gravity;
self.y += self.velocityY;
// Horizontal movement boundaries
if (self.x < 40) self.x = 40;
if (self.x > 2008) self.x = 2008;
// Check platform collisions only when falling
if (self.velocityY > 0) {
for (var i = 0; i < platforms.length; i++) {
var platform = platforms[i];
if (self.intersects(platform) && self.y < platform.y) {
self.jump();
platform.onPlayerLand();
break;
}
}
}
};
self.jump = function () {
self.velocityY = self.jumpStrength;
self.isJumping = true;
LK.getSound('jump').play();
};
self.springJump = function () {
self.velocityY = self.jumpStrength * 1.5;
self.isJumping = true;
LK.getSound('spring').play();
};
return self;
});
var RisingBall = Container.expand(function (hasCage) {
var self = Container.call(this);
self.hasCage = hasCage || false;
self.riseSpeed = 0.45;
if (self.hasCage) {
var cage = self.attachAsset('ballCage', {
anchorX: 0.5,
anchorY: 0.5
});
cage.alpha = 0.7;
var ball = self.attachAsset('character', {
anchorX: 0.5,
anchorY: 0.5
});
ball.alpha = 0.8;
} else {
var ball = self.attachAsset('risingBall', {
anchorX: 0.5,
anchorY: 0.5
});
ball.alpha = 0.8;
}
self.update = function () {
// Base speed increases with game progression (height climbed)
var progressMultiplier = 1 + Math.max(0, (2732 - player.y) / 2000);
// Slow down progression at high levels (towards the end)
var endGameHeight = 2732 - player.y;
if (endGameHeight > 1500) {
// Reduce multiplier for late game - moderate reduction
var lateGameReduction = Math.min(0.4, (endGameHeight - 1500) / 1000);
progressMultiplier *= 1 - lateGameReduction;
}
// Additional speed boost based on player's upward velocity
var velocityMultiplier = 1;
if (player.velocityY < -10) {
// Player is rising quickly - moderate speed boost
velocityMultiplier = 1.5 + Math.abs(player.velocityY) / 15;
}
// Combine both multipliers for final speed
var totalSpeed = self.riseSpeed * progressMultiplier * velocityMultiplier;
self.y -= totalSpeed;
// Prevent balls from going below bottom of screen
if (self.y > cameraY + 2732) {
self.y = cameraY + 2732;
}
// Reset position when too far above camera
if (self.y < cameraY - 1000) {
self.y = cameraY + 3000;
}
};
return self;
});
var WinKey = Container.expand(function () {
var self = Container.call(this);
var keyGraphics = self.attachAsset('winKey', {
anchorX: 0.5,
anchorY: 0.5
});
// Add visual effects to make the key stand out
self.animationTime = 0;
self.update = function () {
// Floating animation
self.animationTime += 0.1;
keyGraphics.y = Math.sin(self.animationTime) * 10;
// Rotation animation
keyGraphics.rotation += 0.05;
// Pulsing scale effect
var scale = 1 + Math.sin(self.animationTime * 2) * 0.2;
keyGraphics.scaleX = scale;
keyGraphics.scaleY = scale;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB
});
/****
* Game Code
****/
var player;
var platforms = [];
var cameraY = 0;
var highestY = 2732;
var platformSpacing = 200;
var lastPlatformY = 2732;
var risingBalls = [];
var winKey = null;
var keySpawned = false;
// UI Elements
var heightText = new Text2('Height: 0m', {
size: 60,
fill: 0xFFFFFF
});
heightText.anchor.set(0.5, 0);
LK.gui.top.addChild(heightText);
// Initialize player
player = game.addChild(new Player());
player.x = 1024;
player.y = 2500;
// Create starting platform directly below player
var startPlatform = new Platform('regular');
startPlatform.x = 1024;
startPlatform.y = 2600;
platforms.push(startPlatform);
game.addChild(startPlatform);
// Create rising balls on right side, positioned side by side with more distance
var rightCagedBall = new RisingBall(true);
rightCagedBall.x = 1750;
rightCagedBall.y = 2400;
risingBalls.push(rightCagedBall);
game.addChild(rightCagedBall);
var rightFreeBall = new RisingBall(false);
rightFreeBall.x = 1950;
rightFreeBall.y = 2400;
risingBalls.push(rightFreeBall);
game.addChild(rightFreeBall);
// Create initial platforms
for (var i = 0; i < 15; i++) {
createPlatform();
}
function createPlatform() {
var currentLevel = Math.floor((2732 - lastPlatformY) / 10);
var platformType = 'regular';
var rand = Math.random();
// Platform type probabilities
if (rand < 0.1) platformType = 'spring';else if (rand < 0.25) platformType = 'breakable';else if (rand < 0.4) platformType = 'moving';
var platform = new Platform(platformType);
platform.x = Math.random() * 1600 + 224; // Keep platforms within bounds
platform.y = lastPlatformY - platformSpacing;
// Increase difficulty with height - reduced spacing for jumpability
var heightFactor = Math.max(0, (2732 - lastPlatformY) / 1000);
// Cap platform spacing after level 2200 to keep gaps jumpable
if (currentLevel > 2200) {
// Use spacing from level 2200 and don't increase further
var cappedHeightFactor = Math.max(0, (2732 - (2732 - 2200 * 10)) / 1000);
platformSpacing = 60 + Math.random() * 30 + cappedHeightFactor * 15;
} else {
platformSpacing = 60 + Math.random() * 30 + heightFactor * 15;
}
platforms.push(platform);
game.addChild(platform);
lastPlatformY = platform.y;
}
// Drag controls
var isDragging = false;
game.down = function (x, y, obj) {
isDragging = true;
player.x = x;
};
game.move = function (x, y, obj) {
if (isDragging) {
player.x = x;
}
};
game.up = function (x, y, obj) {
isDragging = false;
};
game.update = function () {
// Update camera to follow player
var targetCameraY = player.y - 1500;
if (targetCameraY < cameraY) {
cameraY = targetCameraY;
game.y = -cameraY;
}
// Update highest point reached
if (player.y < highestY) {
highestY = player.y;
var height = Math.floor((2732 - highestY) / 10);
LK.setScore(height);
heightText.setText('Height: ' + height + 'm');
// Spawn win key at level 5000
if (height >= 5000 && !keySpawned) {
winKey = new WinKey();
winKey.x = 1024; // Center of screen
winKey.y = player.y - 200; // Above player
game.addChild(winKey);
keySpawned = true;
}
}
// Check for key collection
if (winKey && player.intersects(winKey)) {
LK.showYouWin("Congratulations! You've rescued your girlfriend!");
return;
}
// Generate new platforms as player climbs
while (lastPlatformY > cameraY - 500) {
createPlatform();
}
// Remove platforms that are too far below
for (var i = platforms.length - 1; i >= 0; i--) {
var platform = platforms[i];
if (platform.y > cameraY + 3000) {
platform.destroy();
platforms.splice(i, 1);
}
}
// Check if caged ball goes off screen top
for (var i = 0; i < risingBalls.length; i++) {
var ball = risingBalls[i];
if (ball.hasCage && ball.y < cameraY - 100) {
var height = Math.floor((2732 - highestY) / 10);
if (height >= 5000) {
LK.showGameOver("Mehmet kidnapped Emre");
} else {
LK.showGameOver("Mehmet kidnapped Emre");
}
return;
}
}
// Game over if player falls below screen
if (player.y > cameraY + 2732 + 200) {
var height = Math.floor((2732 - highestY) / 10);
if (height >= 5000) {
LK.showGameOver("Mehmet kidnapped Emre");
} else {
LK.showGameOver("Mehmet kidnapped Emre");
}
}
};
cloud 200x20. In-Game asset. 2d. High contrast. No shadows
wood platform 200x20. In-Game asset. 2d. High contrast. No shadows
trampoline 200x20. In-Game asset. 2d. High contrast. No shadows
black cage. In-Game asset. 2d. High contrast. No shadows
yellow key. In-Game asset. 2d. High contrast. No shadows