/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var EarnButton = Container.expand(function () {
var self = Container.call(this);
var buttonGraphics = self.attachAsset('earnButton', {
anchorX: 0.5,
anchorY: 0.5
});
var buttonText = new Text2('KAZAN!', {
size: 70,
fill: 0x000000
});
buttonText.anchor.set(0.5, 0.5);
self.addChild(buttonText);
self.down = function (x, y, obj) {
LK.getSound('earn').play();
self.parent.earnMoney();
};
return self;
});
var ResetButton = Container.expand(function () {
var self = Container.call(this);
var buttonGraphics = self.attachAsset('resetButton', {
anchorX: 0.5,
anchorY: 0.5
});
var buttonText = new Text2('SIFIRLA', {
size: 80,
fill: 0xFFFFFF
});
buttonText.anchor.set(0.5, 0.5);
self.addChild(buttonText);
self.down = function (x, y, obj) {
LK.getSound('click').play();
self.parent.resetBalance();
};
return self;
});
var StartButton = Container.expand(function () {
var self = Container.call(this);
var buttonGraphics = self.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
var buttonText = new Text2('BAŞLA!', {
size: 80,
fill: 0xFFFFFF
});
buttonText.anchor.set(0.5, 0.5);
self.addChild(buttonText);
self.down = function (x, y, obj) {
LK.getSound('click').play();
self.parent.startGame();
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x2196F3
});
/****
* Game Code
****/
var balance = storage.balance || 0;
var currentEarnings = 0;
var gameTime = 0;
var isGameActive = false;
var gameTimer = null;
var startButton = new StartButton();
startButton.x = 2048 / 2;
startButton.y = 2732 / 2;
game.addChild(startButton);
var earnButton = new EarnButton();
earnButton.x = 2048 / 2;
earnButton.y = 2732 / 2 + 50;
earnButton.visible = false;
game.addChild(earnButton);
var balanceText = new Text2('BAKİYE: ' + balance + ' TL', {
size: 60,
fill: 0xFFFFFF
});
balanceText.anchor.set(0.5, 1);
LK.gui.bottom.addChild(balanceText);
var resetButton = new ResetButton();
resetButton.x = 2048 / 2;
resetButton.y = 2732 - 300;
game.addChild(resetButton);
var timerText = new Text2('', {
size: 100,
fill: 0xFFFFFF
});
timerText.anchor.set(0.5, 0);
LK.gui.top.addChild(timerText);
var earningsText = new Text2('', {
size: 80,
fill: 0xFFD700
});
earningsText.anchor.set(0.5, 0.5);
earningsText.x = 2048 / 2;
earningsText.y = 2732 / 2 - 200;
earningsText.visible = false;
game.addChild(earningsText);
game.startGame = function () {
isGameActive = true;
gameTime = 10;
currentEarnings = 0;
startButton.visible = false;
earnButton.visible = true;
earningsText.visible = true;
earningsText.setText('0 TL');
gameTimer = LK.setInterval(function () {
gameTime--;
timerText.setText(gameTime + ' saniye');
if (gameTime <= 0) {
game.endGame();
}
}, 1000);
timerText.setText(gameTime + ' saniye');
};
game.earnMoney = function () {
if (!isGameActive) return;
currentEarnings += 20;
earningsText.setText(currentEarnings + ' TL');
tween(earnButton, {
scaleX: 1.1,
scaleY: 1.1
}, {
duration: 100,
onFinish: function onFinish() {
tween(earnButton, {
scaleX: 1,
scaleY: 1
}, {
duration: 100
});
}
});
};
game.endGame = function () {
isGameActive = false;
LK.clearInterval(gameTimer);
balance += currentEarnings;
storage.balance = balance;
earnButton.visible = false;
earningsText.visible = false;
timerText.setText('');
balanceText.setText('BAKİYE: ' + balance + ' TL');
LK.getSound('timeUp').play();
tween(balanceText, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 300,
onFinish: function onFinish() {
tween(balanceText, {
scaleX: 1,
scaleY: 1
}, {
duration: 300
});
}
});
LK.setTimeout(function () {
startButton.visible = true;
}, 1000);
};
game.resetBalance = function () {
balance = 0;
storage.balance = balance;
balanceText.setText('BAKİYE: ' + balance + ' TL');
tween(balanceText, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 200,
onFinish: function onFinish() {
tween(balanceText, {
scaleX: 1,
scaleY: 1
}, {
duration: 200
});
}
});
};
game.update = function () {
// Game update logic if needed
}; /****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var EarnButton = Container.expand(function () {
var self = Container.call(this);
var buttonGraphics = self.attachAsset('earnButton', {
anchorX: 0.5,
anchorY: 0.5
});
var buttonText = new Text2('KAZAN!', {
size: 70,
fill: 0x000000
});
buttonText.anchor.set(0.5, 0.5);
self.addChild(buttonText);
self.down = function (x, y, obj) {
LK.getSound('earn').play();
self.parent.earnMoney();
};
return self;
});
var ResetButton = Container.expand(function () {
var self = Container.call(this);
var buttonGraphics = self.attachAsset('resetButton', {
anchorX: 0.5,
anchorY: 0.5
});
var buttonText = new Text2('SIFIRLA', {
size: 80,
fill: 0xFFFFFF
});
buttonText.anchor.set(0.5, 0.5);
self.addChild(buttonText);
self.down = function (x, y, obj) {
LK.getSound('click').play();
self.parent.resetBalance();
};
return self;
});
var StartButton = Container.expand(function () {
var self = Container.call(this);
var buttonGraphics = self.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
var buttonText = new Text2('BAŞLA!', {
size: 80,
fill: 0xFFFFFF
});
buttonText.anchor.set(0.5, 0.5);
self.addChild(buttonText);
self.down = function (x, y, obj) {
LK.getSound('click').play();
self.parent.startGame();
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x2196F3
});
/****
* Game Code
****/
var balance = storage.balance || 0;
var currentEarnings = 0;
var gameTime = 0;
var isGameActive = false;
var gameTimer = null;
var startButton = new StartButton();
startButton.x = 2048 / 2;
startButton.y = 2732 / 2;
game.addChild(startButton);
var earnButton = new EarnButton();
earnButton.x = 2048 / 2;
earnButton.y = 2732 / 2 + 50;
earnButton.visible = false;
game.addChild(earnButton);
var balanceText = new Text2('BAKİYE: ' + balance + ' TL', {
size: 60,
fill: 0xFFFFFF
});
balanceText.anchor.set(0.5, 1);
LK.gui.bottom.addChild(balanceText);
var resetButton = new ResetButton();
resetButton.x = 2048 / 2;
resetButton.y = 2732 - 300;
game.addChild(resetButton);
var timerText = new Text2('', {
size: 100,
fill: 0xFFFFFF
});
timerText.anchor.set(0.5, 0);
LK.gui.top.addChild(timerText);
var earningsText = new Text2('', {
size: 80,
fill: 0xFFD700
});
earningsText.anchor.set(0.5, 0.5);
earningsText.x = 2048 / 2;
earningsText.y = 2732 / 2 - 200;
earningsText.visible = false;
game.addChild(earningsText);
game.startGame = function () {
isGameActive = true;
gameTime = 10;
currentEarnings = 0;
startButton.visible = false;
earnButton.visible = true;
earningsText.visible = true;
earningsText.setText('0 TL');
gameTimer = LK.setInterval(function () {
gameTime--;
timerText.setText(gameTime + ' saniye');
if (gameTime <= 0) {
game.endGame();
}
}, 1000);
timerText.setText(gameTime + ' saniye');
};
game.earnMoney = function () {
if (!isGameActive) return;
currentEarnings += 20;
earningsText.setText(currentEarnings + ' TL');
tween(earnButton, {
scaleX: 1.1,
scaleY: 1.1
}, {
duration: 100,
onFinish: function onFinish() {
tween(earnButton, {
scaleX: 1,
scaleY: 1
}, {
duration: 100
});
}
});
};
game.endGame = function () {
isGameActive = false;
LK.clearInterval(gameTimer);
balance += currentEarnings;
storage.balance = balance;
earnButton.visible = false;
earningsText.visible = false;
timerText.setText('');
balanceText.setText('BAKİYE: ' + balance + ' TL');
LK.getSound('timeUp').play();
tween(balanceText, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 300,
onFinish: function onFinish() {
tween(balanceText, {
scaleX: 1,
scaleY: 1
}, {
duration: 300
});
}
});
LK.setTimeout(function () {
startButton.visible = true;
}, 1000);
};
game.resetBalance = function () {
balance = 0;
storage.balance = balance;
balanceText.setText('BAKİYE: ' + balance + ' TL');
tween(balanceText, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 200,
onFinish: function onFinish() {
tween(balanceText, {
scaleX: 1,
scaleY: 1
}, {
duration: 200
});
}
});
};
game.update = function () {
// Game update logic if needed
};