User prompt
the images are not changning when moving on side of the screen from the middle!
User prompt
make the player can climb down and up based on the clicked position down player or up the player
User prompt
Flip images based on the middle of the screen
User prompt
Flip images of animation Ninja 1 2 3 4 if mouse button clicked and holded on the left side of the player and same if holded on the right side flip images to the right side
User prompt
flip movement asset images when moving to the left direction!
User prompt
Change direction of player based on the movement to the right or to the left and same for the shooting
User prompt
Fix it !
User prompt
if player start climbing on 1px of the ladder stop the animation after reaching 200px of it
User prompt
Fix ladder collision size so the player climbing animation doesn't continue to top screen and it will stop after passing top or bottom edges of the ladder
Code edit (3 edits merged)
Please save this source code
User prompt
turn the animation images to the left if player is moving to the left side and turn them to the right if the player is moving to the right side. same for Ninjashooting frame turn it to the left if i click on enemy on the left side, flip it to right if shooting to the right side enemies
User prompt
Stop the climbing if player is on the platform, and make the collision of platforms thin more. player must move on the platforms or ladder only can't touch background1!
User prompt
The player assets Ninja1 2 3 4 for movement animation doesn't flip to the left when holding on the left of the screen to move player!
User prompt
If player moving to the left flip images to the left and same for the right, do the same for the shooting if shooting enemies on the left flip ninjashooting asset to the left
User prompt
When player passes the top or bottom edges of the ladder stop climbing animation.
User prompt
snap only when touching the ladder not from far distance!
User prompt
when moving left flip image to right and same for the left, same when shooting on left or right flip images. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
When the player climb a ladder he keep climbing till reach top of the screen!
User prompt
When player is not moving show player asset not first frame ninja1
User prompt
Don't do continuous animation for ladder just the vertical distance between its edges. make the player asset the first frame when is not moving like its standing and when moving start animation of Ninja1 2 3 4. fix the edges of terrains boundaries they are thick so the player can't reach ladder to climb. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
fix player is not showing on the screen?!
User prompt
Add the assets frames of ninja1 Ninja2 Ninja3 Ninja4 as animation for player when moving on platforms, and assets of Ninja01 Ninja02 when climbing on ladder, and asset Ninjashooting as animation when player is shooting stars, if player move or shoot to the left flip image if right flip to right. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
shoot the stars only if enemies clicked by mouse and let the click on the screen for movement of the player ↪💡 Consider importing and using the following plugins: @upit/tween.v1
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var Coin = Container.expand(function () { var self = Container.call(this); var coinGraphics = self.attachAsset('coin', { anchorX: 0.5, anchorY: 0.5 }); self.collected = false; // Gentle floating animation self.floatOffset = 0; self.originalY = 0; self.update = function () { if (!self.collected) { self.floatOffset += 0.1; self.y = self.originalY + Math.sin(self.floatOffset) * 5; } }; return self; }); var Enemy = Container.expand(function () { var self = Container.call(this); var enemyGraphics = self.attachAsset('enemy', { anchorX: 0.5, anchorY: 1 }); self.speed = 1.5; self.direction = 1; self.verticalSpeed = 1; self.verticalDirection = 1; self.platformBounds = { left: 0, right: 500, top: 0, bottom: 0 }; self.assignedPlatform = 0; self.maxHealth = 50; self.health = 50; // Create health bar background self.healthBarBg = self.attachAsset('enemyHealthBarBg', { anchorX: 0.5, anchorY: 1 }); self.healthBarBg.x = 0; self.healthBarBg.y = -120; // Create health bar self.healthBar = self.attachAsset('enemyHealthBar', { anchorX: 0.5, anchorY: 1 }); self.healthBar.x = 0; self.healthBar.y = -120; self.updateHealthBar = function () { var healthPercent = self.health / self.maxHealth; self.healthBar.width = 60 * healthPercent; if (healthPercent > 0.6) { self.healthBar.tint = 0x00ff00; } else if (healthPercent > 0.3) { self.healthBar.tint = 0xffff00; } else { self.healthBar.tint = 0xff0000; } }; self.update = function () { // Horizontal movement self.x += self.speed * self.direction; // Bounce off platform edges horizontally if (self.x <= self.platformBounds.left || self.x >= self.platformBounds.right) { self.direction *= -1; } // Vertical movement within platform area self.y += self.verticalSpeed * self.verticalDirection; // Bounce off platform edges vertically if (self.y <= self.platformBounds.top || self.y >= self.platformBounds.bottom) { self.verticalDirection *= -1; } }; return self; }); var Ladder = Container.expand(function () { var self = Container.call(this); var ladderGraphics = self.attachAsset('ladder', { anchorX: 0.5, anchorY: 0.5 }); return self; }); var Platform = Container.expand(function () { var self = Container.call(this); var platformGraphics = self.attachAsset('platform', { anchorX: 0.5, anchorY: 0.5 }); return self; }); var Player = Container.expand(function () { var self = Container.call(this); var playerGraphics = self.attachAsset('player', { anchorX: 0.5, anchorY: 1 }); self.speed = 7; self.climbSpeed = 2; self.isClimbing = false; self.currentPlatform = null; self.targetY = 0; self.maxHealth = 100; self.health = 100; self.lastShot = 0; self.shootCooldown = 30; // 30 ticks = 0.5 seconds // Animation properties self.animationFrame = 0; self.animationSpeed = 8; // Change frame every 8 ticks self.isMoving = false; self.isShooting = false; self.facingLeft = false; self.lastX = self.x; // Animation frames for different states self.walkFrames = ['Ninja1', 'Ninja2', 'Ninja3', 'Ninja4']; self.climbFrames = ['Ninja01', 'Ninja02']; self.shootFrame = 'Ninjashooting'; // Track animation state changes self.lastAsset = null; self.lastFlip = null; self.updateAnimation = function () { var currentAsset = ''; var shouldFlip = false; if (self.isShooting) { currentAsset = self.shootFrame; shouldFlip = self.facingLeft; } else if (self.isClimbing && self.isMoving) { // Only animate climbing when actually moving on ladder var climbFrameIndex = Math.floor(self.animationFrame / self.animationSpeed) % self.climbFrames.length; currentAsset = self.climbFrames[climbFrameIndex]; shouldFlip = self.facingLeft; } else if (self.isMoving && !self.isClimbing) { // Walking animation when moving horizontally var walkFrameIndex = Math.floor(self.animationFrame / self.animationSpeed) % self.walkFrames.length; currentAsset = self.walkFrames[walkFrameIndex]; shouldFlip = self.facingLeft; } else { // Default standing pose - show player asset when not moving currentAsset = 'player'; shouldFlip = self.facingLeft; } // Only update graphics if asset or flip state changed if (!self.lastAsset || self.lastAsset !== currentAsset || self.lastFlip !== shouldFlip) { // Remove old graphics if exists if (playerGraphics) { self.removeChild(playerGraphics); } // Create new graphics with proper flipping playerGraphics = self.attachAsset(currentAsset, { anchorX: 0.5, anchorY: 1, flipX: shouldFlip ? 1 : 0 }); // Store current state self.lastAsset = currentAsset; self.lastFlip = shouldFlip; } }; self.update = function () { // Check if player is moving (horizontally or vertically) var horizontalMovement = Math.abs(self.x - self.lastX) > 0.1; var verticalMovement = Math.abs(self.y - (self.lastY || self.y)) > 0.1; if (horizontalMovement || verticalMovement && self.isClimbing) { self.isMoving = true; // Determine facing direction for any horizontal movement if (horizontalMovement) { if (self.x < self.lastX) { self.facingLeft = true; } else if (self.x > self.lastX) { self.facingLeft = false; } } } else { self.isMoving = false; } // Update last positions self.lastX = self.x; self.lastY = self.y; // Check if player is shooting (cooldown active) self.isShooting = LK.ticks - self.lastShot < 15; // Show shooting animation for 15 ticks // Update animation frame counter only when moving or shooting if (self.isMoving || self.isShooting) { self.animationFrame++; } // Update animation self.updateAnimation(); // Handle climbing movement if (self.isClimbing) { if (Math.abs(self.y - self.targetY) > 8) { // Increased from 8 to 20 for more climbing distance if (self.y > self.targetY) { self.y -= self.climbSpeed; } else { self.y += self.climbSpeed; } // Ensure player doesn't go beyond terrain boundaries while climbing self.y = Math.max(100, Math.min(2632, self.y)); } else { // Snap exactly to target platform position self.y = self.targetY; self.isClimbing = false; // Clear any movement flags to prevent continued movement moveUp = false; moveDown = false; } } else { // Player can now climb ladders freely with hold-to-move controls // No automatic climbing logic needed here } }; return self; }); var Star = Container.expand(function () { var self = Container.call(this); var starGraphics = self.attachAsset('star', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 30; self.targetX = 0; self.targetY = 0; self.active = true; self.shootAt = function (targetX, targetY) { self.targetX = targetX; self.targetY = targetY; // Calculate distance for animation duration var distance = Math.sqrt(Math.pow(targetX - self.x, 2) + Math.pow(targetY - self.y, 2)); var duration = distance * 3; // Adjust speed by changing multiplier // Use tween to animate star to target tween(self, { x: targetX, y: targetY, rotation: Math.PI * 4 }, { duration: duration, easing: tween.linear, onFinish: function onFinish() { self.active = false; } }); }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87CEEB }); /**** * Game Code ****/ // Game state variables var currentLevel = 1; var coinsCollected = 0; var totalCoins = 5; var platforms = []; var ladders = []; var coins = []; var enemies = []; var stars = []; var player; // Platform positions (central hub + 4 outer platforms in 2x2 grid) var platformPositions = [{ x: 1024, y: 1366 }, // Center platform { x: 524, y: 922 }, // Top-left { x: 1524, y: 922 }, // Top-right { x: 524, y: 1800 }, // Bottom-left { x: 1524, y: 1800 } // Bottom-right ]; // Add background var background = game.attachAsset('background1', { anchorX: 0, anchorY: 0, x: 0, y: 0 }); // Create platforms for (var i = 0; i < platformPositions.length; i++) { var platform = new Platform(); platform.x = platformPositions[i].x; platform.y = platformPositions[i].y; platforms.push(platform); game.addChild(platform); } // Create ladders connecting platforms var ladderConnections = [{ from: 0, to: 1 }, // Center to top-left { from: 0, to: 2 }, // Center to top-right { from: 0, to: 3 }, // Center to bottom-left { from: 0, to: 4 } // Center to bottom-right ]; for (var i = 0; i < ladderConnections.length; i++) { var connection = ladderConnections[i]; var fromPlatform = platforms[connection.from]; var toPlatform = platforms[connection.to]; var ladder = new Ladder(); ladder.x = (fromPlatform.x + toPlatform.x) / 2; ladder.y = (fromPlatform.y + toPlatform.y) / 2; ladders.push(ladder); game.addChild(ladder); } // Create coins on each platform for (var i = 0; i < platforms.length; i++) { var coin = new Coin(); coin.x = platforms[i].x; coin.y = platforms[i].y - 50; coin.originalY = coin.y; coins.push(coin); game.addChild(coin); } // Create player player = new Player(); player.x = platforms[0].x; // Start on center platform player.y = platforms[0].y; player.currentPlatform = 0; game.addChild(player); // Create enemies based on level function spawnEnemies() { // Clear existing enemies for (var i = 0; i < enemies.length; i++) { enemies[i].destroy(); } enemies = []; // Spawn exactly 4 enemies, one on each outer platform (excluding center platform at index 0) for (var i = 1; i < platforms.length; i++) { var enemy = new Enemy(); enemy.x = platforms[i].x; enemy.y = platforms[i].y; enemy.assignedPlatform = i; // Set platform boundaries to keep enemy confined to its platform enemy.platformBounds.left = platforms[i].x - 250; enemy.platformBounds.right = platforms[i].x + 250; enemy.platformBounds.top = platforms[i].y - 100; enemy.platformBounds.bottom = platforms[i].y + 50; enemies.push(enemy); game.addChild(enemy); } } // Initial enemy spawn spawnEnemies(); // Player health bar var playerHealthBarBg = LK.getAsset('healthBarBg', { anchorX: 0, anchorY: 0 }); playerHealthBarBg.x = 120; playerHealthBarBg.y = 20; LK.gui.topLeft.addChild(playerHealthBarBg); var playerHealthBar = LK.getAsset('healthBar', { anchorX: 0, anchorY: 0 }); playerHealthBar.x = 120; playerHealthBar.y = 20; LK.gui.topLeft.addChild(playerHealthBar); var healthText = new Text2('Health: 100/100', { size: 40, fill: 0xFFFFFF }); healthText.anchor.set(0, 0); healthText.x = 120; healthText.y = 50; LK.gui.topLeft.addChild(healthText); // Score display var scoreText = new Text2('Coins: 0/' + totalCoins, { size: 60, fill: 0xFFFFFF }); scoreText.anchor.set(0.5, 0); LK.gui.top.addChild(scoreText); // Level display var levelText = new Text2('Level: ' + currentLevel, { size: 50, fill: 0xFFFFFF }); levelText.anchor.set(1, 0); LK.gui.topRight.addChild(levelText); // Movement controls var moveLeft = false; var moveRight = false; var moveUp = false; var moveDown = false; // Touch controls game.down = function (x, y, obj) { // Use the x, y parameters directly as they are already in game coordinates var gamePos = { x: x, y: y }; // Calculate distances for both horizontal and vertical movement var horizontalDistance = Math.abs(gamePos.x - player.x); var verticalDistance = Math.abs(gamePos.y - player.y); // Reset all movement flags first moveLeft = false; moveRight = false; moveUp = false; moveDown = false; // Check for ladder climbing first - if near ladder, only allow vertical movement var nearLadder = false; for (var i = 0; i < ladders.length; i++) { var ladder = ladders[i]; // Much tighter detection - player must be very close to ladder to climb if (Math.abs(gamePos.x - ladder.x) < 40 && Math.abs(gamePos.y - ladder.y) < 60) { nearLadder = true; // Only vertical movement when near ladder if (gamePos.y < player.y - 30) { moveUp = true; } else if (gamePos.y > player.y + 30) { moveDown = true; } break; } } // If not near ladder, check for enemy shooting first, then movement if (!nearLadder) { // Check if tap is on an enemy var enemyClicked = false; for (var i = 0; i < enemies.length; i++) { var enemy = enemies[i]; var enemyDistance = Math.sqrt(Math.pow(gamePos.x - enemy.x, 2) + Math.pow(gamePos.y - enemy.y, 2)); if (enemyDistance < 80) { // Enemy click radius // Shoot at the clicked enemy if cooldown allows if (LK.ticks - player.lastShot > player.shootCooldown) { // Set facing direction based on enemy position if (enemy.x < player.x) { player.facingLeft = true; } else { player.facingLeft = false; } // Force immediate animation update to show correct facing direction player.updateAnimation(); var star = new Star(); star.x = player.x; star.y = player.y - 50; // Shoot from slightly above player star.shootAt(enemy.x, enemy.y); stars.push(star); game.addChild(star); player.lastShot = LK.ticks; LK.getSound('shoot').play(); } enemyClicked = true; break; } } // If no enemy was clicked, handle movement if (!enemyClicked) { if (horizontalDistance > verticalDistance) { // Horizontal movement takes priority if (gamePos.x < player.x - 50) { moveLeft = true; } else if (gamePos.x > player.x + 50) { moveRight = true; } } else { // Vertical movement takes priority if (gamePos.y < player.y - 50) { moveUp = true; } else if (gamePos.y > player.y + 50) { moveDown = true; } } } } }; game.up = function (x, y, obj) { moveLeft = false; moveRight = false; moveUp = false; moveDown = false; }; // Game update loop game.update = function () { // Handle player movement if (!player.isClimbing) { if (moveLeft) { player.x -= player.speed; // Set facing direction for movement player.facingLeft = true; // Force immediate animation update for direction change player.updateAnimation(); // Ensure player doesn't go beyond left boundary player.x = Math.max(20, player.x); } if (moveRight) { player.x += player.speed; // Set facing direction for movement player.facingLeft = false; // Force immediate animation update for direction change player.updateAnimation(); // Ensure player doesn't go beyond right boundary player.x = Math.min(2028, player.x); } if (moveUp) { player.y -= player.speed; // Ensure player doesn't go beyond top boundary player.y = Math.max(100, player.y); } if (moveDown) { player.y += player.speed; // Ensure player doesn't go beyond bottom boundary player.y = Math.min(2632, player.y); } // Platform boundary checking - keep player on current platform unless using ladder if (player.currentPlatform !== null && !player.isClimbing) { var currentPlatform = platforms[player.currentPlatform]; // Horizontal platform boundaries - reduced from 200 to 150 to allow ladder access var platformLeft = currentPlatform.x - 150; var platformRight = currentPlatform.x + 150; // Vertical platform boundaries - made much thinner var platformTop = currentPlatform.y - 30; var platformBottom = currentPlatform.y + 30; // Check if player is trying to move outside platform boundaries if (player.x < platformLeft || player.x > platformRight || player.y < platformTop || player.y > platformBottom) { // Only allow if player is near a ladder - increased detection range var nearLadder = false; for (var ladderIndex = 0; ladderIndex < ladders.length; ladderIndex++) { var ladder = ladders[ladderIndex]; if (Math.abs(player.x - ladder.x) < 250 && Math.abs(player.y - ladder.y) < 300) { nearLadder = true; break; } } // If not near ladder, constrain to platform with thinner boundaries if (!nearLadder) { player.x = Math.max(platformLeft, Math.min(platformRight, player.x)); player.y = Math.max(platformTop, Math.min(platformBottom, player.y)); } } } // Allow player to move between platforms by updating current platform based on proximity if (player.currentPlatform !== null) { // Check if player is close to any platform to update current platform var closestPlatformIndex = 0; var closestDistance = Math.abs(player.y - platforms[0].y); for (var i = 1; i < platforms.length; i++) { var distance = Math.abs(player.y - platforms[i].y); if (distance < closestDistance && Math.abs(player.x - platforms[i].x) < 200) { closestDistance = distance; closestPlatformIndex = i; } } // Update current platform if player is close enough to a different platform - thinner detection if (Math.abs(player.x - platforms[closestPlatformIndex].x) < 200 && Math.abs(player.y - platforms[closestPlatformIndex].y) < 40) { player.currentPlatform = closestPlatformIndex; } } // Keep player within screen bounds player.x = Math.max(20, Math.min(2028, player.x)); player.y = Math.max(100, Math.min(2632, player.y)); // Additional check: if player is climbing and goes out of bounds, stop climbing if (player.isClimbing && (player.y <= 100 || player.y >= 2632)) { player.isClimbing = false; moveUp = false; moveDown = false; // Snap to nearest platform var nearestPlatform = platforms[0]; var nearestDistance = Math.abs(player.y - nearestPlatform.y); for (var i = 1; i < platforms.length; i++) { var distance = Math.abs(player.y - platforms[i].y); if (distance < nearestDistance) { nearestDistance = distance; nearestPlatform = platforms[i]; player.currentPlatform = i; } } player.y = nearestPlatform.y; } // Check for ladder climbing with hold-to-move if (moveUp || moveDown) { for (var i = 0; i < ladders.length; i++) { var ladder = ladders[i]; // Calculate ladder boundaries (top and bottom edges) var ladderTop = ladder.y - 100; // Half of ladder height (200/2) var ladderBottom = ladder.y + 100; // Half of ladder height (200/2) // Player must be very close to ladder horizontally AND within ladder vertical boundaries if (Math.abs(player.x - ladder.x) < 50 && player.y >= ladderTop - 20 && player.y <= ladderBottom + 20) { // Set climbing state for animation player.isClimbing = true; // Snap to ladder horizontally player.x = ladder.x; // Direct climbing movement based on held direction if (moveUp) { // Only move up if not at top edge of ladder if (player.y > ladderTop) { player.y -= player.climbSpeed; // Stop if reached ladder top if (player.y <= ladderTop) { player.y = ladderTop; player.isClimbing = false; moveUp = false; } } else { // Already at ladder top, stop climbing player.isClimbing = false; moveUp = false; } // Stop climbing if reached top of screen if (player.y <= 100) { player.y = 100; player.isClimbing = false; moveUp = false; } } else if (moveDown) { // Only move down if not at bottom edge of ladder if (player.y < ladderBottom) { player.y += player.climbSpeed; // Stop if reached ladder bottom if (player.y >= ladderBottom) { player.y = ladderBottom; player.isClimbing = false; moveDown = false; } } else { // Already at ladder bottom, stop climbing player.isClimbing = false; moveDown = false; } // Ensure doesn't go below screen player.y = Math.min(2632, player.y); } // Update current platform based on proximity while climbing var closestPlatformIndex = 0; var closestDistance = Math.abs(player.y - platforms[0].y); for (var j = 1; j < platforms.length; j++) { var distance = Math.abs(player.y - platforms[j].y); if (distance < closestDistance && Math.abs(platforms[j].x - ladder.x) < 120) { closestDistance = distance; closestPlatformIndex = j; } } // Stop climbing and snap to platform if on platform level if (closestDistance < 40) { player.y = platforms[closestPlatformIndex].y; player.currentPlatform = closestPlatformIndex; player.isClimbing = false; // Stop movement when reaching platform moveUp = false; moveDown = false; } break; } else if (player.isClimbing) { // Player has moved outside ladder boundaries while climbing, stop climbing player.isClimbing = false; moveUp = false; moveDown = false; } } } else { // Not climbing if not moving up or down player.isClimbing = false; } } // Check coin collection for (var i = 0; i < coins.length; i++) { var coin = coins[i]; if (!coin.collected && player.intersects(coin)) { coin.collected = true; coin.alpha = 0; coinsCollected++; LK.setScore(coinsCollected); scoreText.setText('Coins: ' + coinsCollected + '/' + totalCoins); LK.getSound('coinCollect').play(); // Check win condition if (coinsCollected >= totalCoins) { LK.showYouWin(); } } } // Update player health bar function updatePlayerHealthBar() { var healthPercent = player.health / player.maxHealth; playerHealthBar.width = 200 * healthPercent; if (healthPercent > 0.6) { playerHealthBar.tint = 0x00ff00; } else if (healthPercent > 0.3) { playerHealthBar.tint = 0xffff00; } else { playerHealthBar.tint = 0xff0000; } healthText.setText('Health: ' + player.health + '/' + player.maxHealth); } // Update and check star collisions for (var i = stars.length - 1; i >= 0; i--) { var star = stars[i]; // Check star-enemy collisions var hitEnemy = false; for (var j = 0; j < enemies.length; j++) { var enemy = enemies[j]; if (star.active && star.intersects(enemy)) { // Damage enemy enemy.health -= 25; enemy.updateHealthBar(); // Flash enemy red tween(enemy, { tint: 0xFF0000 }, { duration: 200, onFinish: function onFinish() { tween(enemy, { tint: 0xFFFFFF }, { duration: 200 }); } }); LK.getSound('enemyHit').play(); hitEnemy = true; // Remove enemy if health <= 0 if (enemy.health <= 0) { enemy.destroy(); enemies.splice(j, 1); j--; // Adjust index after removal } break; } } // Remove star if hit enemy or inactive if (hitEnemy || !star.active) { tween.stop(star); // Stop any ongoing tween star.destroy(); stars.splice(i, 1); } } // Check enemy collisions for (var i = 0; i < enemies.length; i++) { var enemy = enemies[i]; if (player.intersects(enemy)) { // Initialize lastHit if not exists if (enemy.lastHit === undefined) { enemy.lastHit = 0; } // Only damage if enough time has passed (1 second = 60 ticks) if (LK.ticks - enemy.lastHit > 60) { player.health -= 10; enemy.lastHit = LK.ticks; updatePlayerHealthBar(); LK.getSound('enemyHit').play(); LK.effects.flashScreen(0xff0000, 500); if (player.health <= 0) { LK.showGameOver(); } } } // Update enemy health bars enemy.updateHealthBar(); } // Level progression (spawn more enemies every 30 seconds) if (LK.ticks % (60 * 30) === 0 && coinsCollected < totalCoins) { currentLevel++; levelText.setText('Level: ' + currentLevel); spawnEnemies(); } };
===================================================================
--- original.js
+++ change.js
@@ -615,13 +615,13 @@
// Check for ladder climbing with hold-to-move
if (moveUp || moveDown) {
for (var i = 0; i < ladders.length; i++) {
var ladder = ladders[i];
- // Player must be very close to ladder to climb (within 50 pixels horizontally)
- if (Math.abs(player.x - ladder.x) < 50) {
- // Calculate ladder boundaries (top and bottom edges)
- var ladderTop = ladder.y - 100; // Half of ladder height (200/2)
- var ladderBottom = ladder.y + 100; // Half of ladder height (200/2)
+ // Calculate ladder boundaries (top and bottom edges)
+ var ladderTop = ladder.y - 100; // Half of ladder height (200/2)
+ var ladderBottom = ladder.y + 100; // Half of ladder height (200/2)
+ // Player must be very close to ladder horizontally AND within ladder vertical boundaries
+ if (Math.abs(player.x - ladder.x) < 50 && player.y >= ladderTop - 20 && player.y <= ladderBottom + 20) {
// Set climbing state for animation
player.isClimbing = true;
// Snap to ladder horizontally
player.x = ladder.x;
@@ -684,8 +684,13 @@
moveUp = false;
moveDown = false;
}
break;
+ } else if (player.isClimbing) {
+ // Player has moved outside ladder boundaries while climbing, stop climbing
+ player.isClimbing = false;
+ moveUp = false;
+ moveDown = false;
}
}
} else {
// Not climbing if not moving up or down
coin, hd colors. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Scary blue background of forest, moon, small owl on tree, HD colors. In-Game asset. 2d. High contrast. No shadows
Scary graveyard with different things around it scary things spiders, web spider, skulls, swords, grass, trees.. In-Game asset. 2d. High contrast. No shadows
Scary wallpaper without characters, with all colors, HD colors. In-Game asset. 3d. High contrast. No shadows