/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var Hero = Container.expand(function () { var self = Container.call(this); var heroGraphics = self.attachAsset('hero', { anchorX: 0.5, anchorY: 0.5 }); self.velocityX = 0; self.velocityY = 0; self.isSwinging = false; self.currentHook = null; self.ropeLength = 200; self.gravity = 0.3; self.swingDamping = 0.998; self.update = function () { if (self.isSwinging && self.currentHook) { // Apply mouse movement influence to swing var mouseDelta = mouseX - lastMouseX; self.velocityX += mouseDelta * swingForce; // Calculate rope physics var dx = self.x - self.currentHook.x; var dy = self.y - self.currentHook.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance > self.ropeLength) { // Constrain to rope length var angle = Math.atan2(dy, dx); self.x = self.currentHook.x + Math.cos(angle) * self.ropeLength; self.y = self.currentHook.y + Math.sin(angle) * self.ropeLength; // Apply pendulum physics var tension = self.velocityX * Math.cos(angle) + self.velocityY * Math.sin(angle); self.velocityX -= tension * Math.cos(angle); self.velocityY -= tension * Math.sin(angle); } self.velocityY += self.gravity; self.velocityX *= self.swingDamping; self.velocityY *= self.swingDamping; } else { // Free fall physics self.velocityY += self.gravity; } self.x += self.velocityX; self.y += self.velocityY; }; self.attachToHook = function (hook) { self.currentHook = hook; self.isSwinging = true; LK.getSound('grab').play(); }; self.release = function () { self.currentHook = null; self.isSwinging = false; LK.getSound('swing').play(); }; return self; }); var Hook = Container.expand(function () { var self = Container.call(this); var hookGraphics = self.attachAsset('hook', { anchorX: 0.5, anchorY: 0.5 }); self.isGrabbed = false; return self; }); var RopeSegment = Container.expand(function () { var self = Container.call(this); var ropeGraphics = self.attachAsset('rope', { anchorX: 0.5, anchorY: 0 }); return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x2D1B0F }); /**** * Game Code ****/ // Game variables var hero; var hooks = []; var ropeSegments = []; var throwingLineSegments = []; var lavaFloor; var currentHookIndex = 0; var gameStarted = false; var isReleased = false; var mouseX = 0; var mouseY = 0; var lastMouseX = 0; var swingForce = 0.05; var usedHooks = []; // Track hooks that have been used // Create forest background var forestBackground = game.addChild(LK.getAsset('forestBg', { x: 0, y: 0, alpha: 0.8 })); // Create volcanic glow effect in lower portion var volcanoGlow = game.addChild(LK.getAsset('volcanoGlow', { x: 0, y: 2732 - 800, alpha: 0.3 })); // Create lava floor lavaFloor = game.addChild(LK.getAsset('lava', { x: 0, y: 2732 - 300 })); // Create hero hero = game.addChild(new Hero()); hero.x = 300; hero.y = 400; // Create hooks var hookPositions = [{ x: 300, y: 300 }, { x: 600, y: 450 }, { x: 950, y: 350 }, { x: 1300, y: 500 }, { x: 1650, y: 380 }, { x: 2000, y: 480 }, { x: 2350, y: 420 }, { x: 2700, y: 550 }, { x: 3050, y: 350 }, { x: 3400, y: 480 }, { x: 3750, y: 400 }, { x: 4100, y: 520 }, { x: 4450, y: 320 }, { x: 4800, y: 460 }, { x: 5150, y: 380 }, { x: 5500, y: 500 }, { x: 5850, y: 340 }, { x: 6200, y: 470 }, { x: 6550, y: 410 }, { x: 6900, y: 530 }, { x: 7250, y: 360 }, { x: 7600, y: 490 }, { x: 7950, y: 430 }, { x: 8300, y: 520 }, { x: 8650, y: 400 }, { x: 9000, y: 480 }, { x: 9350, y: 320 }, { x: 9700, y: 550 }, { x: 10050, y: 380 }, { x: 10400, y: 460 }, { x: 10750, y: 340 }, { x: 11100, y: 520 }, { x: 11450, y: 400 }, { x: 11800, y: 480 }, { x: 12150, y: 350 }, { x: 12500, y: 500 }, { x: 12850, y: 420 }, { x: 13200, y: 540 }, { x: 13550, y: 360 }, { x: 13900, y: 470 }, { x: 14250, y: 390 }, { x: 14600, y: 510 }, { x: 14950, y: 330 }, { x: 15300, y: 450 }, { x: 15650, y: 380 }, { x: 16000, y: 520 }, { x: 16350, y: 340 }, { x: 16700, y: 480 }, { x: 17050, y: 400 }, { x: 17400, y: 550 }]; for (var i = 0; i < hookPositions.length; i++) { var hook = game.addChild(new Hook()); hook.x = hookPositions[i].x; hook.y = hookPositions[i].y; hooks.push(hook); } // Start hero attached to first hook hero.attachToHook(hooks[0]); currentHookIndex = 0; usedHooks.push(hooks[0]); // Mark first hook as used // Create rope segments for visual effect for (var j = 0; j < 10; j++) { var segment = game.addChild(new RopeSegment()); ropeSegments.push(segment); } // Create throwing line segments for (var k = 0; k < 15; k++) { var lineSegment = game.addChild(LK.getAsset('ropeLine', { anchorX: 0.5, anchorY: 0.5, alpha: 0 })); throwingLineSegments.push(lineSegment); } // Score display var scoreTxt = new Text2('Score: 0', { size: 80, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Mouse movement handler for swing control game.move = function (x, y, obj) { lastMouseX = mouseX; mouseX = x; mouseY = y; }; // Game input handling game.down = function (x, y, obj) { if (!gameStarted) { gameStarted = true; return; } if (hero.isSwinging && !isReleased) { // Release from current hook hero.release(); isReleased = true; } else if (isReleased) { // Try to grab nearest hook that the hero is close to var nearestHook = null; var minDistance = 200; // Increased grab distance for better UX var bestHook = null; for (var i = 0; i < hooks.length; i++) { if (hooks[i] === hero.currentHook) continue; // Skip hooks that have already been used var isUsed = false; for (var u = 0; u < usedHooks.length; u++) { if (usedHooks[u] === hooks[i]) { isUsed = true; break; } } if (isUsed) continue; var dx = hero.x - hooks[i].x; var dy = hero.y - hooks[i].y; var distance = Math.sqrt(dx * dx + dy * dy); // Prioritize hooks that are in the direction of movement var isInDirection = hero.velocityX > 0 && hooks[i].x > hero.x || hero.velocityX < 0 && hooks[i].x < hero.x; if (distance < minDistance && (bestHook === null || isInDirection && distance < minDistance * 0.8)) { minDistance = distance; nearestHook = hooks[i]; if (isInDirection) bestHook = hooks[i]; } } // Use best hook if available, otherwise use nearest var targetHook = bestHook || nearestHook; if (targetHook) { // Create smooth rope throwing animation var ropeDx = targetHook.x - hero.x; var ropeDy = targetHook.y - hero.y; var ropeDistance = Math.sqrt(ropeDx * ropeDx + ropeDy * ropeDy); var swingRadius = hero.ropeLength; // Calculate optimal attachment point var attachAngle = Math.atan2(ropeDy, ropeDx); var targetX = targetHook.x + Math.cos(attachAngle + Math.PI) * (swingRadius * 0.3); var targetY = targetHook.y + Math.sin(attachAngle + Math.PI) * (swingRadius * 0.3) + swingRadius; // Animate rope throw with tween tween(hero, { x: targetX, y: targetY }, { duration: 250, easing: tween.easeInOut, onFinish: function onFinish() { hero.attachToHook(targetHook); currentHookIndex = hooks.indexOf(targetHook); isReleased = false; // Mark current hook as used usedHooks.push(targetHook); // Award points based on distance and timing var points = Math.floor(30 + ropeDistance / 10); LK.setScore(LK.getScore() + points); scoreTxt.setText('Score: ' + LK.getScore()); } }); } } }; // Game update game.update = function () { // Initialize mouse position if not set if (mouseX === 0 && mouseY === 0) { mouseX = hero.x; mouseY = hero.y; lastMouseX = mouseX; } // Check if hero fell into lava if (hero.y > lavaFloor.y - 50) { LK.effects.flashScreen(0xFF0000, 1000); LK.showGameOver(); return; } // Update rope visual if (hero.isSwinging && hero.currentHook) { var dx = hero.x - hero.currentHook.x; var dy = hero.y - hero.currentHook.y; var distance = Math.sqrt(dx * dx + dy * dy); var segmentDistance = distance / ropeSegments.length; for (var i = 0; i < ropeSegments.length; i++) { var segment = ropeSegments[i]; var progress = (i + 1) / ropeSegments.length; segment.x = hero.currentHook.x + dx * progress; segment.y = hero.currentHook.y + dy * progress; segment.height = segmentDistance; segment.rotation = Math.atan2(dy, dx) + Math.PI / 2; segment.alpha = 1; } // Hide throwing line when swinging for (var m = 0; m < throwingLineSegments.length; m++) { throwingLineSegments[m].alpha = 0; } } else if (isReleased) { // Hide rope when not swinging for (var j = 0; j < ropeSegments.length; j++) { ropeSegments[j].alpha = 0; } // Show throwing line to nearest hook var nearestHook = null; var minDistance = 150; for (var n = 0; n < hooks.length; n++) { if (hooks[n] === hero.currentHook) continue; // Skip hooks that have already been used var isUsedHook = false; for (var v = 0; v < usedHooks.length; v++) { if (usedHooks[v] === hooks[n]) { isUsedHook = true; break; } } if (isUsedHook) continue; var hdx = hero.x - hooks[n].x; var hdy = hero.y - hooks[n].y; var hdistance = Math.sqrt(hdx * hdx + hdy * hdy); if (hdistance < minDistance) { minDistance = hdistance; nearestHook = hooks[n]; } } if (nearestHook) { var lineDx = nearestHook.x - hero.x; var lineDy = nearestHook.y - hero.y; var lineDistance = Math.sqrt(lineDx * lineDx + lineDy * lineDy); var lineSegmentDistance = lineDistance / throwingLineSegments.length; for (var l = 0; l < throwingLineSegments.length; l++) { var lineSegment = throwingLineSegments[l]; var lineProgress = (l + 1) / throwingLineSegments.length; lineSegment.x = hero.x + lineDx * lineProgress; lineSegment.y = hero.y + lineDy * lineProgress; lineSegment.height = lineSegmentDistance; lineSegment.rotation = Math.atan2(lineDy, lineDx) + Math.PI / 2; lineSegment.alpha = 0.6; } } else { for (var o = 0; o < throwingLineSegments.length; o++) { throwingLineSegments[o].alpha = 0; } } } else { // Hide both rope and throwing line for (var p = 0; p < ropeSegments.length; p++) { ropeSegments[p].alpha = 0; } for (var q = 0; q < throwingLineSegments.length; q++) { throwingLineSegments[q].alpha = 0; } } // Check for win condition (reaching final hook) if (currentHookIndex >= hooks.length - 1 && LK.getScore() >= 1000) { LK.showYouWin(); } };
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Hero = Container.expand(function () {
var self = Container.call(this);
var heroGraphics = self.attachAsset('hero', {
anchorX: 0.5,
anchorY: 0.5
});
self.velocityX = 0;
self.velocityY = 0;
self.isSwinging = false;
self.currentHook = null;
self.ropeLength = 200;
self.gravity = 0.3;
self.swingDamping = 0.998;
self.update = function () {
if (self.isSwinging && self.currentHook) {
// Apply mouse movement influence to swing
var mouseDelta = mouseX - lastMouseX;
self.velocityX += mouseDelta * swingForce;
// Calculate rope physics
var dx = self.x - self.currentHook.x;
var dy = self.y - self.currentHook.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance > self.ropeLength) {
// Constrain to rope length
var angle = Math.atan2(dy, dx);
self.x = self.currentHook.x + Math.cos(angle) * self.ropeLength;
self.y = self.currentHook.y + Math.sin(angle) * self.ropeLength;
// Apply pendulum physics
var tension = self.velocityX * Math.cos(angle) + self.velocityY * Math.sin(angle);
self.velocityX -= tension * Math.cos(angle);
self.velocityY -= tension * Math.sin(angle);
}
self.velocityY += self.gravity;
self.velocityX *= self.swingDamping;
self.velocityY *= self.swingDamping;
} else {
// Free fall physics
self.velocityY += self.gravity;
}
self.x += self.velocityX;
self.y += self.velocityY;
};
self.attachToHook = function (hook) {
self.currentHook = hook;
self.isSwinging = true;
LK.getSound('grab').play();
};
self.release = function () {
self.currentHook = null;
self.isSwinging = false;
LK.getSound('swing').play();
};
return self;
});
var Hook = Container.expand(function () {
var self = Container.call(this);
var hookGraphics = self.attachAsset('hook', {
anchorX: 0.5,
anchorY: 0.5
});
self.isGrabbed = false;
return self;
});
var RopeSegment = Container.expand(function () {
var self = Container.call(this);
var ropeGraphics = self.attachAsset('rope', {
anchorX: 0.5,
anchorY: 0
});
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x2D1B0F
});
/****
* Game Code
****/
// Game variables
var hero;
var hooks = [];
var ropeSegments = [];
var throwingLineSegments = [];
var lavaFloor;
var currentHookIndex = 0;
var gameStarted = false;
var isReleased = false;
var mouseX = 0;
var mouseY = 0;
var lastMouseX = 0;
var swingForce = 0.05;
var usedHooks = []; // Track hooks that have been used
// Create forest background
var forestBackground = game.addChild(LK.getAsset('forestBg', {
x: 0,
y: 0,
alpha: 0.8
}));
// Create volcanic glow effect in lower portion
var volcanoGlow = game.addChild(LK.getAsset('volcanoGlow', {
x: 0,
y: 2732 - 800,
alpha: 0.3
}));
// Create lava floor
lavaFloor = game.addChild(LK.getAsset('lava', {
x: 0,
y: 2732 - 300
}));
// Create hero
hero = game.addChild(new Hero());
hero.x = 300;
hero.y = 400;
// Create hooks
var hookPositions = [{
x: 300,
y: 300
}, {
x: 600,
y: 450
}, {
x: 950,
y: 350
}, {
x: 1300,
y: 500
}, {
x: 1650,
y: 380
}, {
x: 2000,
y: 480
}, {
x: 2350,
y: 420
}, {
x: 2700,
y: 550
}, {
x: 3050,
y: 350
}, {
x: 3400,
y: 480
}, {
x: 3750,
y: 400
}, {
x: 4100,
y: 520
}, {
x: 4450,
y: 320
}, {
x: 4800,
y: 460
}, {
x: 5150,
y: 380
}, {
x: 5500,
y: 500
}, {
x: 5850,
y: 340
}, {
x: 6200,
y: 470
}, {
x: 6550,
y: 410
}, {
x: 6900,
y: 530
}, {
x: 7250,
y: 360
}, {
x: 7600,
y: 490
}, {
x: 7950,
y: 430
}, {
x: 8300,
y: 520
}, {
x: 8650,
y: 400
}, {
x: 9000,
y: 480
}, {
x: 9350,
y: 320
}, {
x: 9700,
y: 550
}, {
x: 10050,
y: 380
}, {
x: 10400,
y: 460
}, {
x: 10750,
y: 340
}, {
x: 11100,
y: 520
}, {
x: 11450,
y: 400
}, {
x: 11800,
y: 480
}, {
x: 12150,
y: 350
}, {
x: 12500,
y: 500
}, {
x: 12850,
y: 420
}, {
x: 13200,
y: 540
}, {
x: 13550,
y: 360
}, {
x: 13900,
y: 470
}, {
x: 14250,
y: 390
}, {
x: 14600,
y: 510
}, {
x: 14950,
y: 330
}, {
x: 15300,
y: 450
}, {
x: 15650,
y: 380
}, {
x: 16000,
y: 520
}, {
x: 16350,
y: 340
}, {
x: 16700,
y: 480
}, {
x: 17050,
y: 400
}, {
x: 17400,
y: 550
}];
for (var i = 0; i < hookPositions.length; i++) {
var hook = game.addChild(new Hook());
hook.x = hookPositions[i].x;
hook.y = hookPositions[i].y;
hooks.push(hook);
}
// Start hero attached to first hook
hero.attachToHook(hooks[0]);
currentHookIndex = 0;
usedHooks.push(hooks[0]); // Mark first hook as used
// Create rope segments for visual effect
for (var j = 0; j < 10; j++) {
var segment = game.addChild(new RopeSegment());
ropeSegments.push(segment);
}
// Create throwing line segments
for (var k = 0; k < 15; k++) {
var lineSegment = game.addChild(LK.getAsset('ropeLine', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 0
}));
throwingLineSegments.push(lineSegment);
}
// Score display
var scoreTxt = new Text2('Score: 0', {
size: 80,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Mouse movement handler for swing control
game.move = function (x, y, obj) {
lastMouseX = mouseX;
mouseX = x;
mouseY = y;
};
// Game input handling
game.down = function (x, y, obj) {
if (!gameStarted) {
gameStarted = true;
return;
}
if (hero.isSwinging && !isReleased) {
// Release from current hook
hero.release();
isReleased = true;
} else if (isReleased) {
// Try to grab nearest hook that the hero is close to
var nearestHook = null;
var minDistance = 200; // Increased grab distance for better UX
var bestHook = null;
for (var i = 0; i < hooks.length; i++) {
if (hooks[i] === hero.currentHook) continue;
// Skip hooks that have already been used
var isUsed = false;
for (var u = 0; u < usedHooks.length; u++) {
if (usedHooks[u] === hooks[i]) {
isUsed = true;
break;
}
}
if (isUsed) continue;
var dx = hero.x - hooks[i].x;
var dy = hero.y - hooks[i].y;
var distance = Math.sqrt(dx * dx + dy * dy);
// Prioritize hooks that are in the direction of movement
var isInDirection = hero.velocityX > 0 && hooks[i].x > hero.x || hero.velocityX < 0 && hooks[i].x < hero.x;
if (distance < minDistance && (bestHook === null || isInDirection && distance < minDistance * 0.8)) {
minDistance = distance;
nearestHook = hooks[i];
if (isInDirection) bestHook = hooks[i];
}
}
// Use best hook if available, otherwise use nearest
var targetHook = bestHook || nearestHook;
if (targetHook) {
// Create smooth rope throwing animation
var ropeDx = targetHook.x - hero.x;
var ropeDy = targetHook.y - hero.y;
var ropeDistance = Math.sqrt(ropeDx * ropeDx + ropeDy * ropeDy);
var swingRadius = hero.ropeLength;
// Calculate optimal attachment point
var attachAngle = Math.atan2(ropeDy, ropeDx);
var targetX = targetHook.x + Math.cos(attachAngle + Math.PI) * (swingRadius * 0.3);
var targetY = targetHook.y + Math.sin(attachAngle + Math.PI) * (swingRadius * 0.3) + swingRadius;
// Animate rope throw with tween
tween(hero, {
x: targetX,
y: targetY
}, {
duration: 250,
easing: tween.easeInOut,
onFinish: function onFinish() {
hero.attachToHook(targetHook);
currentHookIndex = hooks.indexOf(targetHook);
isReleased = false;
// Mark current hook as used
usedHooks.push(targetHook);
// Award points based on distance and timing
var points = Math.floor(30 + ropeDistance / 10);
LK.setScore(LK.getScore() + points);
scoreTxt.setText('Score: ' + LK.getScore());
}
});
}
}
};
// Game update
game.update = function () {
// Initialize mouse position if not set
if (mouseX === 0 && mouseY === 0) {
mouseX = hero.x;
mouseY = hero.y;
lastMouseX = mouseX;
}
// Check if hero fell into lava
if (hero.y > lavaFloor.y - 50) {
LK.effects.flashScreen(0xFF0000, 1000);
LK.showGameOver();
return;
}
// Update rope visual
if (hero.isSwinging && hero.currentHook) {
var dx = hero.x - hero.currentHook.x;
var dy = hero.y - hero.currentHook.y;
var distance = Math.sqrt(dx * dx + dy * dy);
var segmentDistance = distance / ropeSegments.length;
for (var i = 0; i < ropeSegments.length; i++) {
var segment = ropeSegments[i];
var progress = (i + 1) / ropeSegments.length;
segment.x = hero.currentHook.x + dx * progress;
segment.y = hero.currentHook.y + dy * progress;
segment.height = segmentDistance;
segment.rotation = Math.atan2(dy, dx) + Math.PI / 2;
segment.alpha = 1;
}
// Hide throwing line when swinging
for (var m = 0; m < throwingLineSegments.length; m++) {
throwingLineSegments[m].alpha = 0;
}
} else if (isReleased) {
// Hide rope when not swinging
for (var j = 0; j < ropeSegments.length; j++) {
ropeSegments[j].alpha = 0;
}
// Show throwing line to nearest hook
var nearestHook = null;
var minDistance = 150;
for (var n = 0; n < hooks.length; n++) {
if (hooks[n] === hero.currentHook) continue;
// Skip hooks that have already been used
var isUsedHook = false;
for (var v = 0; v < usedHooks.length; v++) {
if (usedHooks[v] === hooks[n]) {
isUsedHook = true;
break;
}
}
if (isUsedHook) continue;
var hdx = hero.x - hooks[n].x;
var hdy = hero.y - hooks[n].y;
var hdistance = Math.sqrt(hdx * hdx + hdy * hdy);
if (hdistance < minDistance) {
minDistance = hdistance;
nearestHook = hooks[n];
}
}
if (nearestHook) {
var lineDx = nearestHook.x - hero.x;
var lineDy = nearestHook.y - hero.y;
var lineDistance = Math.sqrt(lineDx * lineDx + lineDy * lineDy);
var lineSegmentDistance = lineDistance / throwingLineSegments.length;
for (var l = 0; l < throwingLineSegments.length; l++) {
var lineSegment = throwingLineSegments[l];
var lineProgress = (l + 1) / throwingLineSegments.length;
lineSegment.x = hero.x + lineDx * lineProgress;
lineSegment.y = hero.y + lineDy * lineProgress;
lineSegment.height = lineSegmentDistance;
lineSegment.rotation = Math.atan2(lineDy, lineDx) + Math.PI / 2;
lineSegment.alpha = 0.6;
}
} else {
for (var o = 0; o < throwingLineSegments.length; o++) {
throwingLineSegments[o].alpha = 0;
}
}
} else {
// Hide both rope and throwing line
for (var p = 0; p < ropeSegments.length; p++) {
ropeSegments[p].alpha = 0;
}
for (var q = 0; q < throwingLineSegments.length; q++) {
throwingLineSegments[q].alpha = 0;
}
}
// Check for win condition (reaching final hook)
if (currentHookIndex >= hooks.length - 1 && LK.getScore() >= 1000) {
LK.showYouWin();
}
};
kanca yaparmısın. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
kancaya takılan halatlardan yapabilirmisin . No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
maceracı bir tip elleriyle halat tutuyor. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
alev ve lav karışımı bir olsun. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat