User prompt
add gangster for first and footera for second
User prompt
make it you can spin freely. you just spin. no score. just nice ↪💡 Consider importing and using the following plugins: @upit/tween.v1
Code edit (1 edits merged)
Please save this source code
User prompt
Spin & Match Adventure
Initial prompt
you spin 2 wheels. on the first wheel it will have Noobini, Lirili, Tim, Fluri, talpa, Svinina, pipi, Trippi, Tung tung tung. the second will have Pizzanini, larila, cheese, flura, di fero, bombardino, kiwi, corni, troppi, sahur.
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var SpinWheel = Container.expand(function (segments, isCharacterWheel) { var self = Container.call(this); var wheelBg = self.attachAsset('wheelBackground', { anchorX: 0.5, anchorY: 0.5 }); self.segments = []; self.segmentAngle = Math.PI * 2 / segments.length; self.spinning = false; self.currentRotation = 0; self.selectedIndex = 0; // Create segments for (var i = 0; i < segments.length; i++) { var segment = new WheelSegment(segments[i], null, isCharacterWheel); var angle = i * self.segmentAngle; var radius = 200; segment.x = Math.cos(angle - Math.PI / 2) * radius; segment.y = Math.sin(angle - Math.PI / 2) * radius; segment.rotation = angle; self.addChild(segment); self.segments.push(segment); } var center = self.attachAsset('wheelCenter', { anchorX: 0.5, anchorY: 0.5 }); self.spin = function () { if (self.spinning) return; self.spinning = true; var spinAmount = Math.PI * 2 * (3 + Math.random() * 3); // 3-6 full rotations var finalRotation = self.currentRotation + spinAmount; tween(self, { rotation: finalRotation }, { duration: 2000 + Math.random() * 1000, easing: tween.easeOut, onFinish: function onFinish() { self.spinning = false; self.currentRotation = finalRotation % (Math.PI * 2); // Calculate selected segment var normalizedRotation = (Math.PI * 2 - self.currentRotation) % (Math.PI * 2); self.selectedIndex = Math.floor(normalizedRotation / self.segmentAngle); if (self.selectedIndex >= segments.length) self.selectedIndex = 0; } }); }; self.getSelectedItem = function () { return segments[self.selectedIndex]; }; return self; }); var WheelSegment = Container.expand(function (text, color, isCharacter) { var self = Container.call(this); var segmentBg = self.attachAsset(isCharacter ? 'characterSegment' : 'itemSegment', { anchorX: 0.5, anchorY: 0.5 }); var segmentText = new Text2(text, { size: 24, fill: 0xFFFFFF }); segmentText.anchor.set(0.5, 0.5); self.addChild(segmentText); return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x2c2c54 }); /**** * Game Code ****/ // Character and item lists var characters = ['Noobini', 'Lirili', 'Tim', 'Fluri', 'Talpa', 'Svinina', 'Pipi', 'Trippi', 'Tung tung']; var items = ['Pizzanini', 'Larila', 'Cheese', 'Flura', 'Di fero', 'Bombardino', 'Kiwi', 'Corni', 'Troppi', 'Sahur']; // Special combinations for bonus points var specialCombos = [{ character: 'Noobini', item: 'Pizzanini', points: 100 }, { character: 'Lirili', item: 'Larila', points: 150 }, { character: 'Tim', item: 'Cheese', points: 75 }, { character: 'Fluri', item: 'Flura', points: 125 }, { character: 'Talpa', item: 'Di fero', points: 200 }, { character: 'Svinina', item: 'Bombardino', points: 180 }]; // Create wheels var characterWheel = new SpinWheel(characters, true); characterWheel.x = 2048 / 2 - 350; characterWheel.y = 2732 / 2; game.addChild(characterWheel); var itemWheel = new SpinWheel(items, false); itemWheel.x = 2048 / 2 + 350; itemWheel.y = 2732 / 2; game.addChild(itemWheel); // Create pointers var characterPointer = game.addChild(LK.getAsset('pointer', { anchorX: 0.5, anchorY: 1 })); characterPointer.x = characterWheel.x; characterPointer.y = characterWheel.y - 330; var itemPointer = game.addChild(LK.getAsset('pointer', { anchorX: 0.5, anchorY: 1 })); itemPointer.x = itemWheel.x; itemPointer.y = itemWheel.y - 330; // UI Elements var scoreTxt = new Text2('Score: 0', { size: 80, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); var instructionTxt = new Text2('Tap to Spin!', { size: 60, fill: 0xFFD700 }); instructionTxt.anchor.set(0.5, 0); instructionTxt.x = 2048 / 2; instructionTxt.y = 2732 - 200; game.addChild(instructionTxt); var resultTxt = new Text2('', { size: 50, fill: 0xFFFFFF }); resultTxt.anchor.set(0.5, 0.5); resultTxt.x = 2048 / 2; resultTxt.y = 2732 / 2 + 400; game.addChild(resultTxt); // Game variables var canSpin = true; var bothWheelsFinished = false; var characterFinished = false; var itemFinished = false; function checkBothWheelsFinished() { if (characterFinished && itemFinished) { bothWheelsFinished = true; canSpin = true; var selectedCharacter = characterWheel.getSelectedItem(); var selectedItem = itemWheel.getSelectedItem(); // Check for special combinations var bonusPoints = 10; // Base points var isSpecialCombo = false; for (var i = 0; i < specialCombos.length; i++) { var combo = specialCombos[i]; if (combo.character === selectedCharacter && combo.item === selectedItem) { bonusPoints = combo.points; isSpecialCombo = true; break; } } LK.setScore(LK.getScore() + bonusPoints); scoreTxt.setText('Score: ' + LK.getScore()); if (isSpecialCombo) { resultTxt.setText(selectedCharacter + ' + ' + selectedItem + '\nSPECIAL COMBO! +' + bonusPoints); resultTxt.tint = 0xffd700; LK.getSound('combo').play(); LK.effects.flashScreen(0xffd700, 500); } else { resultTxt.setText(selectedCharacter + ' + ' + selectedItem + '\n+' + bonusPoints + ' points'); resultTxt.tint = 0xffffff; LK.getSound('match').play(); } // Reset flags characterFinished = false; itemFinished = false; bothWheelsFinished = false; } } game.down = function (x, y, obj) { if (canSpin && !characterWheel.spinning && !itemWheel.spinning) { canSpin = false; resultTxt.setText(''); // Spin both wheels characterWheel.spin(); itemWheel.spin(); LK.getSound('spin').play(); // Update instruction instructionTxt.setText('Spinning...'); } }; game.update = function () { // Check if character wheel finished spinning if (!characterWheel.spinning && !characterFinished && !canSpin) { characterFinished = true; checkBothWheelsFinished(); } // Check if item wheel finished spinning if (!itemWheel.spinning && !itemFinished && !canSpin) { itemFinished = true; checkBothWheelsFinished(); } // Update instruction text if (canSpin && !characterWheel.spinning && !itemWheel.spinning) { instructionTxt.setText('Tap to Spin!'); } };
===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,226 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+
+/****
+* Classes
+****/
+var SpinWheel = Container.expand(function (segments, isCharacterWheel) {
+ var self = Container.call(this);
+ var wheelBg = self.attachAsset('wheelBackground', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.segments = [];
+ self.segmentAngle = Math.PI * 2 / segments.length;
+ self.spinning = false;
+ self.currentRotation = 0;
+ self.selectedIndex = 0;
+ // Create segments
+ for (var i = 0; i < segments.length; i++) {
+ var segment = new WheelSegment(segments[i], null, isCharacterWheel);
+ var angle = i * self.segmentAngle;
+ var radius = 200;
+ segment.x = Math.cos(angle - Math.PI / 2) * radius;
+ segment.y = Math.sin(angle - Math.PI / 2) * radius;
+ segment.rotation = angle;
+ self.addChild(segment);
+ self.segments.push(segment);
+ }
+ var center = self.attachAsset('wheelCenter', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.spin = function () {
+ if (self.spinning) return;
+ self.spinning = true;
+ var spinAmount = Math.PI * 2 * (3 + Math.random() * 3); // 3-6 full rotations
+ var finalRotation = self.currentRotation + spinAmount;
+ tween(self, {
+ rotation: finalRotation
+ }, {
+ duration: 2000 + Math.random() * 1000,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ self.spinning = false;
+ self.currentRotation = finalRotation % (Math.PI * 2);
+ // Calculate selected segment
+ var normalizedRotation = (Math.PI * 2 - self.currentRotation) % (Math.PI * 2);
+ self.selectedIndex = Math.floor(normalizedRotation / self.segmentAngle);
+ if (self.selectedIndex >= segments.length) self.selectedIndex = 0;
+ }
+ });
+ };
+ self.getSelectedItem = function () {
+ return segments[self.selectedIndex];
+ };
+ return self;
+});
+var WheelSegment = Container.expand(function (text, color, isCharacter) {
+ var self = Container.call(this);
+ var segmentBg = self.attachAsset(isCharacter ? 'characterSegment' : 'itemSegment', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ var segmentText = new Text2(text, {
+ size: 24,
+ fill: 0xFFFFFF
+ });
+ segmentText.anchor.set(0.5, 0.5);
+ self.addChild(segmentText);
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x2c2c54
+});
+
+/****
+* Game Code
+****/
+// Character and item lists
+var characters = ['Noobini', 'Lirili', 'Tim', 'Fluri', 'Talpa', 'Svinina', 'Pipi', 'Trippi', 'Tung tung'];
+var items = ['Pizzanini', 'Larila', 'Cheese', 'Flura', 'Di fero', 'Bombardino', 'Kiwi', 'Corni', 'Troppi', 'Sahur'];
+// Special combinations for bonus points
+var specialCombos = [{
+ character: 'Noobini',
+ item: 'Pizzanini',
+ points: 100
+}, {
+ character: 'Lirili',
+ item: 'Larila',
+ points: 150
+}, {
+ character: 'Tim',
+ item: 'Cheese',
+ points: 75
+}, {
+ character: 'Fluri',
+ item: 'Flura',
+ points: 125
+}, {
+ character: 'Talpa',
+ item: 'Di fero',
+ points: 200
+}, {
+ character: 'Svinina',
+ item: 'Bombardino',
+ points: 180
+}];
+// Create wheels
+var characterWheel = new SpinWheel(characters, true);
+characterWheel.x = 2048 / 2 - 350;
+characterWheel.y = 2732 / 2;
+game.addChild(characterWheel);
+var itemWheel = new SpinWheel(items, false);
+itemWheel.x = 2048 / 2 + 350;
+itemWheel.y = 2732 / 2;
+game.addChild(itemWheel);
+// Create pointers
+var characterPointer = game.addChild(LK.getAsset('pointer', {
+ anchorX: 0.5,
+ anchorY: 1
+}));
+characterPointer.x = characterWheel.x;
+characterPointer.y = characterWheel.y - 330;
+var itemPointer = game.addChild(LK.getAsset('pointer', {
+ anchorX: 0.5,
+ anchorY: 1
+}));
+itemPointer.x = itemWheel.x;
+itemPointer.y = itemWheel.y - 330;
+// UI Elements
+var scoreTxt = new Text2('Score: 0', {
+ size: 80,
+ fill: 0xFFFFFF
+});
+scoreTxt.anchor.set(0.5, 0);
+LK.gui.top.addChild(scoreTxt);
+var instructionTxt = new Text2('Tap to Spin!', {
+ size: 60,
+ fill: 0xFFD700
+});
+instructionTxt.anchor.set(0.5, 0);
+instructionTxt.x = 2048 / 2;
+instructionTxt.y = 2732 - 200;
+game.addChild(instructionTxt);
+var resultTxt = new Text2('', {
+ size: 50,
+ fill: 0xFFFFFF
+});
+resultTxt.anchor.set(0.5, 0.5);
+resultTxt.x = 2048 / 2;
+resultTxt.y = 2732 / 2 + 400;
+game.addChild(resultTxt);
+// Game variables
+var canSpin = true;
+var bothWheelsFinished = false;
+var characterFinished = false;
+var itemFinished = false;
+function checkBothWheelsFinished() {
+ if (characterFinished && itemFinished) {
+ bothWheelsFinished = true;
+ canSpin = true;
+ var selectedCharacter = characterWheel.getSelectedItem();
+ var selectedItem = itemWheel.getSelectedItem();
+ // Check for special combinations
+ var bonusPoints = 10; // Base points
+ var isSpecialCombo = false;
+ for (var i = 0; i < specialCombos.length; i++) {
+ var combo = specialCombos[i];
+ if (combo.character === selectedCharacter && combo.item === selectedItem) {
+ bonusPoints = combo.points;
+ isSpecialCombo = true;
+ break;
+ }
+ }
+ LK.setScore(LK.getScore() + bonusPoints);
+ scoreTxt.setText('Score: ' + LK.getScore());
+ if (isSpecialCombo) {
+ resultTxt.setText(selectedCharacter + ' + ' + selectedItem + '\nSPECIAL COMBO! +' + bonusPoints);
+ resultTxt.tint = 0xffd700;
+ LK.getSound('combo').play();
+ LK.effects.flashScreen(0xffd700, 500);
+ } else {
+ resultTxt.setText(selectedCharacter + ' + ' + selectedItem + '\n+' + bonusPoints + ' points');
+ resultTxt.tint = 0xffffff;
+ LK.getSound('match').play();
+ }
+ // Reset flags
+ characterFinished = false;
+ itemFinished = false;
+ bothWheelsFinished = false;
+ }
+}
+game.down = function (x, y, obj) {
+ if (canSpin && !characterWheel.spinning && !itemWheel.spinning) {
+ canSpin = false;
+ resultTxt.setText('');
+ // Spin both wheels
+ characterWheel.spin();
+ itemWheel.spin();
+ LK.getSound('spin').play();
+ // Update instruction
+ instructionTxt.setText('Spinning...');
+ }
+};
+game.update = function () {
+ // Check if character wheel finished spinning
+ if (!characterWheel.spinning && !characterFinished && !canSpin) {
+ characterFinished = true;
+ checkBothWheelsFinished();
+ }
+ // Check if item wheel finished spinning
+ if (!itemWheel.spinning && !itemFinished && !canSpin) {
+ itemFinished = true;
+ checkBothWheelsFinished();
+ }
+ // Update instruction text
+ if (canSpin && !characterWheel.spinning && !itemWheel.spinning) {
+ instructionTxt.setText('Tap to Spin!');
+ }
+};
\ No newline at end of file