User prompt
yazılar ve kutular daha büyük olmalı ayrıca hep aynı tarafa dönmeli ve dönme işlemi biraz sürmeli ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
yazılar kayınca boşlukta duruyormuş gibi oluyor bir yerden giderken öbür taraftan gelmeli ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
spin olan wheel şeklinde değil line olarak olmalı her kutucuğun içinde numara yazmalı
Code edit (1 edits merged)
Please save this source code
User prompt
Lucky Spin Roulette
Initial prompt
Create an arcade-style roulette game with numbers from 0 to 36, where each number is either red or black except for 0 which is green; players can bet any amount of their points on red, black, or green before each round, a pointer slides and stops on a number, red and black bets pay x2 while green (0) pays x36; include simple animations, modern UI, and smooth transitions.
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ var BetButton = Container.expand(function (color, label) { var self = Container.call(this); self.color = color; self.betAmount = 0; var button = self.attachAsset('betButton', { anchorX: 0.5, anchorY: 0.5 }); var colorValue = 0xff0000; if (color === 'black') colorValue = 0x000000; if (color === 'green') colorValue = 0x00aa00; button.tint = colorValue; var labelText = new Text2(label, { size: 40, fill: 0xFFFFFF }); labelText.anchor.set(0.5, 0.5); self.addChild(labelText); var betText = new Text2('$0', { size: 30, fill: 0xFFFF00 }); betText.anchor.set(0.5, 0.5); betText.y = 25; self.addChild(betText); self.setBet = function (amount) { self.betAmount = amount; betText.setText('$' + amount); }; self.down = function (x, y, obj) { if (currentBet < bankroll && !isSpinning) { var betAmount = Math.min(50, bankroll - currentBet); self.betAmount += betAmount; currentBet += betAmount; self.setBet(self.betAmount); updateUI(); } }; return self; }); var RouletteWheel = Container.expand(function () { var self = Container.call(this); // Roulette numbers with colors (European layout) var rouletteNumbers = [{ num: 0, color: 'green' }, { num: 32, color: 'red' }, { num: 15, color: 'black' }, { num: 19, color: 'red' }, { num: 4, color: 'black' }, { num: 21, color: 'red' }, { num: 2, color: 'black' }, { num: 25, color: 'red' }, { num: 17, color: 'black' }, { num: 34, color: 'red' }, { num: 6, color: 'black' }, { num: 27, color: 'red' }, { num: 13, color: 'black' }, { num: 36, color: 'red' }, { num: 11, color: 'black' }, { num: 30, color: 'red' }, { num: 8, color: 'black' }, { num: 23, color: 'red' }, { num: 10, color: 'black' }, { num: 5, color: 'red' }, { num: 24, color: 'black' }, { num: 16, color: 'red' }, { num: 33, color: 'black' }, { num: 1, color: 'red' }, { num: 20, color: 'black' }, { num: 14, color: 'red' }, { num: 31, color: 'black' }, { num: 9, color: 'red' }, { num: 22, color: 'black' }, { num: 18, color: 'red' }, { num: 29, color: 'black' }, { num: 7, color: 'red' }, { num: 28, color: 'black' }, { num: 12, color: 'red' }, { num: 35, color: 'black' }, { num: 3, color: 'red' }, { num: 26, color: 'black' }]; self.numbers = rouletteNumbers; self.spinning = false; // Create wheel background var wheelBg = self.attachAsset('wheelBackground', { anchorX: 0.5, anchorY: 0.5 }); // Create wheel segments self.segments = []; for (var i = 0; i < 37; i++) { var segment = self.attachAsset('wheelSegment', { anchorX: 0.5, anchorY: 1.0 }); var angle = i / 37 * Math.PI * 2; segment.rotation = angle; segment.x = Math.cos(angle) * 0; segment.y = Math.sin(angle) * 0; // Set color based on number var colorValue = 0xff0000; // red if (rouletteNumbers[i].color === 'black') { colorValue = 0x000000; } else if (rouletteNumbers[i].color === 'green') { colorValue = 0x00aa00; } segment.tint = colorValue; self.segments.push(segment); } self.spin = function (targetNumber) { if (self.spinning) return; self.spinning = true; var targetIndex = -1; for (var i = 0; i < self.numbers.length; i++) { if (self.numbers[i].num === targetNumber) { targetIndex = i; break; } } var targetAngle = targetIndex / 37 * Math.PI * 2; var currentRotation = self.rotation % (Math.PI * 2); var spinRotation = Math.PI * 2 * 5 + targetAngle - currentRotation; tween(self, { rotation: self.rotation + spinRotation }, { duration: 3000, easing: tween.easeOut, onFinish: function onFinish() { self.spinning = false; if (onSpinComplete) { onSpinComplete(targetNumber); } } }); }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x0f4d0f }); /**** * Game Code ****/ var bankroll = storage.bankroll || 1000; var currentBet = 0; var isSpinning = false; var onSpinComplete = null; // Create UI elements var bankrollText = new Text2('Bankroll: $' + bankroll, { size: 50, fill: 0xFFFFFF }); bankrollText.anchor.set(0.5, 0); LK.gui.top.addChild(bankrollText); var betText = new Text2('Total Bet: $0', { size: 40, fill: 0xFFFF00 }); betText.anchor.set(0.5, 0); betText.y = 60; LK.gui.top.addChild(betText); var messageText = new Text2('Place your bets!', { size: 60, fill: 0xFFFFFF }); messageText.anchor.set(0.5, 1); LK.gui.bottom.addChild(messageText); // Create roulette wheel var wheel = game.addChild(new RouletteWheel()); wheel.x = 1024; wheel.y = 1000; // Create pointer var pointer = game.addChild(LK.getAsset('pointer', { anchorX: 0.5, anchorY: 1.0 })); pointer.x = 1024; pointer.y = 700; // Create bet buttons var redButton = game.addChild(new BetButton('red', 'RED')); redButton.x = 600; redButton.y = 1600; var blackButton = game.addChild(new BetButton('black', 'BLACK')); blackButton.x = 1024; blackButton.y = 1600; var greenButton = game.addChild(new BetButton('green', 'GREEN')); greenButton.x = 1448; greenButton.y = 1600; // Create spin button var spinButton = game.addChild(LK.getAsset('spinButton', { anchorX: 0.5, anchorY: 0.5 })); spinButton.x = 1024; spinButton.y = 1800; var spinButtonText = new Text2('SPIN', { size: 50, fill: 0xFFFFFF }); spinButtonText.anchor.set(0.5, 0.5); spinButtonText.x = 1024; spinButtonText.y = 1800; game.addChild(spinButtonText); spinButton.down = function (x, y, obj) { if (currentBet > 0 && !isSpinning && bankroll >= currentBet) { startSpin(); } }; function updateUI() { bankrollText.setText('Bankroll: $' + bankroll); betText.setText('Total Bet: $' + currentBet); storage.bankroll = bankroll; } function startSpin() { if (isSpinning) return; isSpinning = true; bankroll -= currentBet; updateUI(); messageText.setText('Spinning...'); LK.getSound('spin').play(); // Generate random winning number var winningNumber = Math.floor(Math.random() * 37); var actualNumber = wheel.numbers[winningNumber].num; onSpinComplete = function onSpinComplete(num) { checkWin(num); }; wheel.spin(actualNumber); } function checkWin(winningNumber) { var winningColor = ''; for (var i = 0; i < wheel.numbers.length; i++) { if (wheel.numbers[i].num === winningNumber) { winningColor = wheel.numbers[i].color; break; } } var totalWin = 0; var winMessage = 'Number ' + winningNumber + ' (' + winningColor.toUpperCase() + ')'; // Check red bet if (redButton.betAmount > 0 && winningColor === 'red') { totalWin += redButton.betAmount * 2; } // Check black bet if (blackButton.betAmount > 0 && winningColor === 'black') { totalWin += blackButton.betAmount * 2; } // Check green bet if (greenButton.betAmount > 0 && winningColor === 'green') { totalWin += greenButton.betAmount * 36; } if (totalWin > 0) { bankroll += totalWin; messageText.setText(winMessage + ' - You won $' + totalWin + '!'); LK.getSound('win').play(); LK.effects.flashScreen(0x00ff00, 1000); } else { messageText.setText(winMessage + ' - You lost $' + currentBet); LK.getSound('lose').play(); LK.effects.flashScreen(0xff0000, 500); } // Reset bets currentBet = 0; redButton.setBet(0); blackButton.setBet(0); greenButton.setBet(0); isSpinning = false; updateUI(); // Check game over if (bankroll <= 0) { LK.setTimeout(function () { LK.showGameOver(); }, 2000); } } game.update = function () { // Update spin button appearance if (currentBet > 0 && !isSpinning && bankroll >= currentBet) { spinButton.tint = 0x00ff00; spinButtonText.setText('SPIN'); } else { spinButton.tint = 0x666666; spinButtonText.setText('SPIN'); } // Check for big win if (bankroll >= 10000) { LK.setTimeout(function () { LK.showYouWin(); }, 1000); } };
===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,378 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+var storage = LK.import("@upit/storage.v1");
+
+/****
+* Classes
+****/
+var BetButton = Container.expand(function (color, label) {
+ var self = Container.call(this);
+ self.color = color;
+ self.betAmount = 0;
+ var button = self.attachAsset('betButton', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ var colorValue = 0xff0000;
+ if (color === 'black') colorValue = 0x000000;
+ if (color === 'green') colorValue = 0x00aa00;
+ button.tint = colorValue;
+ var labelText = new Text2(label, {
+ size: 40,
+ fill: 0xFFFFFF
+ });
+ labelText.anchor.set(0.5, 0.5);
+ self.addChild(labelText);
+ var betText = new Text2('$0', {
+ size: 30,
+ fill: 0xFFFF00
+ });
+ betText.anchor.set(0.5, 0.5);
+ betText.y = 25;
+ self.addChild(betText);
+ self.setBet = function (amount) {
+ self.betAmount = amount;
+ betText.setText('$' + amount);
+ };
+ self.down = function (x, y, obj) {
+ if (currentBet < bankroll && !isSpinning) {
+ var betAmount = Math.min(50, bankroll - currentBet);
+ self.betAmount += betAmount;
+ currentBet += betAmount;
+ self.setBet(self.betAmount);
+ updateUI();
+ }
+ };
+ return self;
+});
+var RouletteWheel = Container.expand(function () {
+ var self = Container.call(this);
+ // Roulette numbers with colors (European layout)
+ var rouletteNumbers = [{
+ num: 0,
+ color: 'green'
+ }, {
+ num: 32,
+ color: 'red'
+ }, {
+ num: 15,
+ color: 'black'
+ }, {
+ num: 19,
+ color: 'red'
+ }, {
+ num: 4,
+ color: 'black'
+ }, {
+ num: 21,
+ color: 'red'
+ }, {
+ num: 2,
+ color: 'black'
+ }, {
+ num: 25,
+ color: 'red'
+ }, {
+ num: 17,
+ color: 'black'
+ }, {
+ num: 34,
+ color: 'red'
+ }, {
+ num: 6,
+ color: 'black'
+ }, {
+ num: 27,
+ color: 'red'
+ }, {
+ num: 13,
+ color: 'black'
+ }, {
+ num: 36,
+ color: 'red'
+ }, {
+ num: 11,
+ color: 'black'
+ }, {
+ num: 30,
+ color: 'red'
+ }, {
+ num: 8,
+ color: 'black'
+ }, {
+ num: 23,
+ color: 'red'
+ }, {
+ num: 10,
+ color: 'black'
+ }, {
+ num: 5,
+ color: 'red'
+ }, {
+ num: 24,
+ color: 'black'
+ }, {
+ num: 16,
+ color: 'red'
+ }, {
+ num: 33,
+ color: 'black'
+ }, {
+ num: 1,
+ color: 'red'
+ }, {
+ num: 20,
+ color: 'black'
+ }, {
+ num: 14,
+ color: 'red'
+ }, {
+ num: 31,
+ color: 'black'
+ }, {
+ num: 9,
+ color: 'red'
+ }, {
+ num: 22,
+ color: 'black'
+ }, {
+ num: 18,
+ color: 'red'
+ }, {
+ num: 29,
+ color: 'black'
+ }, {
+ num: 7,
+ color: 'red'
+ }, {
+ num: 28,
+ color: 'black'
+ }, {
+ num: 12,
+ color: 'red'
+ }, {
+ num: 35,
+ color: 'black'
+ }, {
+ num: 3,
+ color: 'red'
+ }, {
+ num: 26,
+ color: 'black'
+ }];
+ self.numbers = rouletteNumbers;
+ self.spinning = false;
+ // Create wheel background
+ var wheelBg = self.attachAsset('wheelBackground', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ // Create wheel segments
+ self.segments = [];
+ for (var i = 0; i < 37; i++) {
+ var segment = self.attachAsset('wheelSegment', {
+ anchorX: 0.5,
+ anchorY: 1.0
+ });
+ var angle = i / 37 * Math.PI * 2;
+ segment.rotation = angle;
+ segment.x = Math.cos(angle) * 0;
+ segment.y = Math.sin(angle) * 0;
+ // Set color based on number
+ var colorValue = 0xff0000; // red
+ if (rouletteNumbers[i].color === 'black') {
+ colorValue = 0x000000;
+ } else if (rouletteNumbers[i].color === 'green') {
+ colorValue = 0x00aa00;
+ }
+ segment.tint = colorValue;
+ self.segments.push(segment);
+ }
+ self.spin = function (targetNumber) {
+ if (self.spinning) return;
+ self.spinning = true;
+ var targetIndex = -1;
+ for (var i = 0; i < self.numbers.length; i++) {
+ if (self.numbers[i].num === targetNumber) {
+ targetIndex = i;
+ break;
+ }
+ }
+ var targetAngle = targetIndex / 37 * Math.PI * 2;
+ var currentRotation = self.rotation % (Math.PI * 2);
+ var spinRotation = Math.PI * 2 * 5 + targetAngle - currentRotation;
+ tween(self, {
+ rotation: self.rotation + spinRotation
+ }, {
+ duration: 3000,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ self.spinning = false;
+ if (onSpinComplete) {
+ onSpinComplete(targetNumber);
+ }
+ }
+ });
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x0f4d0f
+});
+
+/****
+* Game Code
+****/
+var bankroll = storage.bankroll || 1000;
+var currentBet = 0;
+var isSpinning = false;
+var onSpinComplete = null;
+// Create UI elements
+var bankrollText = new Text2('Bankroll: $' + bankroll, {
+ size: 50,
+ fill: 0xFFFFFF
+});
+bankrollText.anchor.set(0.5, 0);
+LK.gui.top.addChild(bankrollText);
+var betText = new Text2('Total Bet: $0', {
+ size: 40,
+ fill: 0xFFFF00
+});
+betText.anchor.set(0.5, 0);
+betText.y = 60;
+LK.gui.top.addChild(betText);
+var messageText = new Text2('Place your bets!', {
+ size: 60,
+ fill: 0xFFFFFF
+});
+messageText.anchor.set(0.5, 1);
+LK.gui.bottom.addChild(messageText);
+// Create roulette wheel
+var wheel = game.addChild(new RouletteWheel());
+wheel.x = 1024;
+wheel.y = 1000;
+// Create pointer
+var pointer = game.addChild(LK.getAsset('pointer', {
+ anchorX: 0.5,
+ anchorY: 1.0
+}));
+pointer.x = 1024;
+pointer.y = 700;
+// Create bet buttons
+var redButton = game.addChild(new BetButton('red', 'RED'));
+redButton.x = 600;
+redButton.y = 1600;
+var blackButton = game.addChild(new BetButton('black', 'BLACK'));
+blackButton.x = 1024;
+blackButton.y = 1600;
+var greenButton = game.addChild(new BetButton('green', 'GREEN'));
+greenButton.x = 1448;
+greenButton.y = 1600;
+// Create spin button
+var spinButton = game.addChild(LK.getAsset('spinButton', {
+ anchorX: 0.5,
+ anchorY: 0.5
+}));
+spinButton.x = 1024;
+spinButton.y = 1800;
+var spinButtonText = new Text2('SPIN', {
+ size: 50,
+ fill: 0xFFFFFF
+});
+spinButtonText.anchor.set(0.5, 0.5);
+spinButtonText.x = 1024;
+spinButtonText.y = 1800;
+game.addChild(spinButtonText);
+spinButton.down = function (x, y, obj) {
+ if (currentBet > 0 && !isSpinning && bankroll >= currentBet) {
+ startSpin();
+ }
+};
+function updateUI() {
+ bankrollText.setText('Bankroll: $' + bankroll);
+ betText.setText('Total Bet: $' + currentBet);
+ storage.bankroll = bankroll;
+}
+function startSpin() {
+ if (isSpinning) return;
+ isSpinning = true;
+ bankroll -= currentBet;
+ updateUI();
+ messageText.setText('Spinning...');
+ LK.getSound('spin').play();
+ // Generate random winning number
+ var winningNumber = Math.floor(Math.random() * 37);
+ var actualNumber = wheel.numbers[winningNumber].num;
+ onSpinComplete = function onSpinComplete(num) {
+ checkWin(num);
+ };
+ wheel.spin(actualNumber);
+}
+function checkWin(winningNumber) {
+ var winningColor = '';
+ for (var i = 0; i < wheel.numbers.length; i++) {
+ if (wheel.numbers[i].num === winningNumber) {
+ winningColor = wheel.numbers[i].color;
+ break;
+ }
+ }
+ var totalWin = 0;
+ var winMessage = 'Number ' + winningNumber + ' (' + winningColor.toUpperCase() + ')';
+ // Check red bet
+ if (redButton.betAmount > 0 && winningColor === 'red') {
+ totalWin += redButton.betAmount * 2;
+ }
+ // Check black bet
+ if (blackButton.betAmount > 0 && winningColor === 'black') {
+ totalWin += blackButton.betAmount * 2;
+ }
+ // Check green bet
+ if (greenButton.betAmount > 0 && winningColor === 'green') {
+ totalWin += greenButton.betAmount * 36;
+ }
+ if (totalWin > 0) {
+ bankroll += totalWin;
+ messageText.setText(winMessage + ' - You won $' + totalWin + '!');
+ LK.getSound('win').play();
+ LK.effects.flashScreen(0x00ff00, 1000);
+ } else {
+ messageText.setText(winMessage + ' - You lost $' + currentBet);
+ LK.getSound('lose').play();
+ LK.effects.flashScreen(0xff0000, 500);
+ }
+ // Reset bets
+ currentBet = 0;
+ redButton.setBet(0);
+ blackButton.setBet(0);
+ greenButton.setBet(0);
+ isSpinning = false;
+ updateUI();
+ // Check game over
+ if (bankroll <= 0) {
+ LK.setTimeout(function () {
+ LK.showGameOver();
+ }, 2000);
+ }
+}
+game.update = function () {
+ // Update spin button appearance
+ if (currentBet > 0 && !isSpinning && bankroll >= currentBet) {
+ spinButton.tint = 0x00ff00;
+ spinButtonText.setText('SPIN');
+ } else {
+ spinButton.tint = 0x666666;
+ spinButtonText.setText('SPIN');
+ }
+ // Check for big win
+ if (bankroll >= 10000) {
+ LK.setTimeout(function () {
+ LK.showYouWin();
+ }, 1000);
+ }
+};
\ No newline at end of file