User prompt
Remove the level text
User prompt
Move the countdown to the left side
User prompt
remove goal text
User prompt
remove score board
User prompt
gold biraz daha yavaş çeksin
User prompt
goal yazısını ekranın sol tarafına al
User prompt
reduce the number in the upper parts
User prompt
reduce the number slightly
User prompt
also place at the bottom of the screen
User prompt
place in various places on the screen target box
User prompt
more target box
User prompt
Increase the number of pigs and get them in most of the screen
User prompt
Let the pig's score be 10
User prompt
Let the money value of the pigs be 5
User prompt
Let the financial value of targetbox be 2
User prompt
get bags on the screen
User prompt
the bag should not be on the hook
User prompt
keep bags on display
User prompt
drop the bag from the hook
User prompt
The torba needs to be held with a hook
User prompt
place the torba in better places
User prompt
add bag to different parts of the screen
User prompt
use level sound when leveling up
User prompt
remove grab sound
User prompt
Use money sound when pulling up captured objects
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ // Claw class var Claw = Container.expand(function () { var self = Container.call(this); // Arm var arm = self.attachAsset('clawArm', { anchorX: 0.5, anchorY: 0, x: 0, y: 0 }); // Claw head var head = self.attachAsset('clawHead', { anchorX: 0.5, anchorY: 0, x: 0, y: arm.height }); // State self.swingAngle = 0; // in radians self.swingDir = 1; // 1 or -1 self.swingSpeed = 0.025; // radians per tick self.swingMax = Math.PI / 3; // 60 deg left/right self.state = 'swing'; // 'swing', 'extend', 'retract', 'grabbed' self.length = arm.height; // current arm length self.baseLength = arm.height; self.maxLength = GAME_HEIGHT - 100; // how far the claw can extend (let rope go to bottom) self.speed = 32; // pixels per tick when extending self.retractSpeed = 32; // default retract speed self.grabbedObj = null; // reference to grabbed object // Update arm and head positions based on length and angle self.updateClaw = function () { var dx = Math.sin(self.swingAngle) * self.length; var dy = Math.cos(self.swingAngle) * self.length; arm.rotation = -self.swingAngle; arm.height = self.length; head.x = dx; head.y = dy; head.rotation = -self.swingAngle; if (self.grabbedObj) { self.grabbedObj.x = self.x + dx; self.grabbedObj.y = self.y + dy + head.height / 2; } }; // Called every tick self.update = function () { if (self.state === 'swing') { self.swingAngle += self.swingDir * self.swingSpeed; if (self.swingAngle > self.swingMax) { self.swingAngle = self.swingMax; self.swingDir = -1; } if (self.swingAngle < -self.swingMax) { self.swingAngle = -self.swingMax; self.swingDir = 1; } } else if (self.state === 'extend') { self.length += self.speed; if (self.length >= self.maxLength) { self.length = self.maxLength; self.state = 'retract'; } } else if (self.state === 'retract') { self.length -= self.retractSpeed; if (self.length <= self.baseLength) { self.length = self.baseLength; self.state = 'swing'; if (self.grabbedObj) { // Drop object at top self.grabbedObj.onCollected(); self.grabbedObj = null; } } } else if (self.state === 'grabbed') { // Wait for retract to finish self.length -= self.retractSpeed; if (self.length <= self.baseLength) { self.length = self.baseLength; self.state = 'swing'; if (self.grabbedObj) { self.grabbedObj.onCollected(); self.grabbedObj = null; } } } self.updateClaw(); }; // Start extending self.startExtend = function () { if (self.state === 'swing') { self.state = 'extend'; } }; // Called when an object is grabbed self.grabObject = function (obj) { self.grabbedObj = obj; self.state = 'grabbed'; // Set retract speed based on object type self.retractSpeed = obj.retractSpeed; }; // Called when nothing is grabbed (hit ground) self.miss = function () { self.state = 'retract'; self.retractSpeed = 64; //{L} // Faster retract when empty }; return self; }); // Moving Target class var Target = Container.expand(function () { var self = Container.call(this); // Draw as a different asset (targetBox image asset) var boxAsset = self.attachAsset('targetBox', { anchorX: 0.5, anchorY: 0.5, scaleX: 1, scaleY: 1 }); // Optionally, you can adjust scaleX/scaleY if you want it smaller/larger self.speed = 8; // medium speed self.direction = 1; // 1 = right, -1 = left self.y = GROUND_Y - 100; self.x = 400; self.lastX = self.x; self.update = function () { // Move horizontally self.x += self.speed * self.direction; // Bounce at screen edges if (self.lastX <= GAME_WIDTH - 200 && self.x > GAME_WIDTH - 200 || self.lastX >= 200 && self.x < 200) { self.direction *= -1; } // Clamp position if (self.x > GAME_WIDTH - 200) self.x = GAME_WIDTH - 200; if (self.x < 200) self.x = 200; self.lastX = self.x; }; // Add a no-op onCollected method to prevent errors if called by Claw self.onCollected = function () { // No-op for moving target }; return self; }); // Base class for all underground objects var UndergroundObject = Container.expand(function () { var self = Container.call(this); self.value = 0; self.retractSpeed = 32; self.grabSound = 'grab'; self.collectedSound = 'collect'; self.collected = false; // Called when collected self.onCollected = function () { if (self.collected) return; self.collected = true; // Play money sound when pulling up captured objects LK.getSound('money').play(); self.visible = false; if (typeof self.onScore === 'function') self.onScore(); self.destroy(); }; return self; }); // Rock var Rock = UndergroundObject.expand(function () { var self = UndergroundObject.call(this); var rock = self.attachAsset('rock', { anchorX: 0.5, anchorY: 0.5 }); self.value = 50; self.retractSpeed = 6; // very slow self.grabSound = 'rockhit'; self.collectedSound = 'rockhit'; self.onCollected = function () { if (self.collected) return; self.collected = true; LK.getSound('money').play(); self.visible = false; if (typeof self.onScore === 'function') self.onScore(); self.destroy(); }; return self; }); // Small gold nugget var GoldSmall = UndergroundObject.expand(function () { var self = UndergroundObject.call(this); var gold = self.attachAsset('goldSmall', { anchorX: 0.5, anchorY: 0.5 }); self.value = 250; self.retractSpeed = 24; // medium self.grabSound = 'grab'; self.collectedSound = 'collect'; self.onCollected = function () { if (self.collected) return; self.collected = true; LK.getSound('money').play(); self.visible = false; if (typeof self.onScore === 'function') self.onScore(); self.destroy(); }; return self; }); // Gold nugget var Gold = UndergroundObject.expand(function () { var self = UndergroundObject.call(this); var gold = self.attachAsset('gold', { anchorX: 0.5, anchorY: 0.5 }); self.value = 500; self.retractSpeed = 12; // slow self.grabSound = 'grab'; self.collectedSound = 'collect'; self.onCollected = function () { if (self.collected) return; self.collected = true; LK.getSound('money').play(); self.visible = false; if (typeof self.onScore === 'function') self.onScore(); self.destroy(); }; return self; }); // Gem var Gem = UndergroundObject.expand(function () { var self = UndergroundObject.call(this); var gem = self.attachAsset('gem', { anchorX: 0.5, anchorY: 0.5 }); self.value = 800; self.retractSpeed = 32; // fast self.grabSound = 'grab'; self.collectedSound = 'collect'; self.onCollected = function () { if (self.collected) return; self.collected = true; LK.getSound('money').play(); self.visible = false; if (typeof self.onScore === 'function') self.onScore(); self.destroy(); }; return self; }); // Dynamite trap var Dynamite = UndergroundObject.expand(function () { var self = UndergroundObject.call(this); var dynamite = self.attachAsset('dynamite', { anchorX: 0.5, anchorY: 0.5 }); self.value = 0; self.retractSpeed = 40; // fast retract self.grabSound = 'dynamite'; self.collectedSound = 'dynamite'; self.onCollected = function () { if (self.collected) return; self.collected = true; LK.getSound(self.collectedSound).play(); // Flash screen red to indicate explosion LK.effects.flashScreen(0xff0000, 800); // Remove some score as penalty score = Math.max(0, score - 400); LK.setScore(score); scoreTxt.setText(score); self.visible = false; self.destroy(); }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x8B5A2B // brown }); /**** * Game Code ****/ // Game constants // Claw arm (rectangle) // Claw head (ellipse) // Gold nugget (ellipse) // Small gold nugget // Rock (ellipse) // Gem (ellipse) // Sound for grabbing // Sound for collecting // Sound for hitting rock // Music var GAME_WIDTH = 2048; var GAME_HEIGHT = 2732; var GROUND_Y = 700; // y position where underground objects start var LEVEL_TIME = 60; // seconds var LEVEL_GOAL = 1500; // gold needed to win // Level and difficulty progression var level = 1; var maxLevel = 10; var objects = []; var claw = null; var score = 0; var timer = 0; var timeLeft = LEVEL_TIME; var goal = LEVEL_GOAL; var gameActive = true; // Add multiple moving targets var targets = []; // GUI var scoreTxt = new Text2('0', { size: 120, fill: 0xFFF8C0 }); scoreTxt.anchor.set(0, 0); LK.gui.top.addChild(scoreTxt); // Place score text at the top left, but not in the reserved 100x100 area scoreTxt.x = 120; scoreTxt.y = 20; // Goal text var goalTxt = new Text2('Goal: ' + goal, { size: 80, fill: 0xFFE066 }); goalTxt.anchor.set(0, 0); LK.gui.top.addChild(goalTxt); goalTxt.x = 0; goalTxt.y = 0; var timerTxt = new Text2('60', { size: 100, fill: 0xFFFFFF }); timerTxt.anchor.set(0, 0); LK.gui.top.addChild(timerTxt); // Place timer text at the top left, but not in the reserved 100x100 area timerTxt.x = 120; timerTxt.y = 20; // Level text var levelTxt = new Text2('Level: ' + level, { size: 80, fill: 0xB0E0E6 }); levelTxt.anchor.set(1, 0); LK.gui.top.addChild(levelTxt); levelTxt.y = 0; // Place GUI elements, but not in top left 100x100 timerTxt.x = LK.gui.top.width - 120; levelTxt.x = LK.gui.top.width - 120; // Place claw at top center claw = new Claw(); claw.x = GAME_WIDTH / 2; claw.y = 0; game.addChild(claw); // Add bag asset to different parts of the screen var bagTopLeft = LK.getAsset('torba', { anchorX: 0, anchorY: 0, x: 120, y: 140 }); game.addChild(bagTopLeft); var bagTopRight = LK.getAsset('torba', { anchorX: 1, anchorY: 0, x: GAME_WIDTH - 120, y: 140 }); game.addChild(bagTopRight); var bagBottomLeft = LK.getAsset('torba', { anchorX: 0, anchorY: 1, x: 120, y: GAME_HEIGHT - 140 }); game.addChild(bagBottomLeft); var bagBottomRight = LK.getAsset('torba', { anchorX: 1, anchorY: 1, x: GAME_WIDTH - 120, y: GAME_HEIGHT - 140 }); game.addChild(bagBottomRight); // Underground object spawn positions function spawnObjects() { // Clear previous for (var i = 0; i < objects.length; i++) { objects[i].destroy(); } objects = []; // Difficulty scaling var bigGoldCount = 4 + Math.floor(level / 2); var smallGoldCount = 6 + level; var rockCount = 6 + level * 2; var gemCount = 3 + Math.floor(level / 2); var dynamiteCount = 2 + Math.floor(level / 2); // Create all objects in order: gold, diamonds, dynamite, rocks, then mix var allObjs = []; // Gold (big) for (var i = 0; i < bigGoldCount; i++) { var g = new Gold(); g.onScore = function () { score += this.value; LK.setScore(score); scoreTxt.setText(score); }; allObjs.push(g); } // Gold (small) for (var i = 0; i < smallGoldCount; i++) { var gs = new GoldSmall(); gs.onScore = function () { score += this.value; LK.setScore(score); scoreTxt.setText(score); }; allObjs.push(gs); } // Gems for (var i = 0; i < gemCount; i++) { var gem = new Gem(); gem.onScore = function () { score += this.value; LK.setScore(score); scoreTxt.setText(score); }; allObjs.push(gem); } // Dynamite for (var i = 0; i < dynamiteCount; i++) { var d = new Dynamite(); allObjs.push(d); } // Rocks for (var i = 0; i < rockCount; i++) { var r = new Rock(); r.onScore = function () { score += this.value; LK.setScore(score); scoreTxt.setText(score); }; allObjs.push(r); } // Shuffle allObjs array for (var i = allObjs.length - 1; i > 0; i--) { var j = Math.floor(Math.random() * (i + 1)); var temp = allObjs[i]; allObjs[i] = allObjs[j]; allObjs[j] = temp; } // Place objects in the play area, avoiding overlap var gridCols = 8; var gridRows = Math.ceil(allObjs.length / gridCols); var cellW = Math.floor((GAME_WIDTH - 400) / gridCols); var cellH = Math.floor((GAME_HEIGHT - GROUND_Y - 400) / gridRows); var usedCells = []; for (var i = 0; i < allObjs.length; i++) { var obj = allObjs[i]; // Find a free cell var placed = false; var attempts = 0; while (!placed && attempts < 30) { var col = Math.floor(Math.random() * gridCols); var row = Math.floor(Math.random() * gridRows); var cellIdx = row * gridCols + col; if (usedCells.indexOf(cellIdx) === -1) { usedCells.push(cellIdx); obj.x = 200 + col * cellW + Math.floor(cellW / 2); obj.y = GROUND_Y + 200 + row * cellH + Math.floor(cellH / 2); placed = true; } attempts++; } game.addChild(obj); objects.push(obj); } } spawnObjects(); // Create and add a single moving target // Destroy old targets if any if (targets && targets.length) { for (var i = 0; i < targets.length; i++) { if (targets[i]) targets[i].destroy(); } } targets = []; // Add two moving targets at different positions var t1 = new Target(); t1.x = GAME_WIDTH / 2 - 300; t1.y = GROUND_Y + 200; t1.direction = 1; targets.push(t1); game.addChild(t1); var t2 = new Target(); t2.x = GAME_WIDTH / 2 + 300; t2.y = GROUND_Y + 200; t2.direction = -1; targets.push(t2); game.addChild(t2); // Timer timer = LK.setInterval(function () { if (!gameActive) return; timeLeft -= 1; if (timeLeft < 0) timeLeft = 0; timerTxt.setText(timeLeft); if (timeLeft === 0) { gameActive = false; // Game over LK.effects.flashScreen(0x000000, 800); LK.showGameOver(); } }, 1000); // Draw a dot at the top center to send the rope down var dropDot = LK.getAsset('centerCircle', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.5, scaleY: 0.5, x: GAME_WIDTH / 2, y: 80 }); game.addChild(dropDot); // Only trigger on dot press, not anywhere dropDot.down = function (x, y, obj) { if (!gameActive) return; if (claw.state === 'swing') { claw.startExtend(); } }; // Touch/click anywhere else does nothing game.down = function (x, y, obj) { // No-op, handled by dropDot }; // Main update loop game.update = function () { if (!gameActive) return; // Claw update handled in class // If claw is extending, check for collision with objects if (claw.state === 'extend') { // Get claw head position var dx = Math.sin(claw.swingAngle) * claw.length; var dy = Math.cos(claw.swingAngle) * claw.length; var cx = claw.x + dx; var cy = claw.y + dy + 30; // 30: half head height // Check for collision with any object var grabbed = false; for (var i = 0; i < objects.length; i++) { var obj = objects[i]; if (obj.collected) continue; // Simple circle collision var dist = Math.sqrt((obj.x - cx) * (obj.x - cx) + (obj.y - cy) * (obj.y - cy)); var r = 60; // approx radius if (dist < r + 40) { // Grab object claw.grabObject(obj); // Dynamite handles penalty in its onCollected grabbed = true; break; } } // Check for collision with any moving target if not already grabbed something if (!grabbed && targets && targets.length) { for (var ti = 0; ti < targets.length; ti++) { var t = targets[ti]; if (!t.visible) continue; if (typeof t.x !== 'number' || typeof t.y !== 'number') continue; var tdist = Math.sqrt((t.x - cx) * (t.x - cx) + (t.y - cy) * (t.y - cy)); var tr = 100; // slightly larger radius for target if (tdist < tr) { // "Grab" the target: treat as a special object claw.grabbedObj = t; claw.state = 'grabbed'; claw.retractSpeed = 32; // Optionally, you can add a sound or effect here // Remove the target visually and respawn after a delay t.visible = false; (function (targetToRespawn) { LK.setTimeout(function () { if (targetToRespawn) { targetToRespawn.x = 400 + Math.floor(Math.random() * (GAME_WIDTH - 800)); targetToRespawn.y = GROUND_Y - 100 - Math.floor(Math.random() * 120); targetToRespawn.visible = true; } }, 2000); })(t); grabbed = true; break; } } } // If reached max length and nothing grabbed, retract if (claw.length >= claw.maxLength && claw.state === 'extend') { claw.miss(); } } // Win condition if (score >= goal && gameActive) { gameActive = false; LK.effects.flashScreen(0xffff00, 800); // Level up logic if (level < maxLevel) { level += 1; // Play level up sound LK.getSound('level').play(); // Increase goal and decrease time for next level goal = LEVEL_GOAL + level * 800; timeLeft = LEVEL_TIME - Math.min(level * 3, 30); // reduce time, but not below 30s goalTxt.setText('Goal: ' + goal); timerTxt.setText(timeLeft); levelTxt.setText('Level: ' + level); score = 0; LK.setScore(score); scoreTxt.setText(score); // Respawn objects for new level spawnObjects(); gameActive = true; } else { LK.showYouWin(); } } // Update all moving targets if (targets && targets.length) { for (var ti = 0; ti < targets.length; ti++) { if (targets[ti] && typeof targets[ti].update === 'function') { targets[ti].update(); } } } }; // Play background music LK.playMusic('goldminerbg', { fade: { start: 0, end: 1, duration: 1000 } });
===================================================================
--- original.js
+++ change.js
@@ -358,8 +358,37 @@
claw = new Claw();
claw.x = GAME_WIDTH / 2;
claw.y = 0;
game.addChild(claw);
+// Add bag asset to different parts of the screen
+var bagTopLeft = LK.getAsset('torba', {
+ anchorX: 0,
+ anchorY: 0,
+ x: 120,
+ y: 140
+});
+game.addChild(bagTopLeft);
+var bagTopRight = LK.getAsset('torba', {
+ anchorX: 1,
+ anchorY: 0,
+ x: GAME_WIDTH - 120,
+ y: 140
+});
+game.addChild(bagTopRight);
+var bagBottomLeft = LK.getAsset('torba', {
+ anchorX: 0,
+ anchorY: 1,
+ x: 120,
+ y: GAME_HEIGHT - 140
+});
+game.addChild(bagBottomLeft);
+var bagBottomRight = LK.getAsset('torba', {
+ anchorX: 1,
+ anchorY: 1,
+ x: GAME_WIDTH - 120,
+ y: GAME_HEIGHT - 140
+});
+game.addChild(bagBottomRight);
// Underground object spawn positions
function spawnObjects() {
// Clear previous
for (var i = 0; i < objects.length; i++) {
gold. In-Game asset. 2d. High contrast. No shadows
diamond. In-Game asset. 2d. High contrast. No shadows
big rock. In-Game asset. 2d. High contrast. No shadows
upright long rope. In-Game asset. 2d. High contrast. No shadows
double pointed hook. In-Game asset. 2d. High contrast. No shadows
big piece of gold. In-Game asset. 2d. High contrast. No shadows
dynamite. In-Game asset. 2d. High contrast. No shadows
pig. In-Game asset. 2d. High contrast. No shadows
soru işareti olan bir torba. In-Game asset. 2d. High contrast. No shadows
Pig with dollar in mouth. In-Game asset. 2d. High contrast. No shadows
tnt yazılı varil. In-Game asset. 2d. High contrast. No shadows