User prompt
Make more ladders above the bottom ladders till reach the top edges of the top platforms
Code edit (1 edits merged)
Please save this source code
User prompt
move player to above the platform top edge, and limit its movement by distance of the platforms horizontal edges ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
make horizontal movsment only and set player position above the platform that is in the middle of the other 4 platforms like you did with coins and enemies ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
make smooth movement for player to the cursor position ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
change movement of the player by click the direction to move it to it, rest player position above the platform
User prompt
change movement of the player by click the direction to move it to it, rest player position above the platform
User prompt
move enemies to walk above the platforms not in their middle! so the player make it above the middle platform
User prompt
remove the top ladders, make the enemies walk above the platforms left and right and so the coins above the platforms. make the ninja can move horizontally left and right only on the above platforms.
User prompt
change to hold on player and drag to move it, remove climbing
User prompt
Remove what's doing the continuous climbing let it only on the size of the ladder no more then its top or bottom edges!
User prompt
Fix the vertical movement of climbing is climbing up only on any ladder!
User prompt
Add direction-based flipping logic to player class using scaleX property, and for its frames of moving and shooting
User prompt
Do the same for enemies are not fliping !
User prompt
Change this code to be for ninja animations to flip by direction, movement assets Ninja1 ninja2 ninja3 ninja4, and for shooting is ninjashooting asset try to do it by this code: // Flip player based on movement direction if (self.speed > 0) { // Moving right, face right self.scaleX = 1; } else if (self.speed < 0) { // Moving left, face left (flip horizontally) self.scaleX = -1; } }; return self;
User prompt
when hold down move player down on ladder not up!
User prompt
Make the player climb down when going down to ladder its climbing up!
User prompt
Flip player asset and its ninja1 ninja2 ninja3 ninja4 if mouse button clicked on its left
User prompt
Flip ninja frames if moving to the left
User prompt
If enemies moving horizontally to the right flip their images to the right and if they are moving to the left flip their images to the left
User prompt
Flip enemies images based on their direction movement
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
/**** * 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 () { // Track last direction for flipping detection if (self.lastDirection === undefined) { self.lastDirection = self.direction; } // Horizontal movement only 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; } // Flip enemy based on movement direction if (self.direction > 0) { // Moving right, face right enemyGraphics.scaleX = 1; } else if (self.direction < 0) { // Moving left, face left (flip horizontally) enemyGraphics.scaleX = -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.currentPlatform = null; 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.shootFrame = 'Ninjashooting'; // Track animation state changes self.lastAsset = null; self.lastFlip = null; self.updateAnimation = function () { var currentAsset = ''; if (self.isShooting) { currentAsset = self.shootFrame; } else if (self.isMoving) { // Walking animation when moving var walkFrameIndex = Math.floor(self.animationFrame / self.animationSpeed) % self.walkFrames.length; currentAsset = self.walkFrames[walkFrameIndex]; } else { // Default standing pose - show player asset when not moving currentAsset = 'player'; } // Only update graphics if asset changed if (!self.lastAsset || self.lastAsset !== currentAsset) { // Remove old graphics if exists if (playerGraphics) { self.removeChild(playerGraphics); } // Create new graphics playerGraphics = self.attachAsset(currentAsset, { anchorX: 0.5, anchorY: 1 }); // Store current state self.lastAsset = currentAsset; } // Flip player based on facing direction for all animation frames if (self.facingLeft) { // Facing left, flip horizontally playerGraphics.scaleX = -1; } else { // Facing right, normal orientation playerGraphics.scaleX = 1; } }; self.update = function () { // Check if player is moving 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.isMoving = true; // Determine facing direction for any horizontal movement if (horizontalMovement) { if (self.x < self.lastX) { if (!self.facingLeft) { self.facingLeft = true; self.updateAnimation(); } } else if (self.x > self.lastX) { if (self.facingLeft) { self.facingLeft = false; self.updateAnimation(); } } } } 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(); }; 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 - only bottom connections var ladderConnections = [{ 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 above platforms for (var i = 0; i < platforms.length; i++) { var coin = new Coin(); coin.x = platforms[i].x; coin.y = platforms[i].y - 250; // Position coins well above platforms 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 - 200; // Position above the top edge of middle platform 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 - 200; // Position above platform surface enemy.assignedPlatform = i; // Set platform boundaries to keep enemy confined to its platform horizontally only enemy.platformBounds.left = platforms[i].x - 350; enemy.platformBounds.right = platforms[i].x + 350; 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); // Click-to-move 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 }; // Check if tap is on an enemy for shooting 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 var shouldFaceLeft = enemy.x < player.x; if (player.facingLeft !== shouldFaceLeft) { player.facingLeft = shouldFaceLeft; 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, move player to clicked position if (!enemyClicked) { // Set facing direction based on click position if (gamePos.x < player.x) { // Clicked left of player - face left and move left player.facingLeft = true; player.updateAnimation(); } else if (gamePos.x > player.x) { // Clicked right of player - face right and move right player.facingLeft = false; player.updateAnimation(); } // Calculate target position with bounds checking - horizontal movement only // Limit movement to middle platform horizontal edges (platform width is 900, so +/- 450 from center) var platformLeft = platforms[0].x - 450; var platformRight = platforms[0].x + 450; var targetX = Math.max(platformLeft, Math.min(platformRight, gamePos.x)); // Keep player above middle platform top edge - no vertical movement var targetY = platforms[0].y - 200; // Calculate movement distance for duration var moveDistance = Math.abs(targetX - player.x); var duration = moveDistance * 3; // Adjust speed by changing multiplier // Stop any existing movement tween tween.stop(player, { x: true }); // Smooth horizontal movement to target position tween(player, { x: targetX }, { duration: duration, easing: tween.easeOut }); } }; // Game update loop game.update = function () { // 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
@@ -328,9 +328,9 @@
}
// Create player
player = new Player();
player.x = platforms[0].x; // Start on center platform
-player.y = platforms[0].y; // Position above middle platform like coins and enemies
+player.y = platforms[0].y - 200; // Position above the top edge of middle platform
player.currentPlatform = 0;
game.addChild(player);
// Create enemies based on level
function spawnEnemies() {
@@ -438,11 +438,14 @@
player.facingLeft = false;
player.updateAnimation();
}
// Calculate target position with bounds checking - horizontal movement only
- var targetX = Math.max(40, Math.min(2008, gamePos.x));
- // Keep player on middle platform (index 0) - no vertical movement
- var targetY = platforms[0].y;
+ // Limit movement to middle platform horizontal edges (platform width is 900, so +/- 450 from center)
+ var platformLeft = platforms[0].x - 450;
+ var platformRight = platforms[0].x + 450;
+ var targetX = Math.max(platformLeft, Math.min(platformRight, gamePos.x));
+ // Keep player above middle platform top edge - no vertical movement
+ var targetY = platforms[0].y - 200;
// Calculate movement distance for duration
var moveDistance = Math.abs(targetX - player.x);
var duration = moveDistance * 3; // Adjust speed by changing multiplier
// Stop any existing movement tween
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