User prompt
Pointer assentini 30 birim aşağıya indir
User prompt
Memeleri açıklayan yazıları kaldır
User prompt
Spin again yazısını y doğrusunda 100 birim aşağıya indir
User prompt
20 tane meme card assenti oluştur. Rastgele bu meme kartlardan biri seçilsin döndüğünde
User prompt
Please fix the bug: 'Graphics is not a constructor' in or related to this line: 'var section = new Graphics();' Line Number: 237
Code edit (1 edits merged)
Please save this source code
User prompt
Spin to Meme
Initial prompt
"Spin to Meme" is a web-based casual game where players spin a colorful wheel to randomly determine which internet meme they are most aligned with. Each spin generates a unique meme result, accompanied by a fun personality description.
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var MemeResultCard = Container.expand(function () {
var self = Container.call(this);
// Initially hidden
self.visible = false;
var card = self.attachAsset('memeCard', {
anchorX: 0.5,
anchorY: 0.5
});
// Meme title
var titleText = new Text2("Your Spirit Meme", {
size: 80,
fill: 0x333333
});
titleText.anchor.set(0.5, 0);
titleText.y = -500;
self.addChild(titleText);
// Meme name
var memeNameText = new Text2("", {
size: 60,
fill: 0xFF5722
});
memeNameText.anchor.set(0.5, 0);
memeNameText.y = -400;
self.addChild(memeNameText);
// Description
var descriptionText = new Text2("", {
size: 40,
fill: 0x555555
});
descriptionText.anchor.set(0.5, 0);
descriptionText.y = -280;
descriptionText.wordWrap = true;
descriptionText.wordWrapWidth = 1400;
self.addChild(descriptionText);
// Close button
var closeButton = new Text2("SPIN AGAIN", {
size: 50,
fill: 0x3498DB
});
closeButton.anchor.set(0.5, 0.5);
closeButton.y = 450;
closeButton.interactive = true;
self.addChild(closeButton);
closeButton.down = function () {
tween(closeButton, {
scaleX: 0.9,
scaleY: 0.9
}, {
duration: 100
});
};
closeButton.up = function () {
tween(closeButton, {
scaleX: 1,
scaleY: 1
}, {
duration: 100,
onFinish: function onFinish() {
self.hide();
if (self.onClose) {
self.onClose();
}
}
});
};
self.showResult = function (memeName, index) {
memeNameText.setText(memeName);
descriptionText.setText(getMemeDescription(memeName, index));
self.visible = true;
// Animate card appearance
card.scaleX = 0.1;
card.scaleY = 0.1;
card.alpha = 0;
tween(card, {
scaleX: 1,
scaleY: 1,
alpha: 1
}, {
duration: 500,
easing: tween.elasticOut
});
};
self.hide = function () {
tween(card, {
scaleX: 0.1,
scaleY: 0.1,
alpha: 0
}, {
duration: 300,
onFinish: function onFinish() {
self.visible = false;
}
});
};
function getMemeDescription(memeName, index) {
var descriptions = ["You're observant and always noticing new opportunities, even when you should be focusing on what's right in front of you. You appreciate the complexity of choices and aren't afraid to show interest in something new and exciting.", "You're expressive and dramatic, never afraid to show your emotions. When you're upset, everyone knows it. You're also great at standing your ground even when faced with confusion or chaos.", "You have clear preferences and aren't afraid to express what you like and dislike. You make decisions confidently and know exactly what works for you. You're also not afraid to pass on trends that don't match your vibe.", "Your mind works in fascinating ways, and you love exploring ideas to their fullest extent. You can take simple concepts and develop them into complex philosophies. You appreciate intellectual growth and deep thinking.", "You're contemplative and always considering new perspectives. You challenge conventional wisdom and aren't afraid to question assumptions. Your thoughtful nature makes you excellent at solving problems.", "You're authentic in your reactions and wear your emotions on your sleeve. When something surprises you, everyone knows it. You bring honesty and genuine reactions to every situation.", "Much wow! Such personality! You're quirky, fun-loving, and don't take yourself too seriously. You approach life with curiosity and enthusiasm, finding joy in simple pleasures.", "You remain calm even when everything around you is falling apart. Your ability to accept challenging situations with a sense of humor makes you resilient. You're the steady presence others look to during chaos.", "You celebrate victories, both big and small. Your positive attitude helps you recognize achievements and builds confidence. You inspire others with your enthusiasm for life's successes.", "You embrace your awkwardness and aren't afraid to be yourself, even in uncomfortable situations. Your authenticity makes you relatable, and you find humor in life's awkward moments."];
return descriptions[index % descriptions.length];
}
return self;
});
var SpinButton = Container.expand(function () {
var self = Container.call(this);
var buttonGraphic = self.attachAsset('spinButton', {
anchorX: 0.5,
anchorY: 0.5
});
var label = new Text2("SPIN", {
size: 60,
fill: 0xFFFFFF
});
label.anchor.set(0.5, 0.5);
self.addChild(label);
self.down = function (x, y, obj) {
tween(buttonGraphic, {
scaleX: 0.9,
scaleY: 0.9
}, {
duration: 100
});
};
self.up = function (x, y, obj) {
tween(buttonGraphic, {
scaleX: 1,
scaleY: 1
}, {
duration: 100,
onFinish: function onFinish() {
if (self.onSpin) {
self.onSpin();
}
}
});
};
return self;
});
var SpinWheel = Container.expand(function () {
var self = Container.call(this);
// Wheel background
var wheelBase = self.attachAsset('wheel', {
anchorX: 0.5,
anchorY: 0.5
});
// Define meme categories
var memeCategories = ["Distracted Boyfriend", "Woman Yelling at Cat", "Drake Hotline Bling", "Expanding Brain", "Think About It", "Surprised Pikachu", "Doge", "This is Fine", "Success Kid", "Awkward Penguin"];
// Create wheel sections
for (var i = 0; i < memeCategories.length; i++) {
var section = new WheelSection(i, memeCategories.length, memeCategories[i]);
self.addChild(section);
}
// Track wheel state
self.isSpinning = false;
self.currentRotation = 0;
self.targetRotation = 0;
self.spinSpeed = 0;
self.deceleration = 0;
self.memeSections = memeCategories;
self.spin = function () {
if (self.isSpinning) return;
// Play spin sound
LK.getSound('spinSound').play();
self.isSpinning = true;
self.spinSpeed = 0.2 + Math.random() * 0.1; // Random starting speed
// Determine how many rotations (5-10) plus a random section
var rotations = 5 + Math.floor(Math.random() * 5);
var randomSection = Math.floor(Math.random() * memeCategories.length);
var sectionAngle = 2 * Math.PI / memeCategories.length;
// Calculate target rotation: current + full rotations + position to the random section
self.targetRotation = self.currentRotation + rotations * 2 * Math.PI + randomSection * sectionAngle;
// Calculate deceleration rate to gradually stop at the target
var totalAngleToTravel = self.targetRotation - self.currentRotation;
self.deceleration = self.spinSpeed * self.spinSpeed / (2 * totalAngleToTravel);
};
self.update = function () {
if (self.isSpinning) {
// Apply current speed
self.currentRotation += self.spinSpeed;
self.rotation = self.currentRotation;
// Decelerate
if (self.currentRotation < self.targetRotation) {
self.spinSpeed -= self.deceleration;
// Don't let speed go negative
if (self.spinSpeed <= 0.001) {
self.spinSpeed = 0.001;
}
} else {
// We've reached or passed the target
self.isSpinning = false;
self.currentRotation = self.targetRotation;
self.rotation = self.currentRotation;
// Calculate which section is at the top (pointer position)
self.onSpinComplete();
}
}
};
self.onSpinComplete = function () {
// Calculate which section is at the pointer (top)
var pointingAngle = (-self.rotation % (2 * Math.PI) + 2 * Math.PI) % (2 * Math.PI);
var sectionAngle = 2 * Math.PI / memeCategories.length;
var sectionIndex = Math.floor(pointingAngle / sectionAngle);
sectionIndex = (memeCategories.length - sectionIndex) % memeCategories.length;
// Report the result
if (self.onResult) {
self.onResult(memeCategories[sectionIndex], sectionIndex);
}
// Play result sound
LK.getSound('resultSound').play();
};
return self;
});
var WheelSection = Container.expand(function (sectionIndex, totalSections, text) {
var self = Container.call(this);
var radius = 650;
var angle = sectionIndex / totalSections * Math.PI * 2;
var nextAngle = (sectionIndex + 1) / totalSections * Math.PI * 2;
// Create a custom shape for the section using LK.getAsset
var sectionShape = {
width: radius * 2,
height: radius * 2,
color: getColorForSection(sectionIndex),
shape: 'section_' + sectionIndex
};
var section = LK.getAsset('section_' + sectionIndex, {
anchorX: 0.5,
anchorY: 0.5
});
// Position it correctly
self.addChild(section);
// Add text label
var label = new Text2(text, {
size: 40,
fill: 0xFFFFFF
});
label.anchor.set(0.5, 0.5);
// Position text in the middle of the section
var textRadius = radius * 0.75;
var midAngle = (angle + nextAngle) / 2;
label.x = Math.cos(midAngle) * textRadius;
label.y = Math.sin(midAngle) * textRadius;
label.rotation = midAngle + Math.PI / 2;
self.addChild(label);
function getColorForSection(index) {
// A few vibrant colors that work well together
var colors = [0xFF5757,
// Red
0x47B8FF,
// Blue
0xFFD557,
// Yellow
0x7DFF57,
// Green
0xFF57F7,
// Pink
0x57FFBD,
// Teal
0xFF8A57,
// Orange
0xA757FF,
// Purple
0x57FFFF,
// Cyan
0xBCFF57 // Lime
];
return colors[index % colors.length];
}
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x2c3e50
});
/****
* Game Code
****/
// Set up game elements
var wheel = new SpinWheel();
game.addChild(wheel);
wheel.x = 2048 / 2;
wheel.y = 2732 / 2 - 200;
// Add pointer
var pointer = LK.getAsset('pointer', {
anchorX: 0.5,
anchorY: 0
});
game.addChild(pointer);
pointer.x = wheel.x;
pointer.y = wheel.y - wheel.height / 2 - 20;
pointer.rotation = Math.PI; // Point downward
// Add spin button
var spinButton = new SpinButton();
game.addChild(spinButton);
spinButton.x = wheel.x;
spinButton.y = wheel.y + wheel.height / 2 + 200;
// Add result card (initially hidden)
var resultCard = new MemeResultCard();
game.addChild(resultCard);
resultCard.x = wheel.x;
resultCard.y = wheel.y;
// Title
var gameTitle = new Text2("Spin to Meme", {
size: 120,
fill: 0xFFFFFF
});
gameTitle.anchor.set(0.5, 0.5);
gameTitle.x = wheel.x;
gameTitle.y = 200;
game.addChild(gameTitle);
// Subtitle
var subtitle = new Text2("Discover Your Spirit Meme", {
size: 60,
fill: 0xFFFFFF
});
subtitle.anchor.set(0.5, 0.5);
subtitle.x = wheel.x;
subtitle.y = 300;
game.addChild(subtitle);
// Game state
var isGameActive = true;
// Connect components
spinButton.onSpin = function () {
if (isGameActive && !wheel.isSpinning && !resultCard.visible) {
wheel.spin();
}
};
wheel.onResult = function (meme, index) {
LK.setTimeout(function () {
resultCard.showResult(meme, index);
}, 500);
};
resultCard.onClose = function () {
isGameActive = true;
};
// Game update loop
game.update = function () {
if (wheel) {
wheel.update();
}
};
// Start background music
LK.playMusic('bgMusic'); ===================================================================
--- original.js
+++ change.js
@@ -220,14 +220,20 @@
var self = Container.call(this);
var radius = 650;
var angle = sectionIndex / totalSections * Math.PI * 2;
var nextAngle = (sectionIndex + 1) / totalSections * Math.PI * 2;
- var section = new Graphics();
- section.beginFill(getColorForSection(sectionIndex));
- section.moveTo(0, 0);
- section.arc(0, 0, radius, angle, nextAngle, false);
- section.lineTo(0, 0);
- section.endFill();
+ // Create a custom shape for the section using LK.getAsset
+ var sectionShape = {
+ width: radius * 2,
+ height: radius * 2,
+ color: getColorForSection(sectionIndex),
+ shape: 'section_' + sectionIndex
+ };
+ var section = LK.getAsset('section_' + sectionIndex, {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ // Position it correctly
self.addChild(section);
// Add text label
var label = new Text2(text, {
size: 40,