User prompt
agrega asset y tamaño a infoSlime. Ajusta el tamaño del slime segun la info del tamaño
Code edit (1 edits merged)
Please save this source code
User prompt
haz que bobbing se repita en bucle para darle un estilo de movimiento
User prompt
ELimina la caracteristica que mueve de posición Y a slime y remplazalo por una que le de movimiento en bucle ↪💡 Consider importing and using the following plugins: @upit/tween.v1
Code edit (4 edits merged)
Please save this source code
User prompt
disminuye el tamaño de slime y baja su posición
User prompt
arregla el bug que hace que no se cambie el asset
User prompt
Pon a slime más abajo para que parezca que se posiciona con el ambiente
User prompt
Pon a slime más abajo
Code edit (3 edits merged)
Please save this source code
User prompt
establece de menor a mayor como el soft inicial. Corrige el bug que hace que no cambie en nombre
Code edit (1 edits merged)
Please save this source code
User prompt
coloca el boton de soft a la esquina superior derecha, corrige el error de que no cambia el nombre
User prompt
crea un boton para cambiar el orden de los slimes 1->10/10->1/A->Z/Z->A y establece como primero de menor a mayor
Code edit (1 edits merged)
Please save this source code
User prompt
manten una escala razonable a los slimes para que no varien su tamaño
User prompt
haz que salga una musica random al principio y que cada 1:40 minutos cambie a otra random ↪💡 Consider importing and using the following plugins: @upit/tween.v1
Code edit (1 edits merged)
Please save this source code
User prompt
Elimina la suavidad de scrolling y hazla consisa sin plugin
User prompt
Dale información a todos los slimes y hazla interesante
User prompt
agrega la info a los slimes faltantes
Code edit (1 edits merged)
Please save this source code
User prompt
agrega los nuevos slimes
User prompt
haz que los slimes en el juego se ordenen automáticamente en orden de mayor a menor según su rareza si preocuparse de hacerlo manual en la lista SlimeInfo
User prompt
Vuelve slime info de esto manera: var SlimeInfo:[{ SlimeName: Rarity: history: Favoritefood: ability: lifespan:}] Asi volver más facil la agregación de nuevos slimes
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var Slime = Container.expand(function () { var self = Container.call(this); // Create and attach the slime asset self.attachAsset('ClasicSlime', { anchorX: 0.5, anchorY: 0.5, width: 500, height: 500 }); self.lastX = self.lastY = 0; self.baseX = 0; self.baseY = 0; self.setBasePosition = function (x, y) { self.baseX = x; self.baseY = y; self.x = x; self.y = y; }; self.update = function () { self.lastX = self.x; self.lastY = self.y; }; return self; }); var Star = Container.expand(function () { var self = Container.call(this); var starGraphics = self.attachAsset('Star', { anchorX: 0.5, anchorY: 0.5, width: 100, height: 100 }); self.setColorByRarity = function (rarityLevel) { var colors = [0xaaaaaa, 0x82b3c9, 0x4aa564, 0x2e8ece, 0x9b59b6, 0xe67e22, 0xe74c3c, 0xf1c40f, 0x1abc9c, 0xffffff]; starGraphics.tint = rarityLevel >= 1 && rarityLevel <= 10 ? colors[rarityLevel - 1] : colors[0]; // Create glow effect with subtle pulsation self.glowIntensity = 0.2 + rarityLevel / 10; LK.setTimeout(function () { tween(starGraphics, { scaleX: 1 + self.glowIntensity * 0.1, scaleY: 1 + self.glowIntensity * 0.1 }, { duration: 1000 + rarityLevel * 100, easing: tween.easeInOut, repeat: -1, yoyo: true }); }, Math.random() * 500); }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ // Create BGMenu for bottom half of screen var bgMenu = LK.getAsset('BGMenu', { anchorX: 0, anchorY: 0, x: 0, y: 2032 / 2, width: 2048, height: 3532 / 2 }); // Create BG for top half of screen var bg = LK.getAsset('BG', { anchorX: 0, anchorY: 0, x: 0, y: 0, width: 2048, height: 2032 / 2 }); // Create interface element at the top of BGMenu var interfaz = LK.getAsset('Interfaz', { anchorX: 0.5, anchorY: 0, width: 2048, height: 400 }); // Position the interface at the top of BGMenu interfaz.x = bgMenu.width / 2; interfaz.y = bgMenu.y; // Create left button var leftButton = LK.getAsset('BotonChange', { anchorX: 0.5, anchorY: 0.5, scaleX: -1, // Flip horizontally to point left x: -800, y: interfaz.height / 2 }); // Add event handlers for left button leftButton.interactive = true; leftButton.down = function () { changeSlime('prev'); }; // Create right button var rightButton = LK.getAsset('BotonChange', { anchorX: 0.5, anchorY: 0.5, x: 800, y: interfaz.height / 2 }); // Add event handlers for right button rightButton.interactive = true; rightButton.down = function () { changeSlime('next'); }; // Create a list of slime assets ordered by rarity from lowest to highest var slimes = ['ClasicSlime', 'SnowySlime', 'WaterSlime', 'RockSlime', 'FireSlime', 'ShadowSlime', 'ForestSlime', 'BeastSlime', 'LuckySlime', 'RunicSlime', 'DivineSlime']; // slimeNames is now derived from SlimeInfo structure var currentSlimeIndex = 0; // Function to wrap text that exceeds screen width function wrapText(text, maxWidth, textSize) { if (!text) { return ""; } var words = text.split(' '); var wrappedText = '', line = ''; var charsPerLine = Math.floor(maxWidth / (textSize * 0.5)); for (var i = 0; i < words.length; i++) { var testLine = line + words[i] + ' '; if (testLine.length > charsPerLine) { wrappedText += line.trim() + '\n'; line = words[i] + ' '; } else { line = testLine; } } return wrappedText + line.trim(); } // Create structured slime information var rarityNamesByValue = { 1: "Common", 2: "Unusual", 3: "Uncommon", 4: "Remarkable", 5: "Rare", 6: "Exceptional", 7: "Mythical", 8: "Legendary", 9: "Ancient", 10: "Divine" }; // Structured SlimeInfo array with all properties in a single place var SlimeInfo = [{ SlimeName: 'Clasic Slime', Rarity: 1, History: '', Location: '', FavoriteFood: '', Ability: '', Stats: { strength: 3, agility: 5, defense: 2, magic: 1, luck: 2, mysticism: 1 }, Lifespan: '' }, { SlimeName: 'Snowy Slime', Rarity: 2, History: '', Location: '', FavoriteFood: '', Ability: '', Stats: { strength: 3, agility: 2, defense: 8, magic: 6, luck: 4, mysticism: 5 }, Lifespan: '' }, { SlimeName: 'Water Slime', Rarity: 3, History: '', Location: '', FavoriteFood: '', Ability: '', Stats: { strength: 2, agility: 7, defense: 1, magic: 5, luck: 4, mysticism: 3 }, Lifespan: '' }, { SlimeName: 'Rock Slime', Rarity: 4, History: '', Location: '', FavoriteFood: '', Ability: '', Stats: { strength: 8, agility: 1, defense: 9, magic: 2, luck: 3, mysticism: 1 }, Lifespan: '' }, { SlimeName: 'Fire Slime', Rarity: 5, History: '', Location: '', FavoriteFood: '', Ability: '', Stats: { strength: 6, agility: 3, defense: 4, magic: 7, luck: 2, mysticism: 6 }, Lifespan: '' }, { SlimeName: 'Shadow Slime', Rarity: 6, History: '', Location: '', FavoriteFood: '', Ability: '', Stats: { strength: 5, agility: 8, defense: 3, magic: 9, luck: 6, mysticism: 8 }, Lifespan: '' }, { SlimeName: 'Forest Slime', Rarity: 7, History: '', Location: '', FavoriteFood: '', Ability: '', Stats: { strength: 4, agility: 6, defense: 5, magic: 8, luck: 5, mysticism: 7 }, Lifespan: '' }, { SlimeName: 'Beast Slime', Rarity: 8, History: '', Location: '', FavoriteFood: '', Ability: '', Stats: { strength: 9, agility: 7, defense: 7, magic: 3, luck: 8, mysticism: 2 }, Lifespan: '' }, { SlimeName: 'Lucky Slime', Rarity: 8, History: '', Location: '', FavoriteFood: '', Ability: '', Stats: { strength: 3, agility: 5, defense: 2, magic: 6, luck: 10, mysticism: 4 }, Lifespan: '' }, { SlimeName: 'Runic Slime', Rarity: 9, History: '', Location: '', FavoriteFood: '', Ability: '', Stats: { strength: 5, agility: 4, defense: 3, magic: 9, luck: 7, mysticism: 10 }, Lifespan: '' }, { SlimeName: 'Divine Slime', Rarity: 10, History: '', Location: '', FavoriteFood: '', Ability: '', Stats: { strength: 7, agility: 4, defense: 6, magic: 10, luck: 10, mysticism: 9 }, Lifespan: '' }]; // Extract arrays for backward compatibility and easier access var slimeNames = SlimeInfo.map(function (slime) { return slime.SlimeName; }); var rarityValues = SlimeInfo.map(function (slime) { return slime.Rarity; }); var histories = SlimeInfo.map(function (slime) { return slime.History; }); var locations = SlimeInfo.map(function (slime) { return slime.Location; }); var favoriteFoods = SlimeInfo.map(function (slime) { return slime.FavoriteFood; }); var abilities = SlimeInfo.map(function (slime) { return slime.Ability; }); var stats = SlimeInfo.map(function (slime) { return slime.Stats; }); var lifespans = SlimeInfo.map(function (slime) { return slime.Lifespan; }); // Create text display for slime name var slimeNameText = new Text2(slimeNames[currentSlimeIndex], { size: 100, fill: 0xFFFFFF }); slimeNameText.anchor.set(0.5, 0.5); slimeNameText.x = 0; slimeNameText.y = interfaz.height / 2; // Create a slime and add it to the scene var slime = new Slime(); // Position slime at the center of BG and set base position var centerX = bg.width / 2; var centerY = bg.height / 2; slime.setBasePosition(centerX, centerY); // Set initial properties for animations slime.alpha = 1; slime.scaleX = 1; slime.scaleY = 1; // Play background music LK.playMusic('BGSong3'); // --- Info Panel for BGMenu --- var infoPanelHeight = bgMenu.height - interfaz.height - 40; var infoPanelWidth = bgMenu.width; var infoPanelY = bgMenu.y + interfaz.height + 20; var infoPanelX = bgMenu.x + (bgMenu.width - infoPanelWidth) / 2; // Center horizontally // Create a container for the info panel var infoPanel = new Container(); infoPanel.x = infoPanelX; infoPanel.y = infoPanelY; // No background for the info panel // Prepare info categories and data var infoCategories = [{ title: "Rarity", get: function get(i) { var rarityValue = SlimeInfo[i].Rarity; this.currentRarityValue = rarityValue; return rarityNamesByValue[rarityValue]; } }, { title: "History", get: function get(i) { return SlimeInfo[i].History; } }, { title: "Location", get: function get(i) { return SlimeInfo[i].Location; } }, { title: "Favorite Food", get: function get(i) { return SlimeInfo[i].FavoriteFood; } }, { title: "Ability", get: function get(i) { return SlimeInfo[i].Ability; } }, { title: "Stats", get: function get(i) { var s = SlimeInfo[i].Stats; // Create visual stat bars with colored values using actual colors instead of tags function formatStat(name, value) { var barChars = "■".repeat(value); var emptyChars = "□".repeat(10 - value); return name + ": " + value + " [" + barChars + emptyChars + "]"; } // Create a single column with all 6 stats var statText = ""; statText += formatStat("Strength", s.strength) + "\n"; statText += formatStat("Agility", s.agility) + "\n"; statText += formatStat("Defense", s.defense) + "\n"; statText += formatStat("Magic", s.magic) + "\n"; statText += formatStat("Luck", s.luck) + "\n"; statText += formatStat("Mysticism", s.mysticism); return statText; } }, { title: "Lifespan", get: function get(i) { return SlimeInfo[i].Lifespan; } }]; // Create a container for the scrollable text var infoTextContainer = new Container(); infoTextContainer.x = 30; infoTextContainer.y = 30; // Add top margin // Function to update info text for current slime function updateInfoPanel() { // Remove old children infoTextContainer.removeChildren(); var y = 0; for (var c = 0; c < infoCategories.length; c++) { // Add extra spacing between sections if not the first section if (c > 0) { y += 80; // Add extra spacing between sections } // Title with gradient effect based on category var titleColors = { "Rarity": 0xFFD700, "History": 0xCF9FFF, "Location": 0x98FB98, "Favorite Food": 0xFF7F50, "Ability": 0x00BFFF, "Stats": 0xFF1493, "Lifespan": 0x00FA9A }; var titleColor = titleColors[infoCategories[c].title] || 0xFFF7B2; var titleText = new Text2(infoCategories[c].title, { size: 110, fill: titleColor, font: "GillSans-Bold", align: "center", dropShadow: true, dropShadowColor: 0x000000, dropShadowDistance: 3, dropShadowAlpha: 0.5 }); titleText.anchor.set(0.5, 0); titleText.x = infoPanelWidth / 2 - 30; titleText.y = y; infoTextContainer.addChild(titleText); y += titleText.height + 6; // Info - wrap text to fit screen width var infoContent = infoCategories[c].get(currentSlimeIndex); var wrappedText = infoContent; // Only apply text wrapping if not the stats category (which already has formatting) if (infoCategories[c].title !== "Stats") { wrappedText = wrapText(infoContent, infoPanelWidth - 60, 85); // Wrap text with some padding } // Choose text color based on category var textColors = { "Rarity": 0xFFFACD, "History": 0xE6E6FA, "Location": 0xF0FFF0, "Favorite Food": 0xFFE4E1, "Ability": 0xE0FFFF, "Stats": 0xFFE4E1, "Lifespan": 0xF0FFFF }; var textColor = textColors[infoCategories[c].title] || 0xFFFFFF; var infoText = new Text2(wrappedText, { size: 85, fill: textColor, font: "GillSans", align: infoCategories[c].title === "Stats" ? "left" : "center", dropShadow: true, dropShadowColor: 0x333333, dropShadowDistance: 2, dropShadowAlpha: 0.3 }); // Set anchor based on content type if (infoCategories[c].title === "Stats") { infoText.anchor.set(0.5, 0); // Center align stats too infoText.x = infoPanelWidth / 2 - 30; } else { infoText.anchor.set(0.5, 0); // Center align for other content infoText.x = infoPanelWidth / 2 - 30; } infoText.y = y + 20; infoTextContainer.addChild(infoText); // If this is the rarity category, add colored stars if (infoCategories[c].title === "Rarity" && infoCategories[c].currentRarityValue) { var starContainer = new Container(); starContainer.x = infoPanelWidth / 2 - 30; starContainer.y = y + infoText.height + 40; var rarityValue = infoCategories[c].currentRarityValue; var starSpacing = 110, totalWidth = (rarityValue - 1) * starSpacing; var startX = -totalWidth / 2; for (var s = 0; s < rarityValue; s++) { var star = new Star(); star.x = startX + s * starSpacing; star.y = 20; star.alpha = 0; star.scale.x = star.scale.y = 0.5; star.setColorByRarity(rarityValue); starContainer.addChild(star); (function (targetStar, delay) { LK.setTimeout(function () { tween(targetStar, { alpha: 1, scaleX: 1, scaleY: 1 }, { duration: 400, easing: tween.easeOut }); }, delay); })(star, s * 200); } infoTextContainer.addChild(starContainer); y += 80; } y += infoText.height + 24; } infoTextContainer.totalHeight = y; } updateInfoPanel(); // --- Scrolling logic for info panel with visual enhancements --- var scrollOffset = 0; var maxScroll = 0; function updateScrollLimits() { maxScroll = Math.max(0, infoTextContainer.totalHeight - infoPanelHeight + 40 + 60); // Add 60px to account for top and bottom margins // Create smooth bounce effect when reaching limits if (scrollOffset < 0) { scrollOffset = 0; tween(infoTextContainer, { y: 30 }, { duration: 300, easing: tween.elasticOut }); } if (scrollOffset > maxScroll) { scrollOffset = maxScroll; tween(infoTextContainer, { y: 30 - maxScroll }, { duration: 300, easing: tween.elasticOut }); } // Apply smooth scrolling if (!scrollTweenActive && isScrolling === false) { tween(infoTextContainer, { y: 30 - scrollOffset }, { duration: 100, easing: tween.easeOut }); } else { infoTextContainer.y = 30 - scrollOffset; // Apply top margin to starting position } } updateScrollLimits(); // Touch/mouse drag to scroll with inertia and visual feedback var isScrolling = false, lastScrollY = 0, scrollVelocity = 0, lastScrollTime = 0, scrollTweenActive = false, scrollTracker = []; infoPanel.interactive = true; infoPanel.down = function (x, y, obj) { isScrolling = true; lastScrollY = y; lastScrollTime = Date.now(); scrollTracker = []; // Reset scroll tracking if (scrollTweenActive) { tween.stop(infoTextContainer, { y: true }); scrollTweenActive = false; } }; infoPanel.move = function (x, y, obj) { if (isScrolling) { var currentTime = Date.now(); var timeDelta = currentTime - lastScrollTime; var dy = y - lastScrollY; // Track last few movements for better momentum calculation scrollTracker.push({ dy: dy, time: timeDelta }); if (scrollTracker.length > 5) { scrollTracker.shift(); } if (timeDelta > 0) { scrollVelocity = dy / timeDelta * 15; } scrollOffset -= dy; updateScrollLimits(); lastScrollY = y; lastScrollTime = currentTime; } }; infoPanel.up = function (x, y, obj) { if (isScrolling) { isScrolling = false; // Calculate average velocity from recent movements for smoother scroll var recentVelocity = 0; var totalWeight = 0; for (var i = 0; i < scrollTracker.length; i++) { var weight = (i + 1) / scrollTracker.length; recentVelocity += scrollTracker[i].dy / scrollTracker[i].time * weight; totalWeight += weight; } if (totalWeight > 0) { scrollVelocity = recentVelocity / totalWeight * 15; } if (Math.abs(scrollVelocity) > 0.1) { var targetScroll = Math.max(0, Math.min(maxScroll, scrollOffset - scrollVelocity * 50)); var targetY = 30 - targetScroll; scrollTweenActive = true; tween(infoTextContainer, { y: targetY }, { duration: 1000, easing: tween.easeOutQuint, onFinish: function onFinish() { scrollOffset = 30 - infoTextContainer.y; scrollTweenActive = false; } }); } } }; // Unified handler for both navigation buttons function createButtonHandler(direction) { return function (x, y, obj) { changeSlime(direction); updateInfoPanel(); updateScrollLimits(); }; } leftButton.down = createButtonHandler('prev'); rightButton.down = createButtonHandler('next'); // When changing slime, update info panel and scroll position function updateSlimeAndInfo() { // Stop existing tweens before starting new ones to prevent animation conflicts tween.stop(slime); // Enhanced slime transition effects with color flash and particle-like animation tween(slime, { alpha: 0, scaleX: 0.8, scaleY: 0.8, rotation: -0.1 }, { duration: 300, easing: tween.easeOut, onFinish: function onFinish() { // Flash background with slime color var slimeColors = [0xa154b0, 0xd6f1ff, 0x757eff, 0xa3a3a3, 0xff5c5c, 0x303030, 0x0dbf51, 0x794311, 0xffe600, 0x4f226d, 0xf7f497]; LK.effects.flashObject(bg, slimeColors[currentSlimeIndex], 300); slime.removeChildren(); slime.attachAsset(slimes[currentSlimeIndex], { anchorX: 0.5, anchorY: 0.5, width: 500, height: 500 }); // Reset to base position to prevent drift slime.x = slime.baseX; slime.y = slime.baseY; slime.alpha = 0; slime.scaleX = 0.8; slime.scaleY = 0.8; slime.rotation = 0.1; // More dynamic entrance animation tween(slime, { alpha: 1, scaleX: 1.2, scaleY: 1.2, rotation: 0 }, { duration: 400, easing: tween.easeOut, onFinish: function onFinish() { tween(slime, { scaleX: 1, scaleY: 1 }, { duration: 500, easing: tween.elasticOut }); // Add gentle bobbing animation but store a reference to the initial position var initialY = bg.height / 2; // Store original position LK.setTimeout(function () { tween(slime, { y: initialY - 15 }, { duration: 1200, easing: tween.easeInOut, repeat: -1, yoyo: true }); }, 500); } }); } }); // Define slime-specific colors based on their visual appearance var slimeColors = [0xa154b0, // ClasicSlime (purple) 0xd6f1ff, // SnowySlime (light blue) 0x757eff, // WaterSlime (blue) 0xa3a3a3, // RockSlime (gray) 0xff5c5c, // FireSlime (red) 0x303030, // ShadowSlime (dark gray) 0x0dbf51, // ForestSlime (green) 0x794311, // BeastSlime (brown) 0xffe600, // LuckySlime (yellow) 0x4f226d, // RunicSlime (dark purple) 0xf7f497 // DivineSlime (light yellow) ]; tween(slimeNameText, { alpha: 0, scaleX: 0.9, scaleY: 0.9 }, { duration: 200, easing: tween.easeOut, onFinish: function onFinish() { slimeNameText.setText(SlimeInfo[currentSlimeIndex].SlimeName); // Initialize style object if it doesn't exist if (!slimeNameText.style) { slimeNameText.style = {}; } // Apply slime-specific text color slimeNameText.style.fill = slimeColors[currentSlimeIndex]; slimeNameText.style.dropShadow = true; slimeNameText.style.dropShadowColor = 0x000000; slimeNameText.style.dropShadowDistance = 3; slimeNameText.style.dropShadowAlpha = 0.5; // Create more dynamic animation for the name tween(slimeNameText, { alpha: 1, scaleX: 1.1, scaleY: 1.1 }, { duration: 200, easing: tween.easeOut, onFinish: function onFinish() { tween(slimeNameText, { scaleX: 1, scaleY: 1 }, { duration: 400, easing: tween.elasticOut }); } }); } }); // Update content and scroll position updateInfoPanel(); scrollOffset = 0; updateScrollLimits(); // Fade in info container infoTextContainer.alpha = 0; tween(infoTextContainer, { alpha: 1 }, { duration: 400, easing: tween.easeOut }); } function changeSlime(direction) { currentSlimeIndex = direction === 'next' ? (currentSlimeIndex + 1) % slimes.length : (currentSlimeIndex - 1 + slimes.length) % slimes.length; updateSlimeAndInfo(); } /* * Asset initialization */ game.addChild(bgMenu); game.addChild(infoPanel); infoPanel.addChild(infoTextContainer); game.addChild(bg); game.addChild(interfaz); interfaz.addChild(leftButton); interfaz.addChild(rightButton); interfaz.addChild(slimeNameText); game.addChild(slime);
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Slime = Container.expand(function () {
var self = Container.call(this);
// Create and attach the slime asset
self.attachAsset('ClasicSlime', {
anchorX: 0.5,
anchorY: 0.5,
width: 500,
height: 500
});
self.lastX = self.lastY = 0;
self.baseX = 0;
self.baseY = 0;
self.setBasePosition = function (x, y) {
self.baseX = x;
self.baseY = y;
self.x = x;
self.y = y;
};
self.update = function () {
self.lastX = self.x;
self.lastY = self.y;
};
return self;
});
var Star = Container.expand(function () {
var self = Container.call(this);
var starGraphics = self.attachAsset('Star', {
anchorX: 0.5,
anchorY: 0.5,
width: 100,
height: 100
});
self.setColorByRarity = function (rarityLevel) {
var colors = [0xaaaaaa, 0x82b3c9, 0x4aa564, 0x2e8ece, 0x9b59b6, 0xe67e22, 0xe74c3c, 0xf1c40f, 0x1abc9c, 0xffffff];
starGraphics.tint = rarityLevel >= 1 && rarityLevel <= 10 ? colors[rarityLevel - 1] : colors[0];
// Create glow effect with subtle pulsation
self.glowIntensity = 0.2 + rarityLevel / 10;
LK.setTimeout(function () {
tween(starGraphics, {
scaleX: 1 + self.glowIntensity * 0.1,
scaleY: 1 + self.glowIntensity * 0.1
}, {
duration: 1000 + rarityLevel * 100,
easing: tween.easeInOut,
repeat: -1,
yoyo: true
});
}, Math.random() * 500);
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000
});
/****
* Game Code
****/
// Create BGMenu for bottom half of screen
var bgMenu = LK.getAsset('BGMenu', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 2032 / 2,
width: 2048,
height: 3532 / 2
});
// Create BG for top half of screen
var bg = LK.getAsset('BG', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 0,
width: 2048,
height: 2032 / 2
});
// Create interface element at the top of BGMenu
var interfaz = LK.getAsset('Interfaz', {
anchorX: 0.5,
anchorY: 0,
width: 2048,
height: 400
});
// Position the interface at the top of BGMenu
interfaz.x = bgMenu.width / 2;
interfaz.y = bgMenu.y;
// Create left button
var leftButton = LK.getAsset('BotonChange', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: -1,
// Flip horizontally to point left
x: -800,
y: interfaz.height / 2
});
// Add event handlers for left button
leftButton.interactive = true;
leftButton.down = function () {
changeSlime('prev');
};
// Create right button
var rightButton = LK.getAsset('BotonChange', {
anchorX: 0.5,
anchorY: 0.5,
x: 800,
y: interfaz.height / 2
});
// Add event handlers for right button
rightButton.interactive = true;
rightButton.down = function () {
changeSlime('next');
};
// Create a list of slime assets ordered by rarity from lowest to highest
var slimes = ['ClasicSlime', 'SnowySlime', 'WaterSlime', 'RockSlime', 'FireSlime', 'ShadowSlime', 'ForestSlime', 'BeastSlime', 'LuckySlime', 'RunicSlime', 'DivineSlime'];
// slimeNames is now derived from SlimeInfo structure
var currentSlimeIndex = 0;
// Function to wrap text that exceeds screen width
function wrapText(text, maxWidth, textSize) {
if (!text) {
return "";
}
var words = text.split(' ');
var wrappedText = '',
line = '';
var charsPerLine = Math.floor(maxWidth / (textSize * 0.5));
for (var i = 0; i < words.length; i++) {
var testLine = line + words[i] + ' ';
if (testLine.length > charsPerLine) {
wrappedText += line.trim() + '\n';
line = words[i] + ' ';
} else {
line = testLine;
}
}
return wrappedText + line.trim();
}
// Create structured slime information
var rarityNamesByValue = {
1: "Common",
2: "Unusual",
3: "Uncommon",
4: "Remarkable",
5: "Rare",
6: "Exceptional",
7: "Mythical",
8: "Legendary",
9: "Ancient",
10: "Divine"
};
// Structured SlimeInfo array with all properties in a single place
var SlimeInfo = [{
SlimeName: 'Clasic Slime',
Rarity: 1,
History: '',
Location: '',
FavoriteFood: '',
Ability: '',
Stats: {
strength: 3,
agility: 5,
defense: 2,
magic: 1,
luck: 2,
mysticism: 1
},
Lifespan: ''
}, {
SlimeName: 'Snowy Slime',
Rarity: 2,
History: '',
Location: '',
FavoriteFood: '',
Ability: '',
Stats: {
strength: 3,
agility: 2,
defense: 8,
magic: 6,
luck: 4,
mysticism: 5
},
Lifespan: ''
}, {
SlimeName: 'Water Slime',
Rarity: 3,
History: '',
Location: '',
FavoriteFood: '',
Ability: '',
Stats: {
strength: 2,
agility: 7,
defense: 1,
magic: 5,
luck: 4,
mysticism: 3
},
Lifespan: ''
}, {
SlimeName: 'Rock Slime',
Rarity: 4,
History: '',
Location: '',
FavoriteFood: '',
Ability: '',
Stats: {
strength: 8,
agility: 1,
defense: 9,
magic: 2,
luck: 3,
mysticism: 1
},
Lifespan: ''
}, {
SlimeName: 'Fire Slime',
Rarity: 5,
History: '',
Location: '',
FavoriteFood: '',
Ability: '',
Stats: {
strength: 6,
agility: 3,
defense: 4,
magic: 7,
luck: 2,
mysticism: 6
},
Lifespan: ''
}, {
SlimeName: 'Shadow Slime',
Rarity: 6,
History: '',
Location: '',
FavoriteFood: '',
Ability: '',
Stats: {
strength: 5,
agility: 8,
defense: 3,
magic: 9,
luck: 6,
mysticism: 8
},
Lifespan: ''
}, {
SlimeName: 'Forest Slime',
Rarity: 7,
History: '',
Location: '',
FavoriteFood: '',
Ability: '',
Stats: {
strength: 4,
agility: 6,
defense: 5,
magic: 8,
luck: 5,
mysticism: 7
},
Lifespan: ''
}, {
SlimeName: 'Beast Slime',
Rarity: 8,
History: '',
Location: '',
FavoriteFood: '',
Ability: '',
Stats: {
strength: 9,
agility: 7,
defense: 7,
magic: 3,
luck: 8,
mysticism: 2
},
Lifespan: ''
}, {
SlimeName: 'Lucky Slime',
Rarity: 8,
History: '',
Location: '',
FavoriteFood: '',
Ability: '',
Stats: {
strength: 3,
agility: 5,
defense: 2,
magic: 6,
luck: 10,
mysticism: 4
},
Lifespan: ''
}, {
SlimeName: 'Runic Slime',
Rarity: 9,
History: '',
Location: '',
FavoriteFood: '',
Ability: '',
Stats: {
strength: 5,
agility: 4,
defense: 3,
magic: 9,
luck: 7,
mysticism: 10
},
Lifespan: ''
}, {
SlimeName: 'Divine Slime',
Rarity: 10,
History: '',
Location: '',
FavoriteFood: '',
Ability: '',
Stats: {
strength: 7,
agility: 4,
defense: 6,
magic: 10,
luck: 10,
mysticism: 9
},
Lifespan: ''
}];
// Extract arrays for backward compatibility and easier access
var slimeNames = SlimeInfo.map(function (slime) {
return slime.SlimeName;
});
var rarityValues = SlimeInfo.map(function (slime) {
return slime.Rarity;
});
var histories = SlimeInfo.map(function (slime) {
return slime.History;
});
var locations = SlimeInfo.map(function (slime) {
return slime.Location;
});
var favoriteFoods = SlimeInfo.map(function (slime) {
return slime.FavoriteFood;
});
var abilities = SlimeInfo.map(function (slime) {
return slime.Ability;
});
var stats = SlimeInfo.map(function (slime) {
return slime.Stats;
});
var lifespans = SlimeInfo.map(function (slime) {
return slime.Lifespan;
});
// Create text display for slime name
var slimeNameText = new Text2(slimeNames[currentSlimeIndex], {
size: 100,
fill: 0xFFFFFF
});
slimeNameText.anchor.set(0.5, 0.5);
slimeNameText.x = 0;
slimeNameText.y = interfaz.height / 2;
// Create a slime and add it to the scene
var slime = new Slime();
// Position slime at the center of BG and set base position
var centerX = bg.width / 2;
var centerY = bg.height / 2;
slime.setBasePosition(centerX, centerY);
// Set initial properties for animations
slime.alpha = 1;
slime.scaleX = 1;
slime.scaleY = 1;
// Play background music
LK.playMusic('BGSong3');
// --- Info Panel for BGMenu ---
var infoPanelHeight = bgMenu.height - interfaz.height - 40;
var infoPanelWidth = bgMenu.width;
var infoPanelY = bgMenu.y + interfaz.height + 20;
var infoPanelX = bgMenu.x + (bgMenu.width - infoPanelWidth) / 2; // Center horizontally
// Create a container for the info panel
var infoPanel = new Container();
infoPanel.x = infoPanelX;
infoPanel.y = infoPanelY;
// No background for the info panel
// Prepare info categories and data
var infoCategories = [{
title: "Rarity",
get: function get(i) {
var rarityValue = SlimeInfo[i].Rarity;
this.currentRarityValue = rarityValue;
return rarityNamesByValue[rarityValue];
}
}, {
title: "History",
get: function get(i) {
return SlimeInfo[i].History;
}
}, {
title: "Location",
get: function get(i) {
return SlimeInfo[i].Location;
}
}, {
title: "Favorite Food",
get: function get(i) {
return SlimeInfo[i].FavoriteFood;
}
}, {
title: "Ability",
get: function get(i) {
return SlimeInfo[i].Ability;
}
}, {
title: "Stats",
get: function get(i) {
var s = SlimeInfo[i].Stats;
// Create visual stat bars with colored values using actual colors instead of tags
function formatStat(name, value) {
var barChars = "■".repeat(value);
var emptyChars = "□".repeat(10 - value);
return name + ": " + value + " [" + barChars + emptyChars + "]";
}
// Create a single column with all 6 stats
var statText = "";
statText += formatStat("Strength", s.strength) + "\n";
statText += formatStat("Agility", s.agility) + "\n";
statText += formatStat("Defense", s.defense) + "\n";
statText += formatStat("Magic", s.magic) + "\n";
statText += formatStat("Luck", s.luck) + "\n";
statText += formatStat("Mysticism", s.mysticism);
return statText;
}
}, {
title: "Lifespan",
get: function get(i) {
return SlimeInfo[i].Lifespan;
}
}];
// Create a container for the scrollable text
var infoTextContainer = new Container();
infoTextContainer.x = 30;
infoTextContainer.y = 30; // Add top margin
// Function to update info text for current slime
function updateInfoPanel() {
// Remove old children
infoTextContainer.removeChildren();
var y = 0;
for (var c = 0; c < infoCategories.length; c++) {
// Add extra spacing between sections if not the first section
if (c > 0) {
y += 80; // Add extra spacing between sections
}
// Title with gradient effect based on category
var titleColors = {
"Rarity": 0xFFD700,
"History": 0xCF9FFF,
"Location": 0x98FB98,
"Favorite Food": 0xFF7F50,
"Ability": 0x00BFFF,
"Stats": 0xFF1493,
"Lifespan": 0x00FA9A
};
var titleColor = titleColors[infoCategories[c].title] || 0xFFF7B2;
var titleText = new Text2(infoCategories[c].title, {
size: 110,
fill: titleColor,
font: "GillSans-Bold",
align: "center",
dropShadow: true,
dropShadowColor: 0x000000,
dropShadowDistance: 3,
dropShadowAlpha: 0.5
});
titleText.anchor.set(0.5, 0);
titleText.x = infoPanelWidth / 2 - 30;
titleText.y = y;
infoTextContainer.addChild(titleText);
y += titleText.height + 6;
// Info - wrap text to fit screen width
var infoContent = infoCategories[c].get(currentSlimeIndex);
var wrappedText = infoContent;
// Only apply text wrapping if not the stats category (which already has formatting)
if (infoCategories[c].title !== "Stats") {
wrappedText = wrapText(infoContent, infoPanelWidth - 60, 85); // Wrap text with some padding
}
// Choose text color based on category
var textColors = {
"Rarity": 0xFFFACD,
"History": 0xE6E6FA,
"Location": 0xF0FFF0,
"Favorite Food": 0xFFE4E1,
"Ability": 0xE0FFFF,
"Stats": 0xFFE4E1,
"Lifespan": 0xF0FFFF
};
var textColor = textColors[infoCategories[c].title] || 0xFFFFFF;
var infoText = new Text2(wrappedText, {
size: 85,
fill: textColor,
font: "GillSans",
align: infoCategories[c].title === "Stats" ? "left" : "center",
dropShadow: true,
dropShadowColor: 0x333333,
dropShadowDistance: 2,
dropShadowAlpha: 0.3
});
// Set anchor based on content type
if (infoCategories[c].title === "Stats") {
infoText.anchor.set(0.5, 0); // Center align stats too
infoText.x = infoPanelWidth / 2 - 30;
} else {
infoText.anchor.set(0.5, 0); // Center align for other content
infoText.x = infoPanelWidth / 2 - 30;
}
infoText.y = y + 20;
infoTextContainer.addChild(infoText);
// If this is the rarity category, add colored stars
if (infoCategories[c].title === "Rarity" && infoCategories[c].currentRarityValue) {
var starContainer = new Container();
starContainer.x = infoPanelWidth / 2 - 30;
starContainer.y = y + infoText.height + 40;
var rarityValue = infoCategories[c].currentRarityValue;
var starSpacing = 110,
totalWidth = (rarityValue - 1) * starSpacing;
var startX = -totalWidth / 2;
for (var s = 0; s < rarityValue; s++) {
var star = new Star();
star.x = startX + s * starSpacing;
star.y = 20;
star.alpha = 0;
star.scale.x = star.scale.y = 0.5;
star.setColorByRarity(rarityValue);
starContainer.addChild(star);
(function (targetStar, delay) {
LK.setTimeout(function () {
tween(targetStar, {
alpha: 1,
scaleX: 1,
scaleY: 1
}, {
duration: 400,
easing: tween.easeOut
});
}, delay);
})(star, s * 200);
}
infoTextContainer.addChild(starContainer);
y += 80;
}
y += infoText.height + 24;
}
infoTextContainer.totalHeight = y;
}
updateInfoPanel();
// --- Scrolling logic for info panel with visual enhancements ---
var scrollOffset = 0;
var maxScroll = 0;
function updateScrollLimits() {
maxScroll = Math.max(0, infoTextContainer.totalHeight - infoPanelHeight + 40 + 60); // Add 60px to account for top and bottom margins
// Create smooth bounce effect when reaching limits
if (scrollOffset < 0) {
scrollOffset = 0;
tween(infoTextContainer, {
y: 30
}, {
duration: 300,
easing: tween.elasticOut
});
}
if (scrollOffset > maxScroll) {
scrollOffset = maxScroll;
tween(infoTextContainer, {
y: 30 - maxScroll
}, {
duration: 300,
easing: tween.elasticOut
});
}
// Apply smooth scrolling
if (!scrollTweenActive && isScrolling === false) {
tween(infoTextContainer, {
y: 30 - scrollOffset
}, {
duration: 100,
easing: tween.easeOut
});
} else {
infoTextContainer.y = 30 - scrollOffset; // Apply top margin to starting position
}
}
updateScrollLimits();
// Touch/mouse drag to scroll with inertia and visual feedback
var isScrolling = false,
lastScrollY = 0,
scrollVelocity = 0,
lastScrollTime = 0,
scrollTweenActive = false,
scrollTracker = [];
infoPanel.interactive = true;
infoPanel.down = function (x, y, obj) {
isScrolling = true;
lastScrollY = y;
lastScrollTime = Date.now();
scrollTracker = []; // Reset scroll tracking
if (scrollTweenActive) {
tween.stop(infoTextContainer, {
y: true
});
scrollTweenActive = false;
}
};
infoPanel.move = function (x, y, obj) {
if (isScrolling) {
var currentTime = Date.now();
var timeDelta = currentTime - lastScrollTime;
var dy = y - lastScrollY;
// Track last few movements for better momentum calculation
scrollTracker.push({
dy: dy,
time: timeDelta
});
if (scrollTracker.length > 5) {
scrollTracker.shift();
}
if (timeDelta > 0) {
scrollVelocity = dy / timeDelta * 15;
}
scrollOffset -= dy;
updateScrollLimits();
lastScrollY = y;
lastScrollTime = currentTime;
}
};
infoPanel.up = function (x, y, obj) {
if (isScrolling) {
isScrolling = false;
// Calculate average velocity from recent movements for smoother scroll
var recentVelocity = 0;
var totalWeight = 0;
for (var i = 0; i < scrollTracker.length; i++) {
var weight = (i + 1) / scrollTracker.length;
recentVelocity += scrollTracker[i].dy / scrollTracker[i].time * weight;
totalWeight += weight;
}
if (totalWeight > 0) {
scrollVelocity = recentVelocity / totalWeight * 15;
}
if (Math.abs(scrollVelocity) > 0.1) {
var targetScroll = Math.max(0, Math.min(maxScroll, scrollOffset - scrollVelocity * 50));
var targetY = 30 - targetScroll;
scrollTweenActive = true;
tween(infoTextContainer, {
y: targetY
}, {
duration: 1000,
easing: tween.easeOutQuint,
onFinish: function onFinish() {
scrollOffset = 30 - infoTextContainer.y;
scrollTweenActive = false;
}
});
}
}
};
// Unified handler for both navigation buttons
function createButtonHandler(direction) {
return function (x, y, obj) {
changeSlime(direction);
updateInfoPanel();
updateScrollLimits();
};
}
leftButton.down = createButtonHandler('prev');
rightButton.down = createButtonHandler('next');
// When changing slime, update info panel and scroll position
function updateSlimeAndInfo() {
// Stop existing tweens before starting new ones to prevent animation conflicts
tween.stop(slime);
// Enhanced slime transition effects with color flash and particle-like animation
tween(slime, {
alpha: 0,
scaleX: 0.8,
scaleY: 0.8,
rotation: -0.1
}, {
duration: 300,
easing: tween.easeOut,
onFinish: function onFinish() {
// Flash background with slime color
var slimeColors = [0xa154b0, 0xd6f1ff, 0x757eff, 0xa3a3a3, 0xff5c5c, 0x303030, 0x0dbf51, 0x794311, 0xffe600, 0x4f226d, 0xf7f497];
LK.effects.flashObject(bg, slimeColors[currentSlimeIndex], 300);
slime.removeChildren();
slime.attachAsset(slimes[currentSlimeIndex], {
anchorX: 0.5,
anchorY: 0.5,
width: 500,
height: 500
});
// Reset to base position to prevent drift
slime.x = slime.baseX;
slime.y = slime.baseY;
slime.alpha = 0;
slime.scaleX = 0.8;
slime.scaleY = 0.8;
slime.rotation = 0.1;
// More dynamic entrance animation
tween(slime, {
alpha: 1,
scaleX: 1.2,
scaleY: 1.2,
rotation: 0
}, {
duration: 400,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(slime, {
scaleX: 1,
scaleY: 1
}, {
duration: 500,
easing: tween.elasticOut
});
// Add gentle bobbing animation but store a reference to the initial position
var initialY = bg.height / 2; // Store original position
LK.setTimeout(function () {
tween(slime, {
y: initialY - 15
}, {
duration: 1200,
easing: tween.easeInOut,
repeat: -1,
yoyo: true
});
}, 500);
}
});
}
});
// Define slime-specific colors based on their visual appearance
var slimeColors = [0xa154b0,
// ClasicSlime (purple)
0xd6f1ff,
// SnowySlime (light blue)
0x757eff,
// WaterSlime (blue)
0xa3a3a3,
// RockSlime (gray)
0xff5c5c,
// FireSlime (red)
0x303030,
// ShadowSlime (dark gray)
0x0dbf51,
// ForestSlime (green)
0x794311,
// BeastSlime (brown)
0xffe600,
// LuckySlime (yellow)
0x4f226d,
// RunicSlime (dark purple)
0xf7f497 // DivineSlime (light yellow)
];
tween(slimeNameText, {
alpha: 0,
scaleX: 0.9,
scaleY: 0.9
}, {
duration: 200,
easing: tween.easeOut,
onFinish: function onFinish() {
slimeNameText.setText(SlimeInfo[currentSlimeIndex].SlimeName);
// Initialize style object if it doesn't exist
if (!slimeNameText.style) {
slimeNameText.style = {};
}
// Apply slime-specific text color
slimeNameText.style.fill = slimeColors[currentSlimeIndex];
slimeNameText.style.dropShadow = true;
slimeNameText.style.dropShadowColor = 0x000000;
slimeNameText.style.dropShadowDistance = 3;
slimeNameText.style.dropShadowAlpha = 0.5;
// Create more dynamic animation for the name
tween(slimeNameText, {
alpha: 1,
scaleX: 1.1,
scaleY: 1.1
}, {
duration: 200,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(slimeNameText, {
scaleX: 1,
scaleY: 1
}, {
duration: 400,
easing: tween.elasticOut
});
}
});
}
});
// Update content and scroll position
updateInfoPanel();
scrollOffset = 0;
updateScrollLimits();
// Fade in info container
infoTextContainer.alpha = 0;
tween(infoTextContainer, {
alpha: 1
}, {
duration: 400,
easing: tween.easeOut
});
}
function changeSlime(direction) {
currentSlimeIndex = direction === 'next' ? (currentSlimeIndex + 1) % slimes.length : (currentSlimeIndex - 1 + slimes.length) % slimes.length;
updateSlimeAndInfo();
}
/*
* Asset initialization
*/
game.addChild(bgMenu);
game.addChild(infoPanel);
infoPanel.addChild(infoTextContainer);
game.addChild(bg);
game.addChild(interfaz);
interfaz.addChild(leftButton);
interfaz.addChild(rightButton);
interfaz.addChild(slimeNameText);
game.addChild(slime);
Star cartoon. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Un slime verde RPG con estilo suave y simple. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Un slime rojo prendido fuego RPG con estilo suave y simple. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Un slime RPG amarillo y divino con estilo suave y simple. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Un slime fantasmal RPG con estilo suave y simple. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Un slime blanco con una moneda brillante en la frente RPG con estilo suave y simple. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Un slime gris RPG con rocas en su espalda. Estilo suave y simple. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Un slime RPG nevado con estilo suave y simple. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Un slime de agua RPG con estilo suave y simple. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Un slime bestia peludo RPG con estilo suave y simple. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Un slime morado con runas magicas RPG. Estilo suave y simple. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Un slime angelical RPG con estilo suave y simple. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Fullscreen medieval landscape banner, 16:9, high definition, for a game titled "Slime Bestiary". Medieval forest with multiple colored slimes. No text on banner!