User prompt
Add a lot more phrases to add more variety
User prompt
Can you add 50+ more phrases
User prompt
Move all the sliders up 100 pixels
User prompt
Make a scared slider
User prompt
Raise the position of the slider
User prompt
Move all the sliders up
User prompt
Add a new slider for scariness
User prompt
Add a new slider for threaten
User prompt
Add a new slider for flirtatiousness
User prompt
Make the phrases more bold and big
User prompt
Make the phrases white
User prompt
Make the phrases below the person or at the near bottom of the screen
User prompt
Make the phrases three different lines of text to prevent it going off screen
User prompt
Make the phrases black
User prompt
Please fix the bug: 'undefined is not an object (evaluating 'phraseText.style.wordWrap = true')' in or related to this line: 'phraseText.style.wordWrap = true;' Line Number: 360
Code edit (1 edits merged)
Please save this source code
User prompt
Mood Mixer: Phrase Generator
Initial prompt
Make a game where there are sliders for funny, angry, sad, humorous, cute. It will generate something that they would say based on the personality sliders
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ var Character = Container.expand(function () { var self = Container.call(this); // Emotional state values (default to neutral) self.emotions = { funny: 0.5, angry: 0.5, sad: 0.5, humorous: 0.5, cute: 0.5 }; // Create character body self.body = self.attachAsset('characterBody', { anchorX: 0.5, anchorY: 0.5, x: 0, y: 0 }); // Create eyes self.leftEye = self.attachAsset('characterEye', { anchorX: 0.5, anchorY: 0.5, x: -100, y: -50 }); self.rightEye = self.attachAsset('characterEye', { anchorX: 0.5, anchorY: 0.5, x: 100, y: -50 }); // Create pupils self.leftPupil = self.attachAsset('characterPupil', { anchorX: 0.5, anchorY: 0.5, x: -100, y: -50 }); self.rightPupil = self.attachAsset('characterPupil', { anchorX: 0.5, anchorY: 0.5, x: 100, y: -50 }); // Create eyebrows self.leftEyebrow = self.attachAsset('characterEyebrow', { anchorX: 0.5, anchorY: 0.5, x: -100, y: -100 }); self.rightEyebrow = self.attachAsset('characterEyebrow', { anchorX: 0.5, anchorY: 0.5, x: 100, y: -100 }); // Create mouth self.mouth = self.attachAsset('characterMouth', { anchorX: 0.5, anchorY: 0.5, x: 0, y: 80 }); // Update character appearance based on emotional states self.updateAppearance = function () { // Body color and size (influenced by cute and funny) var bodyScale = 1 + self.emotions.cute * 0.2 - self.emotions.angry * 0.1; self.body.scaleX = self.body.scaleY = bodyScale; // Color tint based on emotions var redTint = Math.floor(255 * Math.min(1, 0.8 + self.emotions.angry * 0.5)); var greenTint = Math.floor(255 * Math.min(1, 0.8 + self.emotions.funny * 0.3 + self.emotions.cute * 0.3 - self.emotions.sad * 0.2)); var blueTint = Math.floor(255 * Math.min(1, 0.8 + self.emotions.sad * 0.3 - self.emotions.angry * 0.2)); // Convert RGB to hex var bodyTint = redTint << 16 | greenTint << 8 | blueTint; self.body.tint = bodyTint; // Eyes shape and size var eyeScale = 1 + self.emotions.cute * 0.5 - self.emotions.angry * 0.2; self.leftEye.scaleX = self.rightEye.scaleX = eyeScale; self.leftEye.scaleY = self.rightEye.scaleY = eyeScale * (1 - self.emotions.sad * 0.3); // Pupils position (funny makes them look in different directions) var eyeOffset = self.emotions.funny * 15; self.leftPupil.x = -100 + eyeOffset; self.rightPupil.x = 100 - eyeOffset; // Eyebrows position and rotation (angry, sad) var eyebrowRotation = self.emotions.angry * 0.5 - self.emotions.sad * 0.3; var eyebrowHeight = -100 - self.emotions.angry * 20 + self.emotions.sad * 10; self.leftEyebrow.rotation = -eyebrowRotation; self.rightEyebrow.rotation = eyebrowRotation; self.leftEyebrow.y = self.rightEyebrow.y = eyebrowHeight; // Mouth shape (happy, sad, surprised) var mouthWidth = 1 + self.emotions.humorous * 0.5 - self.emotions.sad * 0.3; var mouthHeight = 0.5 + self.emotions.funny * 1.0 + self.emotions.humorous * 0.5 - self.emotions.sad * 0.5 + self.emotions.angry * 0.3; self.mouth.scaleX = mouthWidth; self.mouth.scaleY = mouthHeight; // Mouth position adjusts with sadness/happiness self.mouth.y = 80 + self.emotions.sad * 30 - self.emotions.humorous * 20; }; // Update emotional values self.updateEmotions = function (emotions) { self.emotions = emotions; self.updateAppearance(); }; // Initialize appearance self.updateAppearance(); return self; }); var GenerateButton = Container.expand(function () { var self = Container.call(this); // Create button background self.background = self.attachAsset('slider', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.5, scaleY: 2.5, tint: 0x4CAF50 }); // Create button text self.text = new Text2("Generate Phrase", { size: 50, fill: 0xFFFFFF }); self.text.anchor.set(0.5, 0.5); self.addChild(self.text); // Event handlers self.down = function (x, y, obj) { tween(self.background, { scaleX: 0.48, scaleY: 2.4 }, { duration: 100 }); tween(self.text, { scaleX: 0.95, scaleY: 0.95 }, { duration: 100 }); }; self.up = function (x, y, obj) { tween(self.background, { scaleX: 0.5, scaleY: 2.5 }, { duration: 100, onFinish: function onFinish() { LK.getSound('generate').play(); if (self.onGenerate) { self.onGenerate(); } } }); tween(self.text, { scaleX: 1, scaleY: 1 }, { duration: 100 }); }; return self; }); var Slider = Container.expand(function (emotionName, color) { var self = Container.call(this); // Set emotion name and color self.emotionName = emotionName; self.color = color || 0xFFFFFF; self.value = 0.5; // Default to middle position // Create slider background var background = self.attachAsset('slider', { anchorX: 0, anchorY: 0.5 }); // Create slider label self.label = new Text2(emotionName + ": 50%", { size: 40, fill: 0xFFFFFF }); self.label.anchor.set(0, 0.5); self.label.x = 0; self.label.y = -50; self.addChild(self.label); // Create slider handle self.handle = self.attachAsset('sliderHandle', { anchorX: 0.5, anchorY: 0.5, x: background.width * self.value, y: 0, tint: self.color }); // Event handlers self.down = function (x, y, obj) { self.isDragging = true; self.updateHandlePosition(x); }; self.up = function (x, y, obj) { if (self.isDragging) { self.isDragging = false; LK.getSound('slide').play(); } }; self.move = function (x, y, obj) { if (self.isDragging) { self.updateHandlePosition(x); } }; // Update handle position based on input self.updateHandlePosition = function (x) { // Calculate handle position within slider bounds var newPos = Math.max(0, Math.min(background.width, x)); self.handle.x = newPos; // Calculate value (0-1) self.value = newPos / background.width; // Update label self.label.setText(self.emotionName + ": " + Math.round(self.value * 100) + "%"); }; // Method to set a specific value self.setValue = function (newValue) { self.value = Math.max(0, Math.min(1, newValue)); self.handle.x = background.width * self.value; self.label.setText(self.emotionName + ": " + Math.round(self.value * 100) + "%"); }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x121212 }); /**** * Game Code ****/ // Game title function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; } function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; } function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) { return t; } var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) { return i; } throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } var titleText = new Text2("Mood Mixer", { size: 120, fill: 0xFFFFFF }); titleText.anchor.set(0.5, 0); titleText.x = 2048 / 2; titleText.y = 100; game.addChild(titleText); // Subtitle var subtitleText = new Text2("Adjust sliders to create a unique personality!", { size: 50, fill: 0xAAAAAA }); subtitleText.anchor.set(0.5, 0); subtitleText.x = 2048 / 2; subtitleText.y = 240; game.addChild(subtitleText); // Create sliders with different colors var sliders = []; var sliderNames = ["Funny", "Angry", "Sad", "Humorous", "Cute", "Flirtatious", "Threaten", "Scary"]; var sliderColors = [0x4CAF50, 0xFF5252, 0x2196F3, 0xFFC107, 0xFF4081, 0xFF69B4, 0x8B0000, 0x00008B]; var sliderY = 500; var sliderSpacing = 150; for (var i = 0; i < sliderNames.length; i++) { var slider = new Slider(sliderNames[i], sliderColors[i]); slider.x = 2048 / 2 - slider.children[0].width / 2; slider.y = sliderY + i * sliderSpacing; game.addChild(slider); sliders.push(slider); } // Create character var character = new Character(); character.x = 2048 / 2; character.y = 1700; game.addChild(character); // Create generate button var generateButton = new GenerateButton(); generateButton.x = 2048 / 2; generateButton.y = sliderY + sliderNames.length * sliderSpacing + 100; game.addChild(generateButton); // Create phrase display area var phraseText = new Text2("Adjust the sliders and generate a phrase!", { size: 70, // Increased size for bold effect fill: 0xFFFFFF, fontWeight: 'bold' // Make the text bold }); phraseText.anchor.set(0.5, 0.5); phraseText.x = 2048 / 2; phraseText.y = 2500; if (phraseText.style) { phraseText.style.wordWrap = true; phraseText.style.wordWrapWidth = 1500; } game.addChild(phraseText); // Phrases for different emotional states var phraseSets = { funny: ["Did you hear about the mathematician who's afraid of negative numbers? He'll stop at nothing to avoid them!", "Why don't scientists trust atoms? Because they make up everything!", "I told my wife she was drawing her eyebrows too high. She looked surprised!", "Life is short. Smile while you still have teeth!", "I'm on a seafood diet. I see food and I eat it!"], angry: ["This is absolutely unacceptable and I won't stand for it!", "You've got to be kidding me right now!", "I've had it up to here with this nonsense!", "That's the last straw! I'm officially done!", "Who do they think they are?! This is outrageous!"], sad: ["Sometimes I just feel like nobody understands...", "Why does the rain always seem to follow me?", "Another day, another disappointment to process.", "I miss the way things used to be...", "Some wounds never truly heal, they just stop bleeding."], humorous: ["I'm not saying I'm Batman, but have you ever seen me and Batman in the same room?", "My bed is a magical place where I suddenly remember everything I was supposed to do.", "I don't always have time to clean my house, but when I do, I still don't.", "Exercise? I thought you said 'extra fries'!", "My wallet is like an onion, opening it makes me cry."], cute: ["Sending you a virtual cuddle and a boopity boop on your nose!", "Aww, you're more adorable than a basket of sleepy puppies!", "Hearts, rainbows, and bunny hugs for everyone!", "I'm just a little ball of sunshine trying to brighten your day!", "Let's sprinkle some sparkles on this moment and make it magical!"], flirtatious: ["Are you a magician? Because whenever I look at you, everyone else disappears.", "Do you have a map? I just got lost in your eyes.", "If you were a vegetable, you'd be a cute-cumber!", "Is your name Google? Because you have everything I've been searching for.", "Do you have a Band-Aid? Because I just scraped my knee falling for you."], threaten: ["You better watch your back, I'm not someone to mess with.", "Don't make me show you what I'm capable of.", "You're playing with fire, and I'm the one holding the match.", "I suggest you step back before things get ugly.", "You're about to find out why they say I'm not to be trifled with."], scary: ["In the dark, you never know what might be lurking.", "I can feel the chill of something sinister nearby.", "The shadows seem to be moving... or is it just my imagination?", "There's a haunting presence that sends shivers down my spine.", "I can't shake the feeling that we're not alone here."] }; // Generate phrase based on emotional sliders function generatePhrase() { // Collect emotion values var emotions = {}; var highestEmotion = { name: "", value: 0 }; var secondHighestEmotion = { name: "", value: 0 }; for (var i = 0; i < sliders.length; i++) { var emotionName = sliders[i].emotionName.toLowerCase(); var emotionValue = sliders[i].value; emotions[emotionName] = emotionValue; // Track highest and second highest emotions if (emotionValue > highestEmotion.value) { secondHighestEmotion = _objectSpread({}, highestEmotion); highestEmotion = { name: emotionName, value: emotionValue }; } else if (emotionValue > secondHighestEmotion.value) { secondHighestEmotion = { name: emotionName, value: emotionValue }; } } // Update character appearance character.updateEmotions(emotions); // Generate a phrase based on emotional mix var phrase = ""; // If one emotion is very dominant (>80%) if (highestEmotion.value > 0.8) { var phraseSet = phraseSets[highestEmotion.name]; phrase = phraseSet[Math.floor(Math.random() * phraseSet.length)]; } // If we have a mixed personality else if (highestEmotion.value > 0.5 && secondHighestEmotion.value > 0.3) { // Get phrases from both top emotions var primaryPhrases = phraseSets[highestEmotion.name]; var secondaryPhrases = phraseSets[secondHighestEmotion.name]; var primaryPhrase = primaryPhrases[Math.floor(Math.random() * primaryPhrases.length)]; var secondaryPhrase = secondaryPhrases[Math.floor(Math.random() * secondaryPhrases.length)]; // Randomly decide which pattern to use for combining var pattern = Math.floor(Math.random() * 3); if (pattern === 0) { // Take half of each phrase var primarySplit = primaryPhrase.split(" "); var secondarySplit = secondaryPhrase.split(" "); var primaryHalf = primarySplit.slice(0, Math.ceil(primarySplit.length / 2)).join(" "); var secondaryHalf = secondarySplit.slice(Math.floor(secondarySplit.length / 2)).join(" "); phrase = primaryHalf + " " + secondaryHalf; } else if (pattern === 1) { // Interject one into the other var primarySplit = primaryPhrase.split("."); if (primarySplit.length > 1) { phrase = primarySplit[0] + ". " + secondaryPhrase; } else { phrase = primaryPhrase + " " + secondaryPhrase; } } else { // Create a new combined phrase phrase = "I'm feeling " + highestEmotion.name + " but also " + secondHighestEmotion.name + ": " + primaryPhrase; } } // Balanced/neutral state else { var allEmotionsBalanced = true; for (var emotion in emotions) { if (emotions[emotion] < 0.4 || emotions[emotion] > 0.6) { allEmotionsBalanced = false; break; } } if (allEmotionsBalanced) { phrase = "I'm feeling perfectly balanced today. Not too much of anything, just right."; } else { // Random mix of emotions var availableEmotions = []; for (var emotion in emotions) { if (emotions[emotion] > 0.4) { availableEmotions.push(emotion); } } if (availableEmotions.length > 0) { var selectedEmotion = availableEmotions[Math.floor(Math.random() * availableEmotions.length)]; var selectedPhrases = phraseSets[selectedEmotion]; phrase = selectedPhrases[Math.floor(Math.random() * selectedPhrases.length)]; } else { phrase = "I'm not feeling much of anything right now. Maybe adjust those sliders?"; } } } // Split the phrase into three lines var words = phrase.split(" "); var line1 = words.slice(0, Math.ceil(words.length / 3)).join(" "); var line2 = words.slice(Math.ceil(words.length / 3), Math.ceil(2 * words.length / 3)).join(" "); var line3 = words.slice(Math.ceil(2 * words.length / 3)).join(" "); phraseText.setText(line1 + "\n" + line2 + "\n" + line3); // Flash text with a color based on the highest emotion var flashColor = 0xFFFFFF; if (highestEmotion.value > 0.5) { var emotionIndex = sliderNames.findIndex(function (name) { return name.toLowerCase() === highestEmotion.name; }); if (emotionIndex >= 0) { flashColor = sliderColors[emotionIndex]; } } // Animate the phrase appearance phraseText.alpha = 0; phraseText.scale.set(0.8, 0.8); tween(phraseText, { alpha: 1, scaleX: 1, scaleY: 1 }, { duration: 300 }); // Update score based on interesting combinations updateScore(emotions); } // Scoring system - more points for creative combinations var totalScore = 0; var lastScoreUpdate = 0; function updateScore(emotions) { // Calculate how balanced or extreme the configuration is var extremeCount = 0; var balancedCount = 0; for (var emotion in emotions) { if (emotions[emotion] > 0.8 || emotions[emotion] < 0.2) { extremeCount++; } if (emotions[emotion] > 0.4 && emotions[emotion] < 0.6) { balancedCount++; } } // Calculate points - reward both extreme configurations and balanced ones var points = 0; // Reward for extremes (very high or very low values) points += extremeCount * 5; // Also reward for perfectly balanced configurations if (balancedCount === Object.keys(emotions).length) { points += 15; // Zen master bonus } // Add novelty bonus if this is a configuration we haven't tried before var configString = ''; for (var emotion in emotions) { configString += Math.round(emotions[emotion] * 10); } var previousConfigs = storage.previousConfigs || []; if (!previousConfigs.includes(configString)) { points += 10; // Bonus for new configuration previousConfigs.push(configString); // Keep track of only the last 50 configurations if (previousConfigs.length > 50) { previousConfigs.shift(); } storage.previousConfigs = previousConfigs; } // Don't allow more than one score update per 2 seconds to prevent spamming var now = Date.now(); if (now - lastScoreUpdate > 2000) { totalScore += points; lastScoreUpdate = now; // Update the score in the LK system if (points > 0) { LK.setScore(totalScore); } } } // Generate button event handler generateButton.onGenerate = function () { generatePhrase(); }; // Randomize sliders function randomizeSliders() { for (var i = 0; i < sliders.length; i++) { var randomValue = Math.random(); sliders[i].setValue(randomValue); } // Update character immediately updateCharacterFromSliders(); } // Update character based on current slider values function updateCharacterFromSliders() { var emotions = {}; for (var i = 0; i < sliders.length; i++) { emotions[sliders[i].emotionName.toLowerCase()] = sliders[i].value; } character.updateEmotions(emotions); } // Initialize with random values for (var i = 0; i < sliders.length; i++) { sliders[i].setValue(1); } updateCharacterFromSliders(); // Add randomize button var randomizeButton = new GenerateButton(); randomizeButton.text.setText("Randomize"); randomizeButton.background.tint = 0x9C27B0; randomizeButton.x = 2048 / 2; randomizeButton.y = sliderY + sliderNames.length * sliderSpacing + 350; game.addChild(randomizeButton); randomizeButton.onGenerate = function () { randomizeSliders(); generatePhrase(); }; // Add a reset to neutral button var resetButton = new GenerateButton(); resetButton.text.setText("Reset to Neutral"); resetButton.background.tint = 0x607D8B; resetButton.x = 2048 / 2; resetButton.y = sliderY + sliderNames.length * sliderSpacing + 450; game.addChild(resetButton); resetButton.onGenerate = function () { for (var i = 0; i < sliders.length; i++) { sliders[i].setValue(0.5); } updateCharacterFromSliders(); phraseText.setText("Adjusted to neutral settings. Generate a phrase!"); }; // Keep track of dragged slider var draggedSlider = null; // Global game event handlers for slider interaction game.down = function (x, y, obj) { // Process in individual components }; game.up = function (x, y, obj) { if (draggedSlider) { updateCharacterFromSliders(); draggedSlider = null; } }; game.move = function (x, y, obj) { // Process in individual components }; // Update function game.update = function () { // This gets called every frame - use for animations or time-based updates // Subtle idle animation for character var time = LK.ticks / 60; // Convert to seconds // Subtle floating movement character.y = 1700 + Math.sin(time) * 10; // Subtle eye movement var eyeMovement = Math.sin(time * 0.5) * 5; character.leftPupil.y = -50 + eyeMovement; character.rightPupil.y = -50 + eyeMovement; }; // Play background music LK.playMusic('bgMusic');
===================================================================
--- original.js
+++ change.js
@@ -557,9 +557,12 @@
}
character.updateEmotions(emotions);
}
// Initialize with random values
-randomizeSliders();
+for (var i = 0; i < sliders.length; i++) {
+ sliders[i].setValue(1);
+}
+updateCharacterFromSliders();
// Add randomize button
var randomizeButton = new GenerateButton();
randomizeButton.text.setText("Randomize");
randomizeButton.background.tint = 0x9C27B0;