/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var Calculator = Container.expand(function () { var self = Container.call(this); self.displayValue = "0"; self.operation = null; self.operand = null; self.waitingForOperand = false; var bg = self.attachAsset('calculatorBg', { anchorX: 0.5, anchorY: 0.5 }); var display = self.attachAsset('calcDisplay', { anchorX: 0.5, anchorY: 0.5, y: -135 }); self.displayText = new Text2(self.displayValue, { size: 14, fill: 0x00FF00 }); self.displayText.anchor.set(1, 0.5); self.displayText.x = 255; self.displayText.y = -135; self.addChild(self.displayText); var buttons = [['C', 'TL→€', '€→TL', '='], ['7', '8', '9', '/'], ['4', '5', '6', '*'], ['1', '2', '3', '-'], ['0', '.', '+', 'OK']]; self.buttons = []; for (var row = 0; row < buttons.length; row++) { for (var col = 0; col < buttons[row].length; col++) { var button = self.createButton(buttons[row][col], col, row); self.addChild(button); self.buttons.push(button); } } self.createButton = function (text, col, row) { var button = new Container(); var bg = LK.getAsset('calcButton', { anchorX: 0.5, anchorY: 0.5 }); button.addChild(bg); var label = new Text2(text, { size: 14, fill: 0xFFFFFF }); label.anchor.set(0.5, 0.5); button.addChild(label); button.x = (col - 1.5) * 135; button.y = (row - 1) * 105 - 30; button.buttonText = text; button.down = function (x, y, obj) { calculator.handleButtonPress(obj.buttonText); }; return button; }; self.handleButtonPress = function (buttonText) { LK.getSound('click').play(); if (buttonText === 'C') { self.clear(); } else if (buttonText === 'OK') { gamePhase = 'assessment'; showAssessment(); } else if (buttonText === 'TL→€') { var tlAmount = parseFloat(self.displayValue); var euroAmount = convertCurrency(tlAmount, 'tl', 'euro'); self.displayValue = euroAmount.toFixed(2); self.updateDisplay(); } else if (buttonText === '€→TL') { var euroAmount = parseFloat(self.displayValue); var tlAmount = convertCurrency(euroAmount, 'euro', 'tl'); self.displayValue = tlAmount.toFixed(2); self.updateDisplay(); } else if (['+', '-', '*', '/', '='].indexOf(buttonText) !== -1) { self.handleOperator(buttonText); } else { self.handleNumber(buttonText); } }; self.handleNumber = function (num) { if (self.waitingForOperand) { self.displayValue = num; self.waitingForOperand = false; } else { self.displayValue = self.displayValue === '0' ? num : self.displayValue + num; } self.updateDisplay(); }; self.handleOperator = function (nextOperator) { var inputValue = parseFloat(self.displayValue); if (self.operand === null) { self.operand = inputValue; } else if (self.operation) { var currentValue = self.operand || 0; var newValue = self.calculate(currentValue, inputValue, self.operation); self.displayValue = String(newValue); self.operand = newValue; self.updateDisplay(); } self.waitingForOperand = true; self.operation = nextOperator === '=' ? null : nextOperator; }; self.calculate = function (firstOperand, secondOperand, operation) { switch (operation) { case '+': return firstOperand + secondOperand; case '-': return firstOperand - secondOperand; case '*': return firstOperand * secondOperand; case '/': return firstOperand / secondOperand; default: return secondOperand; } }; self.clear = function () { self.displayValue = "0"; self.operation = null; self.operand = null; self.waitingForOperand = false; self.updateDisplay(); }; self.updateDisplay = function () { self.displayText.setText(self.displayValue); }; return self; }); var CurrencyItem = Container.expand(function (type, value, currency) { var self = Container.call(this); self.itemType = type; self.value = value; self.currency = currency; self.isDragging = false; self.originalX = 0; self.originalY = 0; var assetId = currency + type + value; var graphics = self.attachAsset(assetId, { anchorX: 0.5, anchorY: 0.5 }); var label = new Text2(value + ' ' + currency.toUpperCase(), { size: 14, fill: 0xFFFFFF }); label.anchor.set(0.5, 0.5); self.addChild(label); self.down = function (x, y, obj) { self.isDragging = true; self.originalX = self.x; self.originalY = self.y; self.alpha = 0.8; LK.getSound('click').play(); }; self.up = function (x, y, obj) { self.isDragging = false; self.alpha = 1.0; var matched = false; for (var i = 0; i < dropZones.length; i++) { if (self.intersects(dropZones[i]) && !dropZones[i].occupied) { var expectedValue = convertCurrency(self.value, self.currency, dropZones[i].targetCurrency); if (Math.abs(expectedValue - dropZones[i].targetValue) < 0.1) { self.x = dropZones[i].x; self.y = dropZones[i].y; dropZones[i].occupied = true; dropZones[i].occupiedBy = self; matched = true; matchedPairs++; LK.getSound('match').play(); LK.setScore(LK.getScore() + 10); scoreText.setText('Score: ' + LK.getScore()); if (matchedPairs >= totalPairs) { gamePhase = 'calculator'; showCalculator(); } break; } } } if (!matched) { tween(self, { x: self.originalX, y: self.originalY }, { duration: 300 }); } }; return self; }); var DropZone = Container.expand(function (targetValue, targetCurrency) { var self = Container.call(this); self.targetValue = targetValue; self.targetCurrency = targetCurrency; self.occupied = false; self.occupiedBy = null; var bg = self.attachAsset('dropZone', { anchorX: 0.5, anchorY: 0.5 }); bg.alpha = 0.3; var label = new Text2(targetValue.toFixed(2) + ' ' + targetCurrency.toUpperCase(), { size: 14, fill: 0xFFFFFF }); label.anchor.set(0.5, 0.5); self.addChild(label); return self; }); var FallingCurrency = Container.expand(function (type, value, currency) { var self = Container.call(this); self.itemType = type; self.value = value; self.currency = currency; self.speed = 2; // Start slow self.lastY = 0; var assetId = currency + type + value; var graphics = self.attachAsset(assetId, { anchorX: 0.5, anchorY: 0.5 }); var label = new Text2(value + ' ' + currency.toUpperCase(), { size: 45, fill: 0xFFFFFF }); label.anchor.set(0.5, 0.5); self.addChild(label); self.update = function () { self.lastY = self.y; self.y += self.speed; // Gradually increase speed if (LK.ticks % 300 === 0) { self.speed += 0.5; } }; return self; }); var Hand = Container.expand(function (side) { var self = Container.call(this); self.side = side; var graphics = self.attachAsset(side + 'Hand', { anchorX: 0.5, anchorY: 0.5 }); self.scoreLabel = new Text2('Score: 0', { size: 90, fill: 0x000000 }); self.scoreLabel.anchor.set(0.5, 0.5); self.addChild(self.scoreLabel); self.updateScoreDisplay = function () { self.scoreLabel.setText('Score: ' + LK.getScore()); // Keep the text centered within the hand bounds self.scoreLabel.x = 0; self.scoreLabel.y = 0; }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x1a1a2e }); /**** * Game Code ****/ var exchangeRate = 47; // TL per Euro var gamePhase = 'falling'; // 'falling', 'calculator', 'assessment' var caughtItems = 0; var missedItems = 0; var maxMissed = 10; var fallingItems = []; var leftHand, rightHand; var useMouseControl = true; var spawnTimer = 0; var spawnRate = 60; // frames between spawns var controlsContainer; var scoreText = new Text2('Score: 0', { size: 14, fill: 0xFFFFFF }); scoreText.anchor.set(0.5, 0); LK.gui.top.addChild(scoreText); var phaseText = new Text2('Catch falling currencies! Missed: 0/10', { size: 14, fill: 0xFFD700 }); phaseText.anchor.set(0.5, 0); phaseText.y = 50; LK.gui.top.addChild(phaseText); var exchangeRateText = new Text2('Exchange Rate: 1 EUR = ' + exchangeRate + ' TL', { size: 14, fill: 0x00FF00 }); exchangeRateText.anchor.set(0.5, 0); exchangeRateText.y = 80; LK.gui.top.addChild(exchangeRateText); function convertCurrency(amount, fromCurrency, toCurrency) { if (fromCurrency === 'tl' && toCurrency === 'euro') { return amount / exchangeRate; } else if (fromCurrency === 'euro' && toCurrency === 'tl') { return amount * exchangeRate; } return amount; } function setupFallingPhase() { // Create hands at bottom leftHand = new Hand('left'); leftHand.x = 400; leftHand.y = 2600; leftHand.updateScoreDisplay(); game.addChild(leftHand); rightHand = new Hand('right'); rightHand.x = 1648; rightHand.y = 2600; rightHand.updateScoreDisplay(); game.addChild(rightHand); // Create control interface setupControls(); } function setupControls() { controlsContainer = new Container(); controlsContainer.x = 1848; controlsContainer.y = 100; LK.gui.addChild(controlsContainer); var controlBg = LK.getAsset('controlButton', { anchorX: 0.5, anchorY: 0.5, scaleX: 2, scaleY: 1.5 }); controlsContainer.addChild(controlBg); var controlText = new Text2('Controls', { size: 12, fill: 0xFFFFFF }); controlText.anchor.set(0.5, 0.5); controlText.y = -30; controlsContainer.addChild(controlText); var mouseText = new Text2('Mouse: ON', { size: 10, fill: 0x00FF00 }); mouseText.anchor.set(0.5, 0.5); controlsContainer.addChild(mouseText); var keyText = new Text2('Keys: OFF', { size: 10, fill: 0xFF0000 }); keyText.anchor.set(0.5, 0.5); keyText.y = 20; controlsContainer.addChild(keyText); controlsContainer.mouseText = mouseText; controlsContainer.keyText = keyText; controlsContainer.down = function () { useMouseControl = !useMouseControl; if (useMouseControl) { controlsContainer.mouseText.setText('Mouse: ON'); controlsContainer.mouseText.style.fill = 0x00FF00; controlsContainer.keyText.setText('Keys: OFF'); controlsContainer.keyText.style.fill = 0xFF0000; } else { controlsContainer.mouseText.setText('Mouse: OFF'); controlsContainer.mouseText.style.fill = 0xFF0000; controlsContainer.keyText.setText('Keys: ON'); controlsContainer.keyText.style.fill = 0x00FF00; } }; } function spawnCurrency() { var allCurrencies = [{ type: 'Coin1kurus', value: 0.01, currency: 'tl' }, { type: 'Coin5kurus', value: 0.05, currency: 'tl' }, { type: 'Coin10kurus', value: 0.10, currency: 'tl' }, { type: 'Coin25kurus', value: 0.25, currency: 'tl' }, { type: 'Coin50kurus', value: 0.50, currency: 'tl' }, { type: 'Coin', value: 1, currency: 'tl' }, { type: 'Note', value: 20, currency: 'tl' }, { type: 'Note', value: 50, currency: 'tl' }, { type: 'Note', value: 100, currency: 'tl' }, { type: 'Note', value: 200, currency: 'tl' }, { type: 'Coin1cent', value: 0.01, currency: 'euro' }, { type: 'Coin2cent', value: 0.02, currency: 'euro' }, { type: 'Coin5cent', value: 0.05, currency: 'euro' }, { type: 'Coin10cent', value: 0.10, currency: 'euro' }, { type: 'Coin20cent', value: 0.20, currency: 'euro' }, { type: 'Coin50cent', value: 0.50, currency: 'euro' }, { type: 'Coin', value: 1, currency: 'euro' }, { type: 'Coin', value: 2, currency: 'euro' }, { type: 'Note', value: 5, currency: 'euro' }, { type: 'Note', value: 10, currency: 'euro' }, { type: 'Note', value: 500, currency: 'euro' }, { type: 'Note', value: 1000, currency: 'euro' }]; var randomCurrency = allCurrencies[Math.floor(Math.random() * allCurrencies.length)]; var fallingItem = new FallingCurrency(randomCurrency.type, randomCurrency.value, randomCurrency.currency); fallingItem.x = Math.random() * 1800 + 124; // Random X within screen bounds fallingItem.y = -100; fallingItem.lastY = fallingItem.y; fallingItem.lastCaught = false; fallingItems.push(fallingItem); game.addChild(fallingItem); } function showCalculator() { phaseText.setText('Use calculator to convert currencies'); // Clear falling items for (var i = 0; i < fallingItems.length; i++) { fallingItems[i].destroy(); } fallingItems = []; // Clear hands if (leftHand) leftHand.destroy(); if (rightHand) rightHand.destroy(); if (controlsContainer) controlsContainer.destroy(); calculator = new Calculator(); calculator.x = 1024; calculator.y = 1400; game.addChild(calculator); } function showAssessment() { phaseText.setText('Game Over!'); // Clear all falling items for (var i = 0; i < fallingItems.length; i++) { fallingItems[i].destroy(); } fallingItems = []; // Clear hands and controls if (leftHand) leftHand.destroy(); if (rightHand) rightHand.destroy(); if (controlsContainer) controlsContainer.destroy(); if (calculator) { calculator.destroy(); } var finalScore = LK.getScore(); // Display final score in center var scoreDisplayText = new Text2('Final Score: ' + finalScore, { size: 135, fill: 0xFFD700 }); scoreDisplayText.anchor.set(0.5, 0.5); scoreDisplayText.x = 1024; scoreDisplayText.y = 1200; game.addChild(scoreDisplayText); // Create game play button var gamePlayButton = new Container(); var buttonBg = LK.getAsset('calcButton', { anchorX: 0.5, anchorY: 0.5, scaleX: 7.5, scaleY: 10 }); gamePlayButton.addChild(buttonBg); var buttonText = new Text2('PLAY AGAIN', { size: 135, fill: 0xFFFFFF }); buttonText.anchor.set(0.5, 0.5); gamePlayButton.addChild(buttonText); gamePlayButton.x = 1024; gamePlayButton.y = 1400; game.addChild(gamePlayButton); gamePlayButton.down = function () { LK.getSound('click').play(); // Reset game state gamePhase = 'falling'; caughtItems = 0; missedItems = 0; spawnTimer = 0; spawnRate = 60; LK.setScore(0); scoreText.setText('Score: 0'); phaseText.setText('Catch falling currencies! Missed: 0/10'); // Clear current game elements scoreDisplayText.destroy(); gamePlayButton.destroy(); game.setBackgroundColor(0x1a1a2e); // Restart falling phase setupFallingPhase(); }; } game.move = function (x, y, obj) { if (gamePhase === 'falling' && useMouseControl) { // Move hands based on mouse position if (x < 1024) { leftHand.x = x; leftHand.updateScoreDisplay(); } else { rightHand.x = x; rightHand.updateScoreDisplay(); } } }; game.update = function () { if (gamePhase === 'falling') { // Handle keyboard controls if (!useMouseControl) { // Simple keyboard simulation using ticks if (LK.ticks % 3 === 0) { leftHand.x = Math.max(100, leftHand.x - 5); leftHand.updateScoreDisplay(); } if (LK.ticks % 4 === 0) { leftHand.x = Math.min(1024, leftHand.x + 5); leftHand.updateScoreDisplay(); } if (LK.ticks % 5 === 0) { rightHand.x = Math.max(1024, rightHand.x - 5); rightHand.updateScoreDisplay(); } if (LK.ticks % 6 === 0) { rightHand.x = Math.min(1948, rightHand.x + 5); rightHand.updateScoreDisplay(); } } // Spawn currency spawnTimer++; if (spawnTimer >= spawnRate) { spawnCurrency(); spawnTimer = 0; // Gradually increase spawn rate if (spawnRate > 20) { spawnRate--; } } // Update falling items for (var i = fallingItems.length - 1; i >= 0; i--) { var item = fallingItems[i]; // Check if caught by hands var currentCaught = item.intersects(leftHand) || item.intersects(rightHand); if (!item.lastCaught && currentCaught) { // Just caught caughtItems++; LK.setScore(LK.getScore() + Math.floor(item.value * 10)); scoreText.setText('Score: ' + LK.getScore()); if (leftHand) leftHand.updateScoreDisplay(); if (rightHand) rightHand.updateScoreDisplay(); LK.getSound('money').play(); item.destroy(); fallingItems.splice(i, 1); continue; } item.lastCaught = currentCaught; // Check if item fell off screen if (item.lastY <= 2732 && item.y > 2732) { missedItems++; phaseText.setText('Catch falling currencies! Missed: ' + missedItems + '/' + maxMissed); item.destroy(); fallingItems.splice(i, 1); if (missedItems >= maxMissed) { gamePhase = 'calculator'; showCalculator(); } continue; } item.lastY = item.y; } } }; setupFallingPhase();
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Calculator = Container.expand(function () {
var self = Container.call(this);
self.displayValue = "0";
self.operation = null;
self.operand = null;
self.waitingForOperand = false;
var bg = self.attachAsset('calculatorBg', {
anchorX: 0.5,
anchorY: 0.5
});
var display = self.attachAsset('calcDisplay', {
anchorX: 0.5,
anchorY: 0.5,
y: -135
});
self.displayText = new Text2(self.displayValue, {
size: 14,
fill: 0x00FF00
});
self.displayText.anchor.set(1, 0.5);
self.displayText.x = 255;
self.displayText.y = -135;
self.addChild(self.displayText);
var buttons = [['C', 'TL→€', '€→TL', '='], ['7', '8', '9', '/'], ['4', '5', '6', '*'], ['1', '2', '3', '-'], ['0', '.', '+', 'OK']];
self.buttons = [];
for (var row = 0; row < buttons.length; row++) {
for (var col = 0; col < buttons[row].length; col++) {
var button = self.createButton(buttons[row][col], col, row);
self.addChild(button);
self.buttons.push(button);
}
}
self.createButton = function (text, col, row) {
var button = new Container();
var bg = LK.getAsset('calcButton', {
anchorX: 0.5,
anchorY: 0.5
});
button.addChild(bg);
var label = new Text2(text, {
size: 14,
fill: 0xFFFFFF
});
label.anchor.set(0.5, 0.5);
button.addChild(label);
button.x = (col - 1.5) * 135;
button.y = (row - 1) * 105 - 30;
button.buttonText = text;
button.down = function (x, y, obj) {
calculator.handleButtonPress(obj.buttonText);
};
return button;
};
self.handleButtonPress = function (buttonText) {
LK.getSound('click').play();
if (buttonText === 'C') {
self.clear();
} else if (buttonText === 'OK') {
gamePhase = 'assessment';
showAssessment();
} else if (buttonText === 'TL→€') {
var tlAmount = parseFloat(self.displayValue);
var euroAmount = convertCurrency(tlAmount, 'tl', 'euro');
self.displayValue = euroAmount.toFixed(2);
self.updateDisplay();
} else if (buttonText === '€→TL') {
var euroAmount = parseFloat(self.displayValue);
var tlAmount = convertCurrency(euroAmount, 'euro', 'tl');
self.displayValue = tlAmount.toFixed(2);
self.updateDisplay();
} else if (['+', '-', '*', '/', '='].indexOf(buttonText) !== -1) {
self.handleOperator(buttonText);
} else {
self.handleNumber(buttonText);
}
};
self.handleNumber = function (num) {
if (self.waitingForOperand) {
self.displayValue = num;
self.waitingForOperand = false;
} else {
self.displayValue = self.displayValue === '0' ? num : self.displayValue + num;
}
self.updateDisplay();
};
self.handleOperator = function (nextOperator) {
var inputValue = parseFloat(self.displayValue);
if (self.operand === null) {
self.operand = inputValue;
} else if (self.operation) {
var currentValue = self.operand || 0;
var newValue = self.calculate(currentValue, inputValue, self.operation);
self.displayValue = String(newValue);
self.operand = newValue;
self.updateDisplay();
}
self.waitingForOperand = true;
self.operation = nextOperator === '=' ? null : nextOperator;
};
self.calculate = function (firstOperand, secondOperand, operation) {
switch (operation) {
case '+':
return firstOperand + secondOperand;
case '-':
return firstOperand - secondOperand;
case '*':
return firstOperand * secondOperand;
case '/':
return firstOperand / secondOperand;
default:
return secondOperand;
}
};
self.clear = function () {
self.displayValue = "0";
self.operation = null;
self.operand = null;
self.waitingForOperand = false;
self.updateDisplay();
};
self.updateDisplay = function () {
self.displayText.setText(self.displayValue);
};
return self;
});
var CurrencyItem = Container.expand(function (type, value, currency) {
var self = Container.call(this);
self.itemType = type;
self.value = value;
self.currency = currency;
self.isDragging = false;
self.originalX = 0;
self.originalY = 0;
var assetId = currency + type + value;
var graphics = self.attachAsset(assetId, {
anchorX: 0.5,
anchorY: 0.5
});
var label = new Text2(value + ' ' + currency.toUpperCase(), {
size: 14,
fill: 0xFFFFFF
});
label.anchor.set(0.5, 0.5);
self.addChild(label);
self.down = function (x, y, obj) {
self.isDragging = true;
self.originalX = self.x;
self.originalY = self.y;
self.alpha = 0.8;
LK.getSound('click').play();
};
self.up = function (x, y, obj) {
self.isDragging = false;
self.alpha = 1.0;
var matched = false;
for (var i = 0; i < dropZones.length; i++) {
if (self.intersects(dropZones[i]) && !dropZones[i].occupied) {
var expectedValue = convertCurrency(self.value, self.currency, dropZones[i].targetCurrency);
if (Math.abs(expectedValue - dropZones[i].targetValue) < 0.1) {
self.x = dropZones[i].x;
self.y = dropZones[i].y;
dropZones[i].occupied = true;
dropZones[i].occupiedBy = self;
matched = true;
matchedPairs++;
LK.getSound('match').play();
LK.setScore(LK.getScore() + 10);
scoreText.setText('Score: ' + LK.getScore());
if (matchedPairs >= totalPairs) {
gamePhase = 'calculator';
showCalculator();
}
break;
}
}
}
if (!matched) {
tween(self, {
x: self.originalX,
y: self.originalY
}, {
duration: 300
});
}
};
return self;
});
var DropZone = Container.expand(function (targetValue, targetCurrency) {
var self = Container.call(this);
self.targetValue = targetValue;
self.targetCurrency = targetCurrency;
self.occupied = false;
self.occupiedBy = null;
var bg = self.attachAsset('dropZone', {
anchorX: 0.5,
anchorY: 0.5
});
bg.alpha = 0.3;
var label = new Text2(targetValue.toFixed(2) + ' ' + targetCurrency.toUpperCase(), {
size: 14,
fill: 0xFFFFFF
});
label.anchor.set(0.5, 0.5);
self.addChild(label);
return self;
});
var FallingCurrency = Container.expand(function (type, value, currency) {
var self = Container.call(this);
self.itemType = type;
self.value = value;
self.currency = currency;
self.speed = 2; // Start slow
self.lastY = 0;
var assetId = currency + type + value;
var graphics = self.attachAsset(assetId, {
anchorX: 0.5,
anchorY: 0.5
});
var label = new Text2(value + ' ' + currency.toUpperCase(), {
size: 45,
fill: 0xFFFFFF
});
label.anchor.set(0.5, 0.5);
self.addChild(label);
self.update = function () {
self.lastY = self.y;
self.y += self.speed;
// Gradually increase speed
if (LK.ticks % 300 === 0) {
self.speed += 0.5;
}
};
return self;
});
var Hand = Container.expand(function (side) {
var self = Container.call(this);
self.side = side;
var graphics = self.attachAsset(side + 'Hand', {
anchorX: 0.5,
anchorY: 0.5
});
self.scoreLabel = new Text2('Score: 0', {
size: 90,
fill: 0x000000
});
self.scoreLabel.anchor.set(0.5, 0.5);
self.addChild(self.scoreLabel);
self.updateScoreDisplay = function () {
self.scoreLabel.setText('Score: ' + LK.getScore());
// Keep the text centered within the hand bounds
self.scoreLabel.x = 0;
self.scoreLabel.y = 0;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x1a1a2e
});
/****
* Game Code
****/
var exchangeRate = 47; // TL per Euro
var gamePhase = 'falling'; // 'falling', 'calculator', 'assessment'
var caughtItems = 0;
var missedItems = 0;
var maxMissed = 10;
var fallingItems = [];
var leftHand, rightHand;
var useMouseControl = true;
var spawnTimer = 0;
var spawnRate = 60; // frames between spawns
var controlsContainer;
var scoreText = new Text2('Score: 0', {
size: 14,
fill: 0xFFFFFF
});
scoreText.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreText);
var phaseText = new Text2('Catch falling currencies! Missed: 0/10', {
size: 14,
fill: 0xFFD700
});
phaseText.anchor.set(0.5, 0);
phaseText.y = 50;
LK.gui.top.addChild(phaseText);
var exchangeRateText = new Text2('Exchange Rate: 1 EUR = ' + exchangeRate + ' TL', {
size: 14,
fill: 0x00FF00
});
exchangeRateText.anchor.set(0.5, 0);
exchangeRateText.y = 80;
LK.gui.top.addChild(exchangeRateText);
function convertCurrency(amount, fromCurrency, toCurrency) {
if (fromCurrency === 'tl' && toCurrency === 'euro') {
return amount / exchangeRate;
} else if (fromCurrency === 'euro' && toCurrency === 'tl') {
return amount * exchangeRate;
}
return amount;
}
function setupFallingPhase() {
// Create hands at bottom
leftHand = new Hand('left');
leftHand.x = 400;
leftHand.y = 2600;
leftHand.updateScoreDisplay();
game.addChild(leftHand);
rightHand = new Hand('right');
rightHand.x = 1648;
rightHand.y = 2600;
rightHand.updateScoreDisplay();
game.addChild(rightHand);
// Create control interface
setupControls();
}
function setupControls() {
controlsContainer = new Container();
controlsContainer.x = 1848;
controlsContainer.y = 100;
LK.gui.addChild(controlsContainer);
var controlBg = LK.getAsset('controlButton', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2,
scaleY: 1.5
});
controlsContainer.addChild(controlBg);
var controlText = new Text2('Controls', {
size: 12,
fill: 0xFFFFFF
});
controlText.anchor.set(0.5, 0.5);
controlText.y = -30;
controlsContainer.addChild(controlText);
var mouseText = new Text2('Mouse: ON', {
size: 10,
fill: 0x00FF00
});
mouseText.anchor.set(0.5, 0.5);
controlsContainer.addChild(mouseText);
var keyText = new Text2('Keys: OFF', {
size: 10,
fill: 0xFF0000
});
keyText.anchor.set(0.5, 0.5);
keyText.y = 20;
controlsContainer.addChild(keyText);
controlsContainer.mouseText = mouseText;
controlsContainer.keyText = keyText;
controlsContainer.down = function () {
useMouseControl = !useMouseControl;
if (useMouseControl) {
controlsContainer.mouseText.setText('Mouse: ON');
controlsContainer.mouseText.style.fill = 0x00FF00;
controlsContainer.keyText.setText('Keys: OFF');
controlsContainer.keyText.style.fill = 0xFF0000;
} else {
controlsContainer.mouseText.setText('Mouse: OFF');
controlsContainer.mouseText.style.fill = 0xFF0000;
controlsContainer.keyText.setText('Keys: ON');
controlsContainer.keyText.style.fill = 0x00FF00;
}
};
}
function spawnCurrency() {
var allCurrencies = [{
type: 'Coin1kurus',
value: 0.01,
currency: 'tl'
}, {
type: 'Coin5kurus',
value: 0.05,
currency: 'tl'
}, {
type: 'Coin10kurus',
value: 0.10,
currency: 'tl'
}, {
type: 'Coin25kurus',
value: 0.25,
currency: 'tl'
}, {
type: 'Coin50kurus',
value: 0.50,
currency: 'tl'
}, {
type: 'Coin',
value: 1,
currency: 'tl'
}, {
type: 'Note',
value: 20,
currency: 'tl'
}, {
type: 'Note',
value: 50,
currency: 'tl'
}, {
type: 'Note',
value: 100,
currency: 'tl'
}, {
type: 'Note',
value: 200,
currency: 'tl'
}, {
type: 'Coin1cent',
value: 0.01,
currency: 'euro'
}, {
type: 'Coin2cent',
value: 0.02,
currency: 'euro'
}, {
type: 'Coin5cent',
value: 0.05,
currency: 'euro'
}, {
type: 'Coin10cent',
value: 0.10,
currency: 'euro'
}, {
type: 'Coin20cent',
value: 0.20,
currency: 'euro'
}, {
type: 'Coin50cent',
value: 0.50,
currency: 'euro'
}, {
type: 'Coin',
value: 1,
currency: 'euro'
}, {
type: 'Coin',
value: 2,
currency: 'euro'
}, {
type: 'Note',
value: 5,
currency: 'euro'
}, {
type: 'Note',
value: 10,
currency: 'euro'
}, {
type: 'Note',
value: 500,
currency: 'euro'
}, {
type: 'Note',
value: 1000,
currency: 'euro'
}];
var randomCurrency = allCurrencies[Math.floor(Math.random() * allCurrencies.length)];
var fallingItem = new FallingCurrency(randomCurrency.type, randomCurrency.value, randomCurrency.currency);
fallingItem.x = Math.random() * 1800 + 124; // Random X within screen bounds
fallingItem.y = -100;
fallingItem.lastY = fallingItem.y;
fallingItem.lastCaught = false;
fallingItems.push(fallingItem);
game.addChild(fallingItem);
}
function showCalculator() {
phaseText.setText('Use calculator to convert currencies');
// Clear falling items
for (var i = 0; i < fallingItems.length; i++) {
fallingItems[i].destroy();
}
fallingItems = [];
// Clear hands
if (leftHand) leftHand.destroy();
if (rightHand) rightHand.destroy();
if (controlsContainer) controlsContainer.destroy();
calculator = new Calculator();
calculator.x = 1024;
calculator.y = 1400;
game.addChild(calculator);
}
function showAssessment() {
phaseText.setText('Game Over!');
// Clear all falling items
for (var i = 0; i < fallingItems.length; i++) {
fallingItems[i].destroy();
}
fallingItems = [];
// Clear hands and controls
if (leftHand) leftHand.destroy();
if (rightHand) rightHand.destroy();
if (controlsContainer) controlsContainer.destroy();
if (calculator) {
calculator.destroy();
}
var finalScore = LK.getScore();
// Display final score in center
var scoreDisplayText = new Text2('Final Score: ' + finalScore, {
size: 135,
fill: 0xFFD700
});
scoreDisplayText.anchor.set(0.5, 0.5);
scoreDisplayText.x = 1024;
scoreDisplayText.y = 1200;
game.addChild(scoreDisplayText);
// Create game play button
var gamePlayButton = new Container();
var buttonBg = LK.getAsset('calcButton', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 7.5,
scaleY: 10
});
gamePlayButton.addChild(buttonBg);
var buttonText = new Text2('PLAY AGAIN', {
size: 135,
fill: 0xFFFFFF
});
buttonText.anchor.set(0.5, 0.5);
gamePlayButton.addChild(buttonText);
gamePlayButton.x = 1024;
gamePlayButton.y = 1400;
game.addChild(gamePlayButton);
gamePlayButton.down = function () {
LK.getSound('click').play();
// Reset game state
gamePhase = 'falling';
caughtItems = 0;
missedItems = 0;
spawnTimer = 0;
spawnRate = 60;
LK.setScore(0);
scoreText.setText('Score: 0');
phaseText.setText('Catch falling currencies! Missed: 0/10');
// Clear current game elements
scoreDisplayText.destroy();
gamePlayButton.destroy();
game.setBackgroundColor(0x1a1a2e);
// Restart falling phase
setupFallingPhase();
};
}
game.move = function (x, y, obj) {
if (gamePhase === 'falling' && useMouseControl) {
// Move hands based on mouse position
if (x < 1024) {
leftHand.x = x;
leftHand.updateScoreDisplay();
} else {
rightHand.x = x;
rightHand.updateScoreDisplay();
}
}
};
game.update = function () {
if (gamePhase === 'falling') {
// Handle keyboard controls
if (!useMouseControl) {
// Simple keyboard simulation using ticks
if (LK.ticks % 3 === 0) {
leftHand.x = Math.max(100, leftHand.x - 5);
leftHand.updateScoreDisplay();
}
if (LK.ticks % 4 === 0) {
leftHand.x = Math.min(1024, leftHand.x + 5);
leftHand.updateScoreDisplay();
}
if (LK.ticks % 5 === 0) {
rightHand.x = Math.max(1024, rightHand.x - 5);
rightHand.updateScoreDisplay();
}
if (LK.ticks % 6 === 0) {
rightHand.x = Math.min(1948, rightHand.x + 5);
rightHand.updateScoreDisplay();
}
}
// Spawn currency
spawnTimer++;
if (spawnTimer >= spawnRate) {
spawnCurrency();
spawnTimer = 0;
// Gradually increase spawn rate
if (spawnRate > 20) {
spawnRate--;
}
}
// Update falling items
for (var i = fallingItems.length - 1; i >= 0; i--) {
var item = fallingItems[i];
// Check if caught by hands
var currentCaught = item.intersects(leftHand) || item.intersects(rightHand);
if (!item.lastCaught && currentCaught) {
// Just caught
caughtItems++;
LK.setScore(LK.getScore() + Math.floor(item.value * 10));
scoreText.setText('Score: ' + LK.getScore());
if (leftHand) leftHand.updateScoreDisplay();
if (rightHand) rightHand.updateScoreDisplay();
LK.getSound('money').play();
item.destroy();
fallingItems.splice(i, 1);
continue;
}
item.lastCaught = currentCaught;
// Check if item fell off screen
if (item.lastY <= 2732 && item.y > 2732) {
missedItems++;
phaseText.setText('Catch falling currencies! Missed: ' + missedItems + '/' + maxMissed);
item.destroy();
fallingItems.splice(i, 1);
if (missedItems >= maxMissed) {
gamePhase = 'calculator';
showCalculator();
}
continue;
}
item.lastY = item.y;
}
}
};
setupFallingPhase();