User prompt
remove pixels 200x200px for enemies movements
User prompt
let enemies digg terrain like player and if they find treasure they mine it to shot with it.
User prompt
fix enemies digging not working well they walk through the terrain but no pixels removed!
User prompt
Please fix the bug: 'Uncaught TypeError: LK.showLeaderboard is not a function' in or related to this line: 'LK.showLeaderboard();' Line Number: 817
User prompt
add HighScore button to the intro beside start game button from the right
User prompt
show enemies front of terrain to be seen on the screen.
User prompt
The enemies not digging the terrain by 200x200 like the player! Change enemies can shot only if collect a treasure.
User prompt
let the enemies can dig the terrain too as the player.
User prompt
let the shot of enemies be the same as treasure image of the area of 5000 miles. Make the enemies can dig terrain as the player. *Don't move the screen when enemies goes to collect treasures, move it only by player, if enemies have no treasures on the screen to shot with they go to player directly and kill it.
User prompt
let the shot of enemies be the same as treasure image of the area of 5000 miles. Make the enemies can dig terrain as the player. *Don't move the screen when enemies goes to collect treasures, move it only by player, if enemies have no treasures on the screen to shot with they go to player directly and kill it.
User prompt
Make the enemies can dig as the player. flip image of enemies and player from the middle of the screen if on the left or on the right side.
User prompt
*Add enemies assets of each area to the game. *They can collect same as player the ores and shoot you a shot size 50x50. *Shot distance 800px. *Enemies can collect ores = treasures from their area of 5000 miles only, so if new area started they can't walk on it but they can still appearing and collecting from their area till it goes up to the top of the screen.
User prompt
change player and ores and pixels of terrain from 100 to 200
User prompt
Remove diagonal move for the player let only x y movements
User prompt
Remove diagonal move for the player let only x y movements
User prompt
Slow down the moving screen when digging ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Slow down the moving screen when digging ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
auto fix IntroBackground
Code edit (1 edits merged)
Please save this source code
User prompt
resize it as the screen its not adjusted correctly!
User prompt
scale it to 2048x2732 inside screen boundaries
User prompt
center the background of the intro!
User prompt
make the Introbackground image same as the screen to be 2048x2732
User prompt
Introbackground not fitted into the screen
User prompt
fix the errors!
/**** * Plugins ****/ var storage = LK.import("@upit/storage.v1"); var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var Player = Container.expand(function () { var self = Container.call(this); var playerGraphics = self.attachAsset('player', { anchorX: 0.5, anchorY: 0.5 }); playerGraphics.alpha = 1; return self; }); var StoneBlock = Container.expand(function () { var self = Container.call(this); self.blockType = 'stone'; var stoneGraphics = self.attachAsset('stone', { anchorX: 0, anchorY: 0 }); self.mine = function () { return false; // Stone blocks cannot be mined }; return self; }); var TerrainBlock = Container.expand(function () { var self = Container.call(this); self.blockType = 'terrain'; self.hasTreasure = false; self.treasureType = null; self.treasureGraphics = null; var blockGraphics = self.attachAsset('terrain', { anchorX: 0, anchorY: 0 }); self.graphics = blockGraphics; self.setTreasure = function (type) { self.hasTreasure = true; self.treasureType = type; // Create and display the actual treasure image if (type) { self.treasureGraphics = self.attachAsset(type, { anchorX: 0.5, anchorY: 0.5, x: blockSize / 2, y: blockSize / 2, scaleX: 0.8, scaleY: 0.8 }); } }; self.mine = function () { if (self.blockType === 'stone') { return false; } self.visible = false; if (self.treasureGraphics) { self.treasureGraphics.visible = false; } return true; }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ game.setBackgroundColor(0x000000); var blockSize = 100; var gridWidth = Math.floor(2048 / blockSize); var gridHeight = Math.floor(2732 / blockSize); var stoneWallWidth = 1; var mineableStartX = stoneWallWidth; var mineableEndX = gridWidth - stoneWallWidth; var terrain = []; var player; var depth = 0; var score = 0; var isDragging = false; var targetX = null; var targetY = null; var isScrolling = false; // Flag to indicate if a scroll animation is in progress var playerSpeed = 40; // Pixels per frame var scrollAnimationDuration = 500; // Duration for scroll animation in milliseconds var treasureCounts = { bronze: 0, silver: 0, gold: 0, diamond: 0, crystal: 0 }; // Game state var gameStarted = false; var introContainer = null; function movePlayerTowardsTarget() { if (targetX === null || targetY === null || !player) { return; } // Move player towards target position, restricting to X or Y axis per update var dx = targetX - player.x; var dy = targetY - player.y; if (dx === 0 && dy === 0) { // Player is already at the target, no movement calculation needed. // The mineBlock() call after this block will handle mining at the current position. } else if (Math.abs(dx) > Math.abs(dy)) { // Prioritize horizontal movement if (Math.abs(dx) > playerSpeed) { player.x += Math.sign(dx) * playerSpeed; } else { player.x = targetX; // Snap to target X } } else { // Prioritize vertical movement if |dy| >= |dx| (this includes dx === 0, or |dx| === |dy|) if (Math.abs(dy) > playerSpeed) { player.y += Math.sign(dy) * playerSpeed; } else { player.y = targetY; // Snap to target Y } } // Mine at player position mineBlock(player.x, player.y); } // Create score text first (will be at the back) var scoreText = new Text2('Score: 0', { size: 60, fill: 0xFFFFFF }); scoreText.anchor.set(0.5, 0); scoreText.y = 90; scoreText.visible = false; // Hide initially LK.gui.top.addChild(scoreText); // Create depth text second (will be in the middle) var depthText = new Text2('Depth: 0m', { size: 60, fill: 0xFFFFFF }); depthText.anchor.set(0.5, 0); depthText.y = 30; depthText.visible = false; // Hide initially LK.gui.top.addChild(depthText); // Create treasure count displays var treasureTexts = {}; var treasureTypes = ['bronze', 'silver', 'gold', 'diamond', 'crystal']; var treasureColors = { bronze: 0xCD7F32, silver: 0xC0C0C0, gold: 0xFFD700, diamond: 0x00FFFF, crystal: 0xFF69B4 }; // Create container for treasure counts var treasureContainer = new Container(); treasureContainer.y = -20; // Move to the very top edge treasureContainer.visible = false; // Hide initially // Create text for each treasure type var xOffset = -500; for (var i = 0; i < treasureTypes.length; i++) { var type = treasureTypes[i]; var text = new Text2(type.charAt(0).toUpperCase() + type.slice(1) + ': 0', { size: 50, fill: treasureColors[type] }); text.anchor.set(0.5, 0); text.x = xOffset + i * 250; treasureContainer.addChild(text); treasureTexts[type] = text; } // Add container to GUI after all texts are created to ensure it appears on top LK.gui.top.addChild(treasureContainer); function getTreasureType(currentDepth) { // Each 5000 miles (250000 pixels) has a specific treasure type var depthInMiles = Math.floor(currentDepth / 50); // Convert pixels to miles var treasureZone = Math.floor(depthInMiles / 5000); // Which 5000-mile zone var rand = Math.random(); var spawnChance = 0.1; // 10% chance to spawn treasure if (rand > spawnChance) { return null; // No treasure } // Make treasure zones cycle every 5 zones (25000 miles) var cycledZone = treasureZone % 5; // Return specific treasure based on cycled zone switch (cycledZone) { case 0: // Bronze zone return 'bronze'; case 1: // Silver zone return 'silver'; case 2: // Gold zone return 'gold'; case 3: // Diamond zone return 'diamond'; case 4: // Crystal zone return 'crystal'; } } function generateRow(y) { var row = []; for (var x = 0; x < gridWidth; x++) { var block; if (x < mineableStartX || x >= mineableEndX) { block = new StoneBlock(); } else { block = new TerrainBlock(); var treasure = getTreasureType(depth + y * blockSize); if (treasure) { block.setTreasure(treasure); } } block.x = x * blockSize; block.y = y * blockSize; game.addChild(block); row.push(block); } return row; } function initializeTerrain() { terrain = []; for (var y = 0; y < gridHeight + 1; y++) { terrain.push(generateRow(y)); } } function completeScrollCleanup() { // The blocks in terrain[0] are the ones that moved off-screen and whose tweens just finished. var topRowToDestroy = terrain[0]; for (var x = 0; x < topRowToDestroy.length; x++) { var block = topRowToDestroy[x]; // Destroy treasure graphics if they exist if (block.treasureGraphics) { block.treasureGraphics.destroy(); } block.destroy(); // This removes the container and its children from the stage } terrain.shift(); // Now remove the row from our logical terrain array depth += blockSize; terrain.push(generateRow(gridHeight)); // Add new row at the bottom, its y positions are set in generateRow depthText.setText('Depth: ' + Math.floor(depth / 50) + 'm'); isScrolling = false; // Allow new scrolls } function scrollTerrain() { if (isScrolling) { return; // Don't start a new scroll if one is already in progress } isScrolling = true; var tweensCompleted = 0; var totalTweens = 0; // Calculate total number of blocks to be tweened for (var y_coord = 0; y_coord < terrain.length; y_coord++) { totalTweens += terrain[y_coord].length; } if (totalTweens === 0) { isScrolling = false; // Should not happen in normal gameplay return; } // Animate each block for (var y_anim = 0; y_anim < terrain.length; y_anim++) { for (var x_anim = 0; x_anim < terrain[y_anim].length; x_anim++) { var blockToAnimate = terrain[y_anim][x_anim]; tween(blockToAnimate, { y: blockToAnimate.y - blockSize }, { duration: scrollAnimationDuration, easing: tween.linear, // Using linear for a steady scroll onFinish: function onFinish() { tweensCompleted++; if (tweensCompleted === totalTweens) { completeScrollCleanup(); // Call cleanup once all tweens are done } } }); } } } function mineBlock(worldX, worldY) { var gridX = Math.floor(worldX / blockSize); var gridY = Math.floor(worldY / blockSize); if (gridX < 0 || gridX >= gridWidth || gridY < 0 || gridY >= gridHeight) { return; } // Check if terrain row exists before accessing if (!terrain[gridY]) { return; } var block = terrain[gridY][gridX]; if (!block || !block.visible) { return; } if (block.mine()) { if (block.hasTreasure) { var treasureValue = 0; switch (block.treasureType) { case 'bronze': treasureValue = 10; break; case 'silver': treasureValue = 25; break; case 'gold': treasureValue = 50; break; case 'diamond': treasureValue = 100; break; case 'crystal': treasureValue = 150; break; } score += treasureValue; LK.setScore(score); scoreText.setText('Score: ' + score); treasureCounts[block.treasureType]++; treasureTexts[block.treasureType].setText(block.treasureType.charAt(0).toUpperCase() + block.treasureType.slice(1) + ': ' + treasureCounts[block.treasureType]); } if (gridY > gridHeight / 2) { scrollTerrain(); } } } // Create intro screen function createIntroScreen() { introContainer = new Container(); // Add intro background - since we're adding to GUI, we need different scaling approach var introBackground = introContainer.attachAsset('IntroBackground', { anchorX: 0.5, anchorY: 0.5, x: 0, y: 0 }); // Since we're adding to GUI.center, we need to scale based on the actual GUI dimensions // The GUI system automatically scales, so we need to set the background to fill the screen // by making it large enough to cover the viewport var assetWidth = introBackground.width; var assetHeight = introBackground.height; // Defensively check for valid, positive asset dimensions before calculating scale if (assetWidth > 0 && assetHeight > 0) { // For GUI elements, we want to scale to fit the entire image within the screen (contain/fit) // Since GUI.center is already centered, this will ensure the image is centered and fully visible. var scaleX = 2048 / assetWidth; var scaleY = 2732 / assetHeight; // Use the smaller scale to ensure the entire image fits within screen boundaries var scale = Math.min(scaleX, scaleY); introBackground.scale.set(scale, scale); // Position is already centered at 0,0 in the GUI.center container } else { // If asset dimensions are invalid (e.g., zero or negative), // set scale to zero to effectively hide it and log a warning. introBackground.scale.set(0, 0); console.log("Warning: IntroBackground asset has invalid dimensions (width: " + assetWidth + ", height: " + assetHeight + "). Cannot scale appropriately."); } // Add start button var startButton = introContainer.attachAsset('Startbutton', { anchorX: 0.5, anchorY: 0.5, x: 0, y: 400, // Lowered by 200px (was 200) scaleX: 4, scaleY: 1.5 }); // Make button interactive startButton.interactive = true; // Add button press handler startButton.down = function () { startGame(); }; // Add blinking animation to the start button tween(startButton, { alpha: 0.5 }, { duration: 800, // Duration of the blink easing: tween.linear, onFinish: function onFinish() { tween(startButton, { alpha: 1 }, { duration: 800, easing: tween.linear, onFinish: function onFinish() { // Loop the animation tween(startButton, { alpha: 0.5 }, { duration: 800, easing: tween.linear, onFinish: arguments.callee }); } }); } }); // Add to GUI center instead of game LK.gui.center.addChild(introContainer); } function startGame() { if (gameStarted) { return; } // Set gameStarted immediately to prevent multiple calls gameStarted = true; // Remove intro screen if (introContainer) { introContainer.destroy(); introContainer = null; } // Show game UI elements scoreText.visible = true; depthText.visible = true; treasureContainer.visible = true; // Initialize game initializeTerrain(); player = game.addChild(new Player()); player.x = 1024; player.y = 200; } // Create intro screen instead of starting game immediately createIntroScreen(); game.down = function (x, y, obj) { if (!gameStarted) { return; } isDragging = true; // Clamp target position to game boundaries targetX = Math.max(0, Math.min(x, 2048)); targetY = Math.max(0, Math.min(y, 2732)); }; game.move = function (x, y, obj) { if (!gameStarted) { return; } // Clamp target position to game boundaries targetX = Math.max(0, Math.min(x, 2048)); targetY = Math.max(0, Math.min(y, 2732)); }; game.up = function (x, y, obj) { if (!gameStarted) { return; } isDragging = false; }; game.update = function () { if (!gameStarted) { return; } if (player && targetX !== null && targetY !== null) { movePlayerTowardsTarget(); } };
===================================================================
--- original.js
+++ change.js
@@ -107,40 +107,30 @@
function movePlayerTowardsTarget() {
if (targetX === null || targetY === null || !player) {
return;
}
+ // Move player towards target position, restricting to X or Y axis per update
var dx = targetX - player.x;
var dy = targetY - player.y;
- // If already at target, mine and return
if (dx === 0 && dy === 0) {
- mineBlock(player.x, player.y);
- return;
- }
- // Determine movement for this step: only X or only Y.
- // Prioritize the axis with the larger absolute difference.
- // If differences are equal, X movement is prioritized.
- if (Math.abs(dx) >= Math.abs(dy)) {
- // Prioritize X movement
- if (dx !== 0) {
- // Check if horizontal movement is needed
- if (Math.abs(dx) > playerSpeed) {
- player.x += Math.sign(dx) * playerSpeed;
- } else {
- player.x = targetX; // Snap to targetX
- }
+ // Player is already at the target, no movement calculation needed.
+ // The mineBlock() call after this block will handle mining at the current position.
+ } else if (Math.abs(dx) > Math.abs(dy)) {
+ // Prioritize horizontal movement
+ if (Math.abs(dx) > playerSpeed) {
+ player.x += Math.sign(dx) * playerSpeed;
+ } else {
+ player.x = targetX; // Snap to target X
}
} else {
- // Vertical distance is strictly greater (Math.abs(dx) < Math.abs(dy)), prioritize Y movement
- if (dy !== 0) {
- // Check if vertical movement is needed
- if (Math.abs(dy) > playerSpeed) {
- player.y += Math.sign(dy) * playerSpeed;
- } else {
- player.y = targetY; // Snap to targetY
- }
+ // Prioritize vertical movement if |dy| >= |dx| (this includes dx === 0, or |dx| === |dy|)
+ if (Math.abs(dy) > playerSpeed) {
+ player.y += Math.sign(dy) * playerSpeed;
+ } else {
+ player.y = targetY; // Snap to target Y
}
}
- // Mine at the new player position
+ // Mine at player position
mineBlock(player.x, player.y);
}
// Create score text first (will be at the back)
var scoreText = new Text2('Score: 0', {
Same ninja character, with pack of all colors
Same ninja character, with pack of colors silver,gold,diamond,pink crystal
Same ninja character, with silver color
Same ninja character, with gold color
Same ninja character, with diamond color
Same ninja character, with crystal pink color
Pack of crystals, pink color In-Game asset. 2d. High contrast. No shadows
same image but add beside the character +1 with green color.
Same image of ninja with dig machine but with different colors. HD colors. yellow
Same image of ninja with dig machine but with different colors. HD colors. red
Same image of ninja with dig machine but with different colors. HD colors. blue
Same image of ninja with dig machine but with different colors. HD colors. black ninja
Same image of ninja with dig machine but with different colors. HD colors. green
Playerdiggingsound1
Sound effect
Enemydiggingsound1
Sound effect
Gamemusic1
Music
CollectedTreasuresound1
Sound effect
Startsound1
Sound effect
Intromusic1
Music
PlayerShotSound
Sound effect
EnemyShotshound1
Sound effect
Lifesound1
Sound effect
enemyshotsound1
Sound effect
playershotsound1
Sound effect