/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ var Astronaut = Container.expand(function () { var self = Container.call(this); var astronautGraphics = self.attachAsset('astronaut', { anchorX: 0.5, anchorY: 0.5 }); astronautGraphics.scaleX = 0.8; astronautGraphics.scaleY = 0.8; self.speed = 8; self.update = function () { self.y += self.speed; if (self.y > 2800) { self.destroy(); } }; return self; }); var CashOutButton = Container.expand(function () { var self = Container.call(this); var buttonBg = self.attachAsset('cashOutButton', { anchorX: 0.5, anchorY: 0.5 }); var buttonText = new Text2('CASH OUT', { size: 64, fill: 0xFFFFFF }); buttonText.anchor.set(0.5, 0.5); buttonText.y = -8; // Move button text up slightly self.addChild(buttonText); var winningsText = new Text2('$0', { size: 48, fill: 0xFFFFFF }); winningsText.anchor.set(0.5, 0.5); winningsText.x = 0; // Center horizontally in button winningsText.y = 15; // Position below button text self.addChild(winningsText); self.updateWinnings = function (multiplier, bet) { var potentialWinnings = Math.floor(bet * multiplier); winningsText.setText('$' + potentialWinnings); }; self.down = function (x, y, obj) { if (gameState === 'flying') { cashOut(); } }; return self; }); var Rocket = Container.expand(function () { var self = Container.call(this); var rocketGraphics = self.attachAsset('rocket', { anchorX: 0.5, anchorY: 1.0 }); var flame = self.attachAsset('flame', { anchorX: 0.5, anchorY: 0, y: -10 }); self.speed = 0; self.trailTimer = 0; self.update = function () { // Add flame animation flame.scaleX = 0.8 + Math.sin(LK.ticks * 0.3) * 0.3; flame.scaleY = 0.8 + Math.sin(LK.ticks * 0.2) * 0.4; // Create trail particles self.trailTimer++; if (self.trailTimer % 3 === 0) { var trail = new TrailParticle(); trail.x = self.x + (Math.random() - 0.5) * 20; trail.y = self.y + 10; game.addChild(trail); trailParticles.push(trail); } }; return self; }); var TrailParticle = Container.expand(function () { var self = Container.call(this); var graphics = self.attachAsset('trail', { anchorX: 0.5, anchorY: 0.5 }); self.life = 60; self.maxLife = 60; self.update = function () { self.life--; graphics.alpha = self.life / self.maxLife; if (self.life <= 0) { self.destroy(); } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x001122 }); /**** * Game Code ****/ // Game state variables var gameState = 'betting'; // 'betting', 'flying', 'crashed' var currentMultiplier = 1.0; var betAmount = 10; var crashPoint = 0; var rocketStartY = 2100; // Move rocket up to accommodate repositioned buttons var rocketCurrentY = rocketStartY; var flightStartTime = 0; var hasPlayerCashedOut = false; var playerBalance = storage.balance || 1000; var trailParticles = []; var previousCrashes = storage.crashes || []; // UI Elements var backgroundGraphics = game.attachAsset('background', { anchorX: 0, anchorY: 0 }); var rocket = new Rocket(); rocket.x = 1024; rocket.y = rocketStartY; game.addChild(rocket); var multiplierBackground = LK.getAsset('multiplierBackground', { anchorX: 0.5, anchorY: 0.5 }); LK.gui.top.addChild(multiplierBackground); multiplierBackground.y = 240; var multiplierText = new Text2('1.00x', { size: 80, fill: 0xFFFFFF }); multiplierText.anchor.set(0.5, 0); LK.gui.top.addChild(multiplierText); multiplierText.y = 200; var websiteText = new Text2('vayabi560.com', { size: 40, fill: 0xFFFFFF, font: "'Arial Black', 'Helvetica-Bold', sans-serif" }); websiteText.anchor.set(0.5, 0); LK.gui.top.addChild(websiteText); websiteText.y = 380; var balanceText = new Text2('Balance: $' + Math.floor(playerBalance), { size: 40, fill: 0xFFFFFF }); balanceText.anchor.set(0, 0); LK.gui.topLeft.addChild(balanceText); balanceText.x = 120; balanceText.y = 20; var betText = new Text2('Bet: $' + betAmount, { size: 50, fill: 0xFFFFFF }); betText.anchor.set(0.5, 1); LK.gui.bottom.addChild(betText); betText.y = -200; var statusText = new Text2('Place your bet and tap to launch!\nBahsini yerleĆtir ve launch butonuna tıkla', { size: 35, fill: 0xFFFF00 }); statusText.anchor.set(0.5, 1); statusText.x = rocket.x; statusText.y = rocket.y - 250; game.addChild(statusText); var cashOutButton = new CashOutButton(); cashOutButton.x = 1300; // Right side of screen with margin cashOutButton.y = 2400; // Lower position for mobile comfort cashOutButton.scaleX = 0.8; // Make smaller for mobile cashOutButton.scaleY = 0.8; cashOutButton.alpha = 0; game.addChild(cashOutButton); // Bet control buttons var minusButton = game.attachAsset('betButton', { anchorX: 0.5, anchorY: 0.5, x: 300, y: 2580, scaleX: 0.7, scaleY: 0.7 }); var minusButtonText = new Text2('-', { size: 35, fill: 0xFFFFFF, font: "'Arial Black', 'Helvetica-Bold', sans-serif" }); minusButtonText.anchor.set(0.5, 0.5); minusButtonText.x = 300; minusButtonText.y = 2580; game.addChild(minusButtonText); var plusButton = game.attachAsset('betButton', { anchorX: 0.5, anchorY: 0.5, x: 500, y: 2580, scaleX: 0.7, scaleY: 0.7 }); var plusButtonText = new Text2('+', { size: 35, fill: 0xFFFFFF, font: "'Arial Black', 'Helvetica-Bold', sans-serif" }); plusButtonText.anchor.set(0.5, 0.5); plusButtonText.x = 500; plusButtonText.y = 2580; game.addChild(plusButtonText); var minButton = game.attachAsset('betButton', { anchorX: 0.5, anchorY: 0.5, x: 700, y: 2580, scaleX: 0.7, scaleY: 0.7 }); var minButtonText = new Text2('MIN', { size: 40, fill: 0xFFFFFF, font: "'Arial Black', 'Helvetica-Bold', sans-serif" }); minButtonText.anchor.set(0.5, 0.5); minButtonText.x = 700; minButtonText.y = 2580; game.addChild(minButtonText); var maxButton = game.attachAsset('betButton', { anchorX: 0.5, anchorY: 0.5, x: 900, y: 2580, scaleX: 0.7, scaleY: 0.7 }); var maxButtonText = new Text2('MAX', { size: 40, fill: 0xFFFFFF, font: "'Arial Black', 'Helvetica-Bold', sans-serif" }); maxButtonText.anchor.set(0.5, 0.5); maxButtonText.x = 900; maxButtonText.y = 2580; game.addChild(maxButtonText); var percent25Button = game.attachAsset('betButton', { anchorX: 0.5, anchorY: 0.5, x: 1100, y: 2580, scaleX: 0.7, scaleY: 0.7 }); var percent25ButtonText = new Text2('25%', { size: 40, fill: 0xFFFFFF, font: "'Arial Black', 'Helvetica-Bold', sans-serif" }); percent25ButtonText.anchor.set(0.5, 0.5); percent25ButtonText.x = 1100; percent25ButtonText.y = 2580; game.addChild(percent25ButtonText); var percent50Button = game.attachAsset('betButton', { anchorX: 0.5, anchorY: 0.5, x: 1300, y: 2580, scaleX: 0.7, scaleY: 0.7 }); var percent50ButtonText = new Text2('50%', { size: 40, fill: 0xFFFFFF, font: "'Arial Black', 'Helvetica-Bold', sans-serif" }); percent50ButtonText.anchor.set(0.5, 0.5); percent50ButtonText.x = 1300; percent50ButtonText.y = 2580; game.addChild(percent50ButtonText); var percent75Button = game.attachAsset('betButton', { anchorX: 0.5, anchorY: 0.5, x: 1500, y: 2580, scaleX: 0.7, scaleY: 0.7 }); var percent75ButtonText = new Text2('75%', { size: 40, fill: 0xFFFFFF, font: "'Arial Black', 'Helvetica-Bold', sans-serif" }); percent75ButtonText.anchor.set(0.5, 0.5); percent75ButtonText.x = 1500; percent75ButtonText.y = 2580; game.addChild(percent75ButtonText); var betButton = game.attachAsset('playButton', { anchorX: 0.5, anchorY: 0.5, x: 748, // Left side of screen with margin y: 2400, // Match cashout button height scaleX: 0.8, // Make smaller for mobile scaleY: 0.8 }); var betButtonText = new Text2('PLAY ($' + betAmount + ')', { size: 50, fill: 0xFFFFFF, font: "'Arial Black', 'Helvetica-Bold', sans-serif" }); betButtonText.anchor.set(0.5, 0.5); betButtonText.x = 748; // Match button position betButtonText.y = 2400; game.addChild(betButtonText); // Previous crashes display var crashHistoryText = new Text2('Previous crashes: ' + (previousCrashes.length > 0 ? previousCrashes.slice(-5).join('x, ') + 'x' : 'None'), { size: 30, fill: 0x888888 }); crashHistoryText.anchor.set(0.5, 0); LK.gui.top.addChild(crashHistoryText); crashHistoryText.y = 120; // Logo button var logoButton = game.attachAsset('logo', { anchorX: 1.0, anchorY: 0.0, x: 1948, y: 100 }); function updateBetAmount() { betText.setText('Bet: $' + betAmount); betButtonText.setText('PLAY ($' + betAmount + ')'); } function generateCrashPoint() { // Generate crash point between 1.01x and 10.00x with higher probability for lower values var random = Math.random(); if (random < 0.5) { return 1.01 + Math.random() * 1.99; // 1.01x - 3.00x (50% chance) } else if (random < 0.8) { return 3.0 + Math.random() * 2.0; // 3.00x - 5.00x (30% chance) } else { return 5.0 + Math.random() * 5.0; // 5.00x - 10.00x (20% chance) } } function startRound() { if (playerBalance < betAmount) { statusText.setText('Insufficient balance!'); return; } gameState = 'flying'; playerBalance -= betAmount; hasPlayerCashedOut = false; crashPoint = generateCrashPoint(); flightStartTime = LK.ticks; rocketCurrentY = rocketStartY; currentMultiplier = 1.0; // Update UI balanceText.setText('Balance: $' + Math.floor(playerBalance)); statusText.setText('Cash out before it crashes!\nĂakılmadan önce parayı çek!'); statusText.x = rocket.x; statusText.y = rocket.y - 320; // Show cash out button tween(cashOutButton, { alpha: 1 }, { duration: 300 }); // Hide bet button tween(betButton, { alpha: 0 }, { duration: 300 }); tween(betButtonText, { alpha: 0 }, { duration: 300 }); LK.getSound('launch').play(); } function cashOut() { if (gameState !== 'flying' || hasPlayerCashedOut) return; hasPlayerCashedOut = true; var winnings = Math.floor(betAmount * currentMultiplier); playerBalance += winnings; statusText.setText('Cashed out! Won $' + winnings); balanceText.setText('Balance: $' + Math.floor(playerBalance)); // Spawn astronaut animation var astronaut = new Astronaut(); astronaut.x = rocket.x + 80; astronaut.y = rocket.y; game.addChild(astronaut); // Hide cash out button tween(cashOutButton, { alpha: 0 }, { duration: 300 }); LK.getSound('cashout').play(); // End round after delay LK.setTimeout(function () { endRound(); }, 2000); } function crashRocket() { gameState = 'crashed'; if (!hasPlayerCashedOut) { statusText.setText('CRASHED! You lost $' + betAmount); } // Add crash point to history previousCrashes.push(parseFloat(currentMultiplier.toFixed(2))); if (previousCrashes.length > 10) { previousCrashes.shift(); } // Flash screen red LK.effects.flashScreen(0xff0000, 500); // Hide cash out button tween(cashOutButton, { alpha: 0 }, { duration: 300 }); LK.getSound('crash').play(); // End round after delay LK.setTimeout(function () { endRound(); }, 2000); } function endRound() { gameState = 'betting'; // Reset rocket position rocket.y = rocketStartY; rocketCurrentY = rocketStartY; // Clear trail particles for (var i = trailParticles.length - 1; i >= 0; i--) { trailParticles[i].destroy(); trailParticles.splice(i, 1); } // Show bet button betButton.alpha = 1; betButtonText.alpha = 1; betButtonText.setText('PLAY ($' + betAmount + ')'); // Update crash history crashHistoryText.setText('Previous crashes: ' + (previousCrashes.length > 0 ? previousCrashes.slice(-5).join('x, ') + 'x' : 'None')); statusText.setText('Place your bet and tap to launch!\nBahsini yerleĆtir ve launch butonuna tıkla'); statusText.x = rocket.x; statusText.y = rocket.y - 320; // Save data storage.balance = playerBalance; storage.crashes = previousCrashes; } // Event handlers game.down = function (x, y, obj) { // Check if bet button was clicked during betting phase if (gameState === 'betting') { // Check minus button var minusLeft = minusButton.x - minusButton.width * 0.7 / 2; var minusRight = minusButton.x + minusButton.width * 0.7 / 2; var minusTop = minusButton.y - minusButton.height * 0.7 / 2; var minusBottom = minusButton.y + minusButton.height * 0.7 / 2; if (x >= minusLeft && x <= minusRight && y >= minusTop && y <= minusBottom) { betAmount = Math.max(1, betAmount - 1); updateBetAmount(); return; } // Check plus button var plusLeft = plusButton.x - plusButton.width * 0.7 / 2; var plusRight = plusButton.x + plusButton.width * 0.7 / 2; var plusTop = plusButton.y - plusButton.height * 0.7 / 2; var plusBottom = plusButton.y + plusButton.height * 0.7 / 2; if (x >= plusLeft && x <= plusRight && y >= plusTop && y <= plusBottom) { betAmount = Math.min(playerBalance, betAmount + 1); updateBetAmount(); return; } // Check min button var minBtnLeft = minButton.x - minButton.width / 2; var minBtnRight = minButton.x + minButton.width / 2; var minBtnTop = minButton.y - minButton.height / 2; var minBtnBottom = minButton.y + minButton.height / 2; if (x >= minBtnLeft && x <= minBtnRight && y >= minBtnTop && y <= minBtnBottom) { betAmount = 1; updateBetAmount(); return; } // Check max button var maxBtnLeft = maxButton.x - maxButton.width / 2; var maxBtnRight = maxButton.x + maxButton.width / 2; var maxBtnTop = maxButton.y - maxButton.height / 2; var maxBtnBottom = maxButton.y + maxButton.height / 2; if (x >= maxBtnLeft && x <= maxBtnRight && y >= maxBtnTop && y <= maxBtnBottom) { betAmount = Math.floor(playerBalance); updateBetAmount(); return; } // Check 25% button var p25Left = percent25Button.x - percent25Button.width / 2; var p25Right = percent25Button.x + percent25Button.width / 2; var p25Top = percent25Button.y - percent25Button.height / 2; var p25Bottom = percent25Button.y + percent25Button.height / 2; if (x >= p25Left && x <= p25Right && y >= p25Top && y <= p25Bottom) { betAmount = Math.floor(playerBalance * 0.25); updateBetAmount(); return; } // Check 50% button var p50Left = percent50Button.x - percent50Button.width / 2; var p50Right = percent50Button.x + percent50Button.width / 2; var p50Top = percent50Button.y - percent50Button.height / 2; var p50Bottom = percent50Button.y + percent50Button.height / 2; if (x >= p50Left && x <= p50Right && y >= p50Top && y <= p50Bottom) { betAmount = Math.floor(playerBalance * 0.5); updateBetAmount(); return; } // Check 75% button var p75Left = percent75Button.x - percent75Button.width / 2; var p75Right = percent75Button.x + percent75Button.width / 2; var p75Top = percent75Button.y - percent75Button.height / 2; var p75Bottom = percent75Button.y + percent75Button.height / 2; if (x >= p75Left && x <= p75Right && y >= p75Top && y <= p75Bottom) { betAmount = Math.floor(playerBalance * 0.75); updateBetAmount(); return; } // Check if launch button was clicked var buttonLeft = betButton.x - betButton.width * 0.8 / 2; var buttonRight = betButton.x + betButton.width * 0.8 / 2; var buttonTop = betButton.y - betButton.height * 0.8 / 2; var buttonBottom = betButton.y + betButton.height * 0.8 / 2; if (x >= buttonLeft && x <= buttonRight && y >= buttonTop && y <= buttonBottom) { startRound(); } } // Check logo button click var logoLeft = logoButton.x - logoButton.width; var logoRight = logoButton.x; var logoTop = logoButton.y; var logoBottom = logoButton.y + logoButton.height; if (x >= logoLeft && x <= logoRight && y >= logoTop && y <= logoBottom) { console.log('Logo clicked - would redirect to https://vayabi5559.com'); return; } }; game.update = function () { // Update trail particles for (var i = trailParticles.length - 1; i >= 0; i--) { if (trailParticles[i] && trailParticles[i].life <= 0) { trailParticles.splice(i, 1); } } if (gameState === 'flying') { // Calculate flight time and multiplier var flightTime = (LK.ticks - flightStartTime) / 60; // Convert to seconds currentMultiplier = 1.0 + flightTime * 0.5; // Multiplier increases by 0.5 per second // Update rocket position (move up as multiplier increases) var progress = (currentMultiplier - 1.0) / 9.0; // Progress from 0 to 1 over 9x multiplier rocket.y = rocketStartY - progress * 1800; // Add slight wobble to rocket rocket.x = 1024 + Math.sin(LK.ticks * 0.1) * 10; // Update multiplier display multiplierText.setText(currentMultiplier.toFixed(2) + 'x'); // Update potential winnings display cashOutButton.updateWinnings(currentMultiplier, betAmount); // Check if rocket should crash if (currentMultiplier >= crashPoint && !hasPlayerCashedOut) { crashRocket(); } } };
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var Astronaut = Container.expand(function () {
var self = Container.call(this);
var astronautGraphics = self.attachAsset('astronaut', {
anchorX: 0.5,
anchorY: 0.5
});
astronautGraphics.scaleX = 0.8;
astronautGraphics.scaleY = 0.8;
self.speed = 8;
self.update = function () {
self.y += self.speed;
if (self.y > 2800) {
self.destroy();
}
};
return self;
});
var CashOutButton = Container.expand(function () {
var self = Container.call(this);
var buttonBg = self.attachAsset('cashOutButton', {
anchorX: 0.5,
anchorY: 0.5
});
var buttonText = new Text2('CASH OUT', {
size: 64,
fill: 0xFFFFFF
});
buttonText.anchor.set(0.5, 0.5);
buttonText.y = -8; // Move button text up slightly
self.addChild(buttonText);
var winningsText = new Text2('$0', {
size: 48,
fill: 0xFFFFFF
});
winningsText.anchor.set(0.5, 0.5);
winningsText.x = 0; // Center horizontally in button
winningsText.y = 15; // Position below button text
self.addChild(winningsText);
self.updateWinnings = function (multiplier, bet) {
var potentialWinnings = Math.floor(bet * multiplier);
winningsText.setText('$' + potentialWinnings);
};
self.down = function (x, y, obj) {
if (gameState === 'flying') {
cashOut();
}
};
return self;
});
var Rocket = Container.expand(function () {
var self = Container.call(this);
var rocketGraphics = self.attachAsset('rocket', {
anchorX: 0.5,
anchorY: 1.0
});
var flame = self.attachAsset('flame', {
anchorX: 0.5,
anchorY: 0,
y: -10
});
self.speed = 0;
self.trailTimer = 0;
self.update = function () {
// Add flame animation
flame.scaleX = 0.8 + Math.sin(LK.ticks * 0.3) * 0.3;
flame.scaleY = 0.8 + Math.sin(LK.ticks * 0.2) * 0.4;
// Create trail particles
self.trailTimer++;
if (self.trailTimer % 3 === 0) {
var trail = new TrailParticle();
trail.x = self.x + (Math.random() - 0.5) * 20;
trail.y = self.y + 10;
game.addChild(trail);
trailParticles.push(trail);
}
};
return self;
});
var TrailParticle = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('trail', {
anchorX: 0.5,
anchorY: 0.5
});
self.life = 60;
self.maxLife = 60;
self.update = function () {
self.life--;
graphics.alpha = self.life / self.maxLife;
if (self.life <= 0) {
self.destroy();
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x001122
});
/****
* Game Code
****/
// Game state variables
var gameState = 'betting'; // 'betting', 'flying', 'crashed'
var currentMultiplier = 1.0;
var betAmount = 10;
var crashPoint = 0;
var rocketStartY = 2100; // Move rocket up to accommodate repositioned buttons
var rocketCurrentY = rocketStartY;
var flightStartTime = 0;
var hasPlayerCashedOut = false;
var playerBalance = storage.balance || 1000;
var trailParticles = [];
var previousCrashes = storage.crashes || [];
// UI Elements
var backgroundGraphics = game.attachAsset('background', {
anchorX: 0,
anchorY: 0
});
var rocket = new Rocket();
rocket.x = 1024;
rocket.y = rocketStartY;
game.addChild(rocket);
var multiplierBackground = LK.getAsset('multiplierBackground', {
anchorX: 0.5,
anchorY: 0.5
});
LK.gui.top.addChild(multiplierBackground);
multiplierBackground.y = 240;
var multiplierText = new Text2('1.00x', {
size: 80,
fill: 0xFFFFFF
});
multiplierText.anchor.set(0.5, 0);
LK.gui.top.addChild(multiplierText);
multiplierText.y = 200;
var websiteText = new Text2('vayabi560.com', {
size: 40,
fill: 0xFFFFFF,
font: "'Arial Black', 'Helvetica-Bold', sans-serif"
});
websiteText.anchor.set(0.5, 0);
LK.gui.top.addChild(websiteText);
websiteText.y = 380;
var balanceText = new Text2('Balance: $' + Math.floor(playerBalance), {
size: 40,
fill: 0xFFFFFF
});
balanceText.anchor.set(0, 0);
LK.gui.topLeft.addChild(balanceText);
balanceText.x = 120;
balanceText.y = 20;
var betText = new Text2('Bet: $' + betAmount, {
size: 50,
fill: 0xFFFFFF
});
betText.anchor.set(0.5, 1);
LK.gui.bottom.addChild(betText);
betText.y = -200;
var statusText = new Text2('Place your bet and tap to launch!\nBahsini yerleĆtir ve launch butonuna tıkla', {
size: 35,
fill: 0xFFFF00
});
statusText.anchor.set(0.5, 1);
statusText.x = rocket.x;
statusText.y = rocket.y - 250;
game.addChild(statusText);
var cashOutButton = new CashOutButton();
cashOutButton.x = 1300; // Right side of screen with margin
cashOutButton.y = 2400; // Lower position for mobile comfort
cashOutButton.scaleX = 0.8; // Make smaller for mobile
cashOutButton.scaleY = 0.8;
cashOutButton.alpha = 0;
game.addChild(cashOutButton);
// Bet control buttons
var minusButton = game.attachAsset('betButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 300,
y: 2580,
scaleX: 0.7,
scaleY: 0.7
});
var minusButtonText = new Text2('-', {
size: 35,
fill: 0xFFFFFF,
font: "'Arial Black', 'Helvetica-Bold', sans-serif"
});
minusButtonText.anchor.set(0.5, 0.5);
minusButtonText.x = 300;
minusButtonText.y = 2580;
game.addChild(minusButtonText);
var plusButton = game.attachAsset('betButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 500,
y: 2580,
scaleX: 0.7,
scaleY: 0.7
});
var plusButtonText = new Text2('+', {
size: 35,
fill: 0xFFFFFF,
font: "'Arial Black', 'Helvetica-Bold', sans-serif"
});
plusButtonText.anchor.set(0.5, 0.5);
plusButtonText.x = 500;
plusButtonText.y = 2580;
game.addChild(plusButtonText);
var minButton = game.attachAsset('betButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 700,
y: 2580,
scaleX: 0.7,
scaleY: 0.7
});
var minButtonText = new Text2('MIN', {
size: 40,
fill: 0xFFFFFF,
font: "'Arial Black', 'Helvetica-Bold', sans-serif"
});
minButtonText.anchor.set(0.5, 0.5);
minButtonText.x = 700;
minButtonText.y = 2580;
game.addChild(minButtonText);
var maxButton = game.attachAsset('betButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 900,
y: 2580,
scaleX: 0.7,
scaleY: 0.7
});
var maxButtonText = new Text2('MAX', {
size: 40,
fill: 0xFFFFFF,
font: "'Arial Black', 'Helvetica-Bold', sans-serif"
});
maxButtonText.anchor.set(0.5, 0.5);
maxButtonText.x = 900;
maxButtonText.y = 2580;
game.addChild(maxButtonText);
var percent25Button = game.attachAsset('betButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 1100,
y: 2580,
scaleX: 0.7,
scaleY: 0.7
});
var percent25ButtonText = new Text2('25%', {
size: 40,
fill: 0xFFFFFF,
font: "'Arial Black', 'Helvetica-Bold', sans-serif"
});
percent25ButtonText.anchor.set(0.5, 0.5);
percent25ButtonText.x = 1100;
percent25ButtonText.y = 2580;
game.addChild(percent25ButtonText);
var percent50Button = game.attachAsset('betButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 1300,
y: 2580,
scaleX: 0.7,
scaleY: 0.7
});
var percent50ButtonText = new Text2('50%', {
size: 40,
fill: 0xFFFFFF,
font: "'Arial Black', 'Helvetica-Bold', sans-serif"
});
percent50ButtonText.anchor.set(0.5, 0.5);
percent50ButtonText.x = 1300;
percent50ButtonText.y = 2580;
game.addChild(percent50ButtonText);
var percent75Button = game.attachAsset('betButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 1500,
y: 2580,
scaleX: 0.7,
scaleY: 0.7
});
var percent75ButtonText = new Text2('75%', {
size: 40,
fill: 0xFFFFFF,
font: "'Arial Black', 'Helvetica-Bold', sans-serif"
});
percent75ButtonText.anchor.set(0.5, 0.5);
percent75ButtonText.x = 1500;
percent75ButtonText.y = 2580;
game.addChild(percent75ButtonText);
var betButton = game.attachAsset('playButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 748,
// Left side of screen with margin
y: 2400,
// Match cashout button height
scaleX: 0.8,
// Make smaller for mobile
scaleY: 0.8
});
var betButtonText = new Text2('PLAY ($' + betAmount + ')', {
size: 50,
fill: 0xFFFFFF,
font: "'Arial Black', 'Helvetica-Bold', sans-serif"
});
betButtonText.anchor.set(0.5, 0.5);
betButtonText.x = 748; // Match button position
betButtonText.y = 2400;
game.addChild(betButtonText);
// Previous crashes display
var crashHistoryText = new Text2('Previous crashes: ' + (previousCrashes.length > 0 ? previousCrashes.slice(-5).join('x, ') + 'x' : 'None'), {
size: 30,
fill: 0x888888
});
crashHistoryText.anchor.set(0.5, 0);
LK.gui.top.addChild(crashHistoryText);
crashHistoryText.y = 120;
// Logo button
var logoButton = game.attachAsset('logo', {
anchorX: 1.0,
anchorY: 0.0,
x: 1948,
y: 100
});
function updateBetAmount() {
betText.setText('Bet: $' + betAmount);
betButtonText.setText('PLAY ($' + betAmount + ')');
}
function generateCrashPoint() {
// Generate crash point between 1.01x and 10.00x with higher probability for lower values
var random = Math.random();
if (random < 0.5) {
return 1.01 + Math.random() * 1.99; // 1.01x - 3.00x (50% chance)
} else if (random < 0.8) {
return 3.0 + Math.random() * 2.0; // 3.00x - 5.00x (30% chance)
} else {
return 5.0 + Math.random() * 5.0; // 5.00x - 10.00x (20% chance)
}
}
function startRound() {
if (playerBalance < betAmount) {
statusText.setText('Insufficient balance!');
return;
}
gameState = 'flying';
playerBalance -= betAmount;
hasPlayerCashedOut = false;
crashPoint = generateCrashPoint();
flightStartTime = LK.ticks;
rocketCurrentY = rocketStartY;
currentMultiplier = 1.0;
// Update UI
balanceText.setText('Balance: $' + Math.floor(playerBalance));
statusText.setText('Cash out before it crashes!\nĂakılmadan önce parayı çek!');
statusText.x = rocket.x;
statusText.y = rocket.y - 320;
// Show cash out button
tween(cashOutButton, {
alpha: 1
}, {
duration: 300
});
// Hide bet button
tween(betButton, {
alpha: 0
}, {
duration: 300
});
tween(betButtonText, {
alpha: 0
}, {
duration: 300
});
LK.getSound('launch').play();
}
function cashOut() {
if (gameState !== 'flying' || hasPlayerCashedOut) return;
hasPlayerCashedOut = true;
var winnings = Math.floor(betAmount * currentMultiplier);
playerBalance += winnings;
statusText.setText('Cashed out! Won $' + winnings);
balanceText.setText('Balance: $' + Math.floor(playerBalance));
// Spawn astronaut animation
var astronaut = new Astronaut();
astronaut.x = rocket.x + 80;
astronaut.y = rocket.y;
game.addChild(astronaut);
// Hide cash out button
tween(cashOutButton, {
alpha: 0
}, {
duration: 300
});
LK.getSound('cashout').play();
// End round after delay
LK.setTimeout(function () {
endRound();
}, 2000);
}
function crashRocket() {
gameState = 'crashed';
if (!hasPlayerCashedOut) {
statusText.setText('CRASHED! You lost $' + betAmount);
}
// Add crash point to history
previousCrashes.push(parseFloat(currentMultiplier.toFixed(2)));
if (previousCrashes.length > 10) {
previousCrashes.shift();
}
// Flash screen red
LK.effects.flashScreen(0xff0000, 500);
// Hide cash out button
tween(cashOutButton, {
alpha: 0
}, {
duration: 300
});
LK.getSound('crash').play();
// End round after delay
LK.setTimeout(function () {
endRound();
}, 2000);
}
function endRound() {
gameState = 'betting';
// Reset rocket position
rocket.y = rocketStartY;
rocketCurrentY = rocketStartY;
// Clear trail particles
for (var i = trailParticles.length - 1; i >= 0; i--) {
trailParticles[i].destroy();
trailParticles.splice(i, 1);
}
// Show bet button
betButton.alpha = 1;
betButtonText.alpha = 1;
betButtonText.setText('PLAY ($' + betAmount + ')');
// Update crash history
crashHistoryText.setText('Previous crashes: ' + (previousCrashes.length > 0 ? previousCrashes.slice(-5).join('x, ') + 'x' : 'None'));
statusText.setText('Place your bet and tap to launch!\nBahsini yerleĆtir ve launch butonuna tıkla');
statusText.x = rocket.x;
statusText.y = rocket.y - 320;
// Save data
storage.balance = playerBalance;
storage.crashes = previousCrashes;
}
// Event handlers
game.down = function (x, y, obj) {
// Check if bet button was clicked during betting phase
if (gameState === 'betting') {
// Check minus button
var minusLeft = minusButton.x - minusButton.width * 0.7 / 2;
var minusRight = minusButton.x + minusButton.width * 0.7 / 2;
var minusTop = minusButton.y - minusButton.height * 0.7 / 2;
var minusBottom = minusButton.y + minusButton.height * 0.7 / 2;
if (x >= minusLeft && x <= minusRight && y >= minusTop && y <= minusBottom) {
betAmount = Math.max(1, betAmount - 1);
updateBetAmount();
return;
}
// Check plus button
var plusLeft = plusButton.x - plusButton.width * 0.7 / 2;
var plusRight = plusButton.x + plusButton.width * 0.7 / 2;
var plusTop = plusButton.y - plusButton.height * 0.7 / 2;
var plusBottom = plusButton.y + plusButton.height * 0.7 / 2;
if (x >= plusLeft && x <= plusRight && y >= plusTop && y <= plusBottom) {
betAmount = Math.min(playerBalance, betAmount + 1);
updateBetAmount();
return;
}
// Check min button
var minBtnLeft = minButton.x - minButton.width / 2;
var minBtnRight = minButton.x + minButton.width / 2;
var minBtnTop = minButton.y - minButton.height / 2;
var minBtnBottom = minButton.y + minButton.height / 2;
if (x >= minBtnLeft && x <= minBtnRight && y >= minBtnTop && y <= minBtnBottom) {
betAmount = 1;
updateBetAmount();
return;
}
// Check max button
var maxBtnLeft = maxButton.x - maxButton.width / 2;
var maxBtnRight = maxButton.x + maxButton.width / 2;
var maxBtnTop = maxButton.y - maxButton.height / 2;
var maxBtnBottom = maxButton.y + maxButton.height / 2;
if (x >= maxBtnLeft && x <= maxBtnRight && y >= maxBtnTop && y <= maxBtnBottom) {
betAmount = Math.floor(playerBalance);
updateBetAmount();
return;
}
// Check 25% button
var p25Left = percent25Button.x - percent25Button.width / 2;
var p25Right = percent25Button.x + percent25Button.width / 2;
var p25Top = percent25Button.y - percent25Button.height / 2;
var p25Bottom = percent25Button.y + percent25Button.height / 2;
if (x >= p25Left && x <= p25Right && y >= p25Top && y <= p25Bottom) {
betAmount = Math.floor(playerBalance * 0.25);
updateBetAmount();
return;
}
// Check 50% button
var p50Left = percent50Button.x - percent50Button.width / 2;
var p50Right = percent50Button.x + percent50Button.width / 2;
var p50Top = percent50Button.y - percent50Button.height / 2;
var p50Bottom = percent50Button.y + percent50Button.height / 2;
if (x >= p50Left && x <= p50Right && y >= p50Top && y <= p50Bottom) {
betAmount = Math.floor(playerBalance * 0.5);
updateBetAmount();
return;
}
// Check 75% button
var p75Left = percent75Button.x - percent75Button.width / 2;
var p75Right = percent75Button.x + percent75Button.width / 2;
var p75Top = percent75Button.y - percent75Button.height / 2;
var p75Bottom = percent75Button.y + percent75Button.height / 2;
if (x >= p75Left && x <= p75Right && y >= p75Top && y <= p75Bottom) {
betAmount = Math.floor(playerBalance * 0.75);
updateBetAmount();
return;
}
// Check if launch button was clicked
var buttonLeft = betButton.x - betButton.width * 0.8 / 2;
var buttonRight = betButton.x + betButton.width * 0.8 / 2;
var buttonTop = betButton.y - betButton.height * 0.8 / 2;
var buttonBottom = betButton.y + betButton.height * 0.8 / 2;
if (x >= buttonLeft && x <= buttonRight && y >= buttonTop && y <= buttonBottom) {
startRound();
}
}
// Check logo button click
var logoLeft = logoButton.x - logoButton.width;
var logoRight = logoButton.x;
var logoTop = logoButton.y;
var logoBottom = logoButton.y + logoButton.height;
if (x >= logoLeft && x <= logoRight && y >= logoTop && y <= logoBottom) {
console.log('Logo clicked - would redirect to https://vayabi5559.com');
return;
}
};
game.update = function () {
// Update trail particles
for (var i = trailParticles.length - 1; i >= 0; i--) {
if (trailParticles[i] && trailParticles[i].life <= 0) {
trailParticles.splice(i, 1);
}
}
if (gameState === 'flying') {
// Calculate flight time and multiplier
var flightTime = (LK.ticks - flightStartTime) / 60; // Convert to seconds
currentMultiplier = 1.0 + flightTime * 0.5; // Multiplier increases by 0.5 per second
// Update rocket position (move up as multiplier increases)
var progress = (currentMultiplier - 1.0) / 9.0; // Progress from 0 to 1 over 9x multiplier
rocket.y = rocketStartY - progress * 1800;
// Add slight wobble to rocket
rocket.x = 1024 + Math.sin(LK.ticks * 0.1) * 10;
// Update multiplier display
multiplierText.setText(currentMultiplier.toFixed(2) + 'x');
// Update potential winnings display
cashOutButton.updateWinnings(currentMultiplier, betAmount);
// Check if rocket should crash
if (currentMultiplier >= crashPoint && !hasPlayerCashedOut) {
crashRocket();
}
}
};