User prompt
magnifyingGlass Move your ascent 0.5cm to the left
User prompt
magnifyingGlass Move your ascent 1.5cm to the right
User prompt
magnifyingGlass Move your assent 4cm to the left
User prompt
Place a magnifying glass to the left of the "axtarış" text on the screen
User prompt
Move the prisoner's ascent 1cm to the left
User prompt
The serial number of the box disappears after the box is opened
User prompt
Delete the serial number on the prisoner assent
Code edit (1 edits merged)
Please save this source code
User prompt
Fix bugs
Code edit (1 edits merged)
Please save this source code
User prompt
Move the prisoners' success rate 2cm to the right
Code edit (1 edits merged)
Please save this source code
User prompt
Move the text "Prisoners succeeded" to the top right in 1/100 format only
User prompt
Move the prisoner assent 0.5cm to the left and 1cm down
User prompt
Move the prisoner ascent 0.5cm to the left
Code edit (1 edits merged)
Please save this source code
User prompt
Move the prisoner ascender 3cm to the right
User prompt
Delete the serial number under the prisoner assent
User prompt
Position my prisoner icon slightly lower
User prompt
Position the prisoner ascent a little lower so that it is not above the text
User prompt
Put prisoner assent 10 pixels down
User prompt
Place the prisoner's ascent slightly lower than its current position
User prompt
Move the prisoner ascent slightly lower than its current position
User prompt
Do not let Prisoner assenti come over the texts
User prompt
Place the prisoner's assent to the left of the current prisoner text
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var Box = Container.expand(function (boxNumber, containsNumber) {
var self = Container.call(this);
self.boxNumber = boxNumber;
self.containsNumber = containsNumber;
self.isOpen = false;
self.boxGraphic = self.attachAsset('box', {
anchorX: 0.5,
anchorY: 0.5
});
self.numberText = new Text2(boxNumber.toString(), {
size: 56,
fill: 0xFFFFFF,
font: "bold Arial"
});
self.numberText.anchor.set(0.5, 0.5);
self.numberText.y = -90; // Moved higher to prevent overlap with boxes above
self.addChild(self.numberText);
self.contentText = new Text2(containsNumber.toString(), {
size: 25,
fill: 0x000000
});
self.contentText.anchor.set(0.5, 0.5);
self.contentText.visible = false;
self.addChild(self.contentText);
// Add prisoner number label on the box (hidden)
self.prisonerNumberText = new Text2('P' + containsNumber.toString(), {
size: 32,
fill: 0xFFFFFF
});
self.prisonerNumberText.anchor.set(0.5, 0.5);
self.prisonerNumberText.y = 50;
self.prisonerNumberText.visible = false;
self.addChild(self.prisonerNumberText);
self.openBox = function () {
if (!self.isOpen) {
self.isOpen = true;
self.removeChild(self.boxGraphic);
self.boxGraphic = self.attachAsset('boxOpen', {
anchorX: 0.5,
anchorY: 0.5
});
self.contentText.setText(self.containsNumber.toString());
self.contentText.visible = true;
self.contentText.alpha = 1.0;
self.contentText.y = 0; // Center the text in the middle of the box
self.contentText.x = 0; // Ensure horizontal centering
// Make the text more prominent with larger size and bold styling
self.contentText.size = 40;
self.contentText.fill = 0x000000; // Black text for better contrast
// Create new Text2 with bold styling
self.removeChild(self.contentText);
self.contentText = new Text2(self.containsNumber.toString(), {
size: 120,
fill: 0x000000,
font: "bold Arial"
});
self.contentText.anchor.set(0.5, 0.5);
self.contentText.y = 0;
self.contentText.x = 0;
self.contentText.visible = true;
self.contentText.alpha = 1.0;
self.addChild(self.contentText);
// Create pop-out animation effect
self.contentText.scaleX = 0.1;
self.contentText.scaleY = 0.1;
// Animate the number popping out
tween(self.contentText, {
scaleX: 1.5,
scaleY: 1.5,
alpha: 1
}, {
duration: 300,
onFinish: function onFinish() {
// Scale back to normal size after pop effect
tween(self.contentText, {
scaleX: 1,
scaleY: 1
}, {
duration: 200
});
}
});
LK.getSound('boxOpen').play();
return self.containsNumber;
}
return null;
};
self.closeBox = function () {
if (self.isOpen) {
self.isOpen = false;
self.removeChild(self.boxGraphic);
self.boxGraphic = self.attachAsset('box', {
anchorX: 0.5,
anchorY: 0.5
});
self.contentText.visible = false;
}
};
self.down = function (x, y, obj) {
// Always allow opening boxes to see the random number inside
if (!self.isOpen) {
var foundNumber = self.openBox();
// Only process game logic if we're in playing state
if (gameState === 'playing' && attemptsLeft > 0) {
attemptsLeft--;
attemptsText.setText('Attempts: ' + attemptsLeft);
if (foundNumber === currentPrisoner) {
prisonerFound = true;
LK.getSound('success').play();
successText.setText('Prisoner ' + currentPrisoner + ' found their number!');
successText.visible = true;
LK.setTimeout(function () {
nextPrisoner();
}, 2000);
} else if (attemptsLeft <= 0) {
LK.getSound('failure').play();
failureText.setText('Prisoner ' + currentPrisoner + ' failed!');
failureText.visible = true;
gameState = 'gameOver';
LK.setTimeout(function () {
LK.showGameOver();
}, 2000);
}
}
}
};
return self;
});
var Prisoner = Container.expand(function (prisonerNumber) {
var self = Container.call(this);
self.prisonerNumber = prisonerNumber;
self.prisonerGraphic = self.attachAsset('prisoner', {
anchorX: 0.5,
anchorY: 1.0
});
self.numberText = new Text2(prisonerNumber.toString(), {
size: 60,
fill: 0xFFFFFF
});
self.numberText.anchor.set(0.5, 0.5);
self.numberText.y = 40; // Place the number under the prisoner
self.addChild(self.numberText);
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x2F4F4F
});
/****
* Game Code
****/
var totalPrisoners = 100;
var boxes = [];
var prisoners = [];
var currentPrisoner = 1;
var attemptsLeft = Math.floor(totalPrisoners / 2);
var maxAttempts = Math.floor(totalPrisoners / 2);
var gameState = 'setup'; // setup, playing, gameOver, victory
var prisonerFound = false;
var successfulPrisoners = 0;
// UI Elements
var titleText = new Text2('100 Məhkum Testi', {
size: 120,
fill: 0xFFFFFF
});
titleText.anchor.set(0.5, 0);
titleText.x = 1024;
titleText.y = 50;
game.addChild(titleText);
var instructionText = new Text2('Məhkum öz nömrəsini 50 sınamada tapmalıdır. ', {
size: 70,
fill: 0xCCCCCC
});
instructionText.anchor.set(0.5, 0);
instructionText.x = 1024;
instructionText.y = 180;
game.addChild(instructionText);
var currentPrisonerText = new Text2('Current Prisoner: 1', {
size: 90,
fill: 0xFFFF00
});
currentPrisonerText.anchor.set(0.5, 0);
currentPrisonerText.x = 1024;
currentPrisonerText.y = 260;
game.addChild(currentPrisonerText);
var attemptsText = new Text2('Attempts: ' + attemptsLeft, {
size: 80,
fill: 0xFFFFFF
});
attemptsText.anchor.set(0.5, 0);
attemptsText.x = 1024;
attemptsText.y = 360;
game.addChild(attemptsText);
var successText = new Text2('', {
size: 80,
fill: 0x00FF00
});
successText.anchor.set(0.5, 0.5);
successText.x = 1024;
successText.y = 1366;
successText.visible = false;
game.addChild(successText);
var failureText = new Text2('', {
size: 80,
fill: 0xFF0000
});
failureText.anchor.set(0.5, 0.5);
failureText.x = 1024;
failureText.y = 1366;
failureText.visible = false;
game.addChild(failureText);
var progressText = new Text2('Prisoners succeeded: 0/' + totalPrisoners, {
size: 70,
fill: 0xFFFFFF
});
progressText.anchor.set(0.5, 0);
progressText.x = 1024;
progressText.y = 440;
game.addChild(progressText);
// Create shuffled array of numbers 1 to totalPrisoners
function shuffleArray(array) {
var shuffled = array.slice();
for (var i = shuffled.length - 1; i > 0; i--) {
var j = Math.floor(Math.random() * (i + 1));
var temp = shuffled[i];
shuffled[i] = shuffled[j];
shuffled[j] = temp;
}
return shuffled;
}
// Initialize the game
function setupGame() {
// Create array of numbers 1 to totalPrisoners
var numbers = [];
for (var i = 1; i <= totalPrisoners; i++) {
numbers.push(i);
}
// Shuffle the numbers
var shuffledNumbers = shuffleArray(numbers);
// Create boxes in a grid
var boxesPerRow = 10;
var spacing = 200; // Increased spacing to prevent overlap
var startX = 1024 - boxesPerRow * spacing / 2 + spacing / 2;
var startY = 600; // Moved down to make space for text above
for (var i = 0; i < totalPrisoners; i++) {
var row = Math.floor(i / boxesPerRow);
var col = i % boxesPerRow;
var box = new Box(i + 1, shuffledNumbers[i]);
box.x = startX + col * spacing;
box.y = startY + row * spacing;
boxes.push(box);
game.addChild(box);
}
// Create current prisoner display
var prisoner = new Prisoner(currentPrisoner);
prisoner.x = 500; // Position further left to prevent overlap with text elements
prisoner.y = 380; // Moved slightly lower than previous position
prisoners.push(prisoner);
game.addChild(prisoner);
gameState = 'playing';
}
function nextPrisoner() {
// Close all boxes
for (var i = 0; i < boxes.length; i++) {
boxes[i].closeBox();
}
successfulPrisoners++;
progressText.setText('Prisoners succeeded: ' + successfulPrisoners + '/' + totalPrisoners);
if (successfulPrisoners >= totalPrisoners) {
// All prisoners succeeded!
gameState = 'victory';
LK.setScore(100);
LK.setTimeout(function () {
LK.showYouWin();
}, 1000);
return;
}
currentPrisoner++;
attemptsLeft = maxAttempts;
prisonerFound = false;
// Update UI
currentPrisonerText.setText('Current Prisoner: ' + currentPrisoner);
attemptsText.setText('Attempts: ' + attemptsLeft);
successText.visible = false;
failureText.visible = false;
// Update prisoner display
if (prisoners.length > 0) {
prisoners[0].numberText.setText(currentPrisoner.toString());
}
gameState = 'playing';
}
// Start the game
setupGame();
// Game update loop
game.update = function () {
// No continuous updates needed for this turn-based game
}; ===================================================================
--- original.js
+++ change.js
@@ -266,9 +266,9 @@
}
// Create current prisoner display
var prisoner = new Prisoner(currentPrisoner);
prisoner.x = 500; // Position further left to prevent overlap with text elements
- prisoner.y = 350; // Moved slightly lower than previous position
+ prisoner.y = 380; // Moved slightly lower than previous position
prisoners.push(prisoner);
game.addChild(prisoner);
gameState = 'playing';
}