User prompt
Please fix the bug: 'Uncaught TypeError: storage.set is not a function' in or related to this line: 'storage.set('language', currentLanguage);' Line Number: 354 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Please fix the bug: 'storage.getValue is not a function' in or related to this line: 'var currentLanguage = storage.getValue('language') || 'en';' Line Number: 572 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Please fix the bug: 'storage.get is not a function' in or related to this line: 'var currentLanguage = storage.get('language') || 'en';' Line Number: 572
User prompt
"I want you to create a main menu. It will include a settings menu with support for different languages: Russian, French, English, and Turkish."
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'toGlobal')' in or related to this line: 'var localPos = self.toLocal(obj.parent.toGlobal(obj.position));' Line Number: 289
Code edit (1 edits merged)
Please save this source code
User prompt
Thoroughbred Legacy: Champion's Rise
Initial prompt
Game Title Concept: "Thoroughbred Echoes: Champion's Ascent" (or similar, AI can suggest alternatives) Core Game Genre: Detailed Horse Racing Simulation and Management RPG. Think Rival Stars Horse Racing or Gallop Racer, combined with in-depth management and detailed thoroughbred breeding elements. Target Audience: Players who love horses, horse racing, strategic management, and progression-based RPG elements. Those seeking a realistic simulation experience without sacrificing fun. I. Overall Vision & Game Pillars This game aims to provide players with the opportunity to establish their own horse farm, breed thoroughbred horses, train them, and lead them to victory on international race tracks. The focus is on in-depth horse management, training, jockey skills, and strategic race decisions. The game should offer a dynamic and evolving horse racing world where the player's decisions have significant short-term and long-term consequences. Pillar 1: In-Depth Horse Management & Breeding: Each horse must have unique genetic traits, personalities, and development potential. Pillar 2: Strategic Racing Experience: Races shouldn't just be about quick button presses; tactics, jockey skill, and the horse's condition must be critical. Pillar 3: Evolving Economic & Social System: The racing world should feel alive and competitive, reacting to the player's actions. Pillar 4: RPG-Style Progression: Both the player (stable owner/trainer) and jockeys' skills should develop over time. Pillar 5: Visual & Sensory Immersion: Detailed horse models, realistic animations, diverse tracks, and atmospheric sound design. II. Setting & Atmosphere Era: Contemporary horse racing world, encompassing global racing calendars and different cultural track environments (e.g., British turf tracks, American dirt tracks, major Japanese racecourses). World Map: A dynamic global map or race calendar interface. Players should be able to travel to participate in races in different regions and expand their farm internationally. Race Tracks: Numerous realistic or inspired race tracks, each with unique characteristics (length, surface type, sharpness of turns, elevation changes). Weather conditions (rain, sunny, cloudy) should affect track conditions. Atmosphere: A competitive, prestigious, and at times dramatic atmosphere. This should be reinforced through social events, auctions, media attention, and interactions with rivals. III. Core Gameplay Mechanics A. Horse Breeding & Management: Genetic System: Each horse should possess a unique genetic code. Parents' genes (e.g., speed, stamina, temperament, injury susceptibility) should pass to offspring. A complex thoroughbred database to expand the gene pool. Breeding & Stallion Selection: Players can breed their own horses or lease outside stallions and mares. Detailed analysis of genetic matchups. Horse Growth & Development: Stages of horse development from foal to adult. Each age having unique training and health requirements. Personality & Temperament: Each horse should have a distinct personality (e.g., feisty, calm, competitive, timid). This should affect training methods and race performance. Training System: Detailed training programs: Physical Training: Focusing on specific attributes like speed, stamina, acceleration. Overtraining should increase injury risk. Mental Training: Developing mental aspects such as starting discipline, calmness in crowds, and competing with rival horses. Training Conditions: Training sessions should be affected by weather conditions, track surface, and the jockey's skill. Health & Care: Regular veterinary checks, feeding programs, and rest needs for horses. Injuries and illnesses can lead to performance drops or career endings. Rehabilitation processes. Retirement: Successful horses can be retired to stud, continuing their genetic lines within the game. B. Racing Mechanics: Real-Time Race Control: The player controls their jockey during races. This shouldn't just be about pressing a "speed up" button but also: Positioning: Finding the ideal position throughout the race, avoiding being boxed in. Energy Management: Judiciously using the horse's stamina, deciding when to make a sprint. Maneuvers: Overtaking from the inside, swinging wide, blocking rivals (within fair limits). Jockey Skills: The jockey's ability to communicate with the horse, use the whip (within fair limits), and calm the horse during the race. Pre-Race Strategy: Jockey Selection: Each jockey should have different skills, weight, and preferred horse temperaments. Tactical Instructions: Giving instructions based on the horse's running style (e.g., front-runner, closer, mid-pacer) and track conditions. Equipment Selection: Minor adjustments like tack and horseshoe type should affect performance. Rival Horse AI: Opponent horses and jockeys should act intelligently, have their own strategies, and create a dynamic competitive environment. Photo Finish & Detailed Race Results: Races should conclude with millisecond precision. Detailed post-race statistics (speed, distance covered, sprint times, etc.). C. Management & Economy: Farm Management: Facility Construction: Building and upgrading facilities such as stables, training tracks (on different surfaces), breeding facilities, and veterinary clinics. Staff Management: Hiring staff like trainers, grooms, veterinarians, and jockeys, assigning them based on skills, and managing their salaries. Resource Management: Managing consumables like feed, medicine, and equipment. Financial Management: Income Sources: Race winnings, horse sales, stud fees, passive betting income. Expenses: Staff salaries, horse care, training, travel, facility maintenance, and upgrades. Loans & Debts: Taking bank loans if necessary, maintaining financial balance. Market & Trade: Buying/Selling Horses: Participating in horse auctions, buying/selling young foals or retired champions. Sponsorships: Securing sponsorship deals from brands for additional income. Reputation System: Gaining reputation through racing success, ethical conduct, and breeding achievements. High reputation should grant access to better jockeys, invitations to more prestigious races, and higher stud fees. D. RPG & Progression: Player Character (Stable Owner/Trainer): Skills that can be developed through a talent tree (e.g., Horse Health Knowledge, Training Techniques, Business Acumen, Charisma). These skills provide bonuses in different aspects of the game. Jockey Development: Jockeys should improve their skills (e.g., Balance, Speed Control, Sprint Timing) with race experience. Discovering and signing contracts with new jockeys. Fame & Trophy Collection: Major races won, trophies, and records should secure a place for the player and their horses in a "Hall of Fame." Quests & Events: Dynamically generated quests (e.g., making a specific horse a champion, beating a rival, earning a certain amount of money) and special events (e.g., annual breeding auction, international racing festivals). IV. Emergent & Dynamic Systems: Dynamic Rival AI: Rival stable owners and trainers should intelligently breed and race their horses based on their own strategies. Their successes or failures should impact market prices and overall competition. Weather System: Real-time weather changes (rain, sun, snow) should affect race track surfaces and alter race tactics. Injury & Risk System: Horses' risk of injury during training and races. Treatment processes, potential career endings, or performance drops. Random Events: Unexpected events (e.g., epidemics, financial fluctuations, discovery of new talented foals) should influence the player's strategies. Media & Public Opinion: Media attention and public opinion should vary based on race results, horse popularity, and player actions. V. User Interface (UI) & User Experience (UX) Considerations: Intuitive & Fluid: The UI should be clean and understandable despite comprehensive information. Easy navigation between menus. Informative Tooltips: Detailed and clear tooltips for all statistics, mechanics, and UI elements. Horse Profile & Pedigree: Comprehensive profile screen for each horse, showing all its statistics, health status, training history, and a visualized interface for its detailed pedigree. Race Interface: A clear HUD during races that shows essential information (position, speed, stamina, distance) without obstructing the view. Visual Feedback: Clear visual and auditory feedback for all management decisions and race events. Performance: Optimize for smooth performance, especially during large-scale races and detailed farm views. VI. Desired Output from AI: Based on this prompt, the AI is expected to generate a detailed game design document (GDD) covering: Core Gameplay Loop Diagram/Description: A clear explanation of the daily, weekly, and campaign-level gameplay loops. Detailed Horse Genetics & Attribute System: An in-depth explanation of how horse genetic traits are generated, inherited, and how they affect performance. Training & Conditioning System: A detailed breakdown of training types, their effects, and the risks of fatigue and injury. Race Mechanics Deep Dive: A detailed explanation of how in-race control, jockey skills, and horse AI function. Economic Simulation Model: A basic overview of how the game's economy would function, including income, expenses, and market fluctuations. Key UI/UX Screens: Conceptual layouts or descriptive mock-ups for crucial UI screens (e.g., Horse Profile, Farm Management, Race Calendar, Jockey Skill Screen). Emergent Narrative Examples: Illustrative examples of how dynamic systems could create compelling player stories (e.g., the rise of an underdog champion, an enduring rivalry). Technical Considerations (High-Level): Any high-level thoughts on potential engine choices, asset pipelines, or technical challenges. Monetization Strategy (if applicable): A high-level thought process on how such a game could be monetized without compromising the core experience (e.g., expansions, cosmetic DLC, not pay-to-win)
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var Horse = Container.expand(function (config) {
var self = Container.call(this);
config = config || {};
// Horse stats
self.name = config.name || 'Unnamed Horse';
self.speed = config.speed || Math.random() * 50 + 50;
self.stamina = config.stamina || Math.random() * 50 + 50;
self.temperament = config.temperament || Math.random() * 50 + 50;
self.age = config.age || 2;
self.raceWins = config.raceWins || 0;
self.value = config.value || 10000;
self.currentEnergy = 100;
self.maxEnergy = 100;
// Visual representation
var horseBody = self.attachAsset('horse', {
anchorX: 0.5,
anchorY: 0.5
});
var jockeySprite = self.attachAsset('jockey', {
anchorX: 0.5,
anchorY: 0.5,
y: -20
});
// Racing properties
self.racePosition = 0;
self.raceSpeed = 0;
self.isRacing = false;
self.train = function (type) {
switch (type) {
case 'speed':
self.speed += Math.random() * 5 + 2;
break;
case 'stamina':
self.stamina += Math.random() * 5 + 2;
break;
case 'temperament':
self.temperament += Math.random() * 5 + 2;
break;
}
self.currentEnergy = Math.max(0, self.currentEnergy - 20);
};
self.rest = function () {
self.currentEnergy = Math.min(self.maxEnergy, self.currentEnergy + 30);
};
self.breed = function (partner) {
var offspring = new Horse({
speed: (self.speed + partner.speed) / 2 + (Math.random() - 0.5) * 20,
stamina: (self.stamina + partner.stamina) / 2 + (Math.random() - 0.5) * 20,
temperament: (self.temperament + partner.temperament) / 2 + (Math.random() - 0.5) * 20,
age: 0,
name: 'Foal ' + Math.floor(Math.random() * 1000)
});
return offspring;
};
self.getRaceSpeed = function () {
var energyFactor = self.currentEnergy / self.maxEnergy;
return (self.speed * 0.6 + self.stamina * 0.4) * energyFactor;
};
self.update = function () {
if (self.isRacing) {
self.raceSpeed = self.getRaceSpeed() * (0.8 + Math.random() * 0.4);
self.racePosition += self.raceSpeed * 0.1;
self.x = self.racePosition;
// Energy drain during race
self.currentEnergy = Math.max(0, self.currentEnergy - 0.2);
}
};
return self;
});
var MainMenu = Container.expand(function () {
var self = Container.call(this);
var background = self.attachAsset('menuBackground', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1366
});
var titleText = new Text2('', {
size: 80,
fill: '#ffffff'
});
titleText.anchor.set(0.5, 0.5);
titleText.x = 1024;
titleText.y = 500;
self.addChild(titleText);
var playBtn = self.attachAsset('menuButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1200
});
var playText = new Text2('', {
size: 40,
fill: '#ffffff'
});
playText.anchor.set(0.5, 0.5);
playText.x = 1024;
playText.y = 1200;
self.addChild(playText);
var settingsBtn = self.attachAsset('settingsButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1350
});
var settingsText = new Text2('', {
size: 35,
fill: '#ffffff'
});
settingsText.anchor.set(0.5, 0.5);
settingsText.x = 1024;
settingsText.y = 1350;
self.addChild(settingsText);
self.updateLanguage = function () {
titleText.setText(translations[currentLanguage].title);
playText.setText(translations[currentLanguage].play);
settingsText.setText(translations[currentLanguage].settings);
};
self.down = function (x, y, obj) {
if (!obj || !obj.parent || !obj.parent.toGlobal) {
var localPos = {
x: x,
y: y
};
} else {
var localPos = self.toLocal(obj.parent.toGlobal(obj.position));
}
// Check play button
if (localPos.x >= 874 && localPos.x <= 1174 && localPos.y >= 1160 && localPos.y <= 1240) {
currentView = 'stable';
updateView();
}
// Check settings button
if (localPos.x >= 899 && localPos.x <= 1149 && localPos.y >= 1320 && localPos.y <= 1380) {
currentView = 'settings';
updateView();
}
};
return self;
});
var RaceView = Container.expand(function () {
var self = Container.call(this);
// Create race track
var track = self.attachAsset('trackSegment', {
anchorX: 0,
anchorY: 0.5,
x: 0,
y: 1366
});
var finishLine = self.attachAsset('finish', {
anchorX: 0.5,
anchorY: 0.5,
x: 1900,
y: 1366
});
var raceTitle = new Text2('RACE IN PROGRESS', {
size: 50,
fill: '#ffffff'
});
raceTitle.anchor.set(0.5, 0.5);
raceTitle.x = 1024;
raceTitle.y = 200;
self.addChild(raceTitle);
self.raceHorses = [];
self.setupRace = function () {
// Clear existing race horses
for (var i = 0; i < self.raceHorses.length; i++) {
self.raceHorses[i].destroy();
}
self.raceHorses = [];
// Add player's horses and AI horses
var raceHorsesList = [];
// Add player horses
for (var i = 0; i < Math.min(horses.length, 3); i++) {
raceHorsesList.push(horses[i]);
}
// Add AI horses to fill up to 6 total
while (raceHorsesList.length < 6) {
var aiHorse = new Horse({
name: 'AI Horse ' + (raceHorsesList.length + 1),
speed: Math.random() * 40 + 60,
stamina: Math.random() * 40 + 60,
temperament: Math.random() * 40 + 60
});
raceHorsesList.push(aiHorse);
}
// Position horses at start line
for (var i = 0; i < raceHorsesList.length; i++) {
var horse = raceHorsesList[i];
horse.x = 50;
horse.y = 1200 + i * 70;
horse.racePosition = 0;
horse.isRacing = true;
horse.currentEnergy = horse.maxEnergy;
self.addChild(horse);
self.raceHorses.push(horse);
}
};
self.checkRaceFinish = function () {
for (var i = 0; i < self.raceHorses.length; i++) {
var horse = self.raceHorses[i];
if (horse.racePosition >= 1850) {
// Race finished
self.finishRace(horse);
return true;
}
}
return false;
};
self.finishRace = function (winner) {
// Stop all horses
for (var i = 0; i < self.raceHorses.length; i++) {
self.raceHorses[i].isRacing = false;
}
// Check if winner is player's horse
var isPlayerWinner = false;
for (var i = 0; i < horses.length; i++) {
if (horses[i] === winner) {
isPlayerWinner = true;
winner.raceWins++;
break;
}
}
if (isPlayerWinner) {
money += 10000;
LK.setScore(LK.getScore() + 1);
LK.getSound('crowdCheer').play();
} else {
money += 2000; // Participation prize
}
updateMoneyDisplay();
// Return to stable after 3 seconds
LK.setTimeout(function () {
currentView = 'stable';
updateView();
}, 3000);
};
return self;
});
var SettingsMenu = Container.expand(function () {
var self = Container.call(this);
var background = self.attachAsset('menuBackground', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1366
});
var titleText = new Text2('', {
size: 60,
fill: '#ffffff'
});
titleText.anchor.set(0.5, 0.5);
titleText.x = 1024;
titleText.y = 400;
self.addChild(titleText);
var languageLabel = new Text2('', {
size: 40,
fill: '#ffffff'
});
languageLabel.anchor.set(0.5, 0.5);
languageLabel.x = 1024;
languageLabel.y = 800;
self.addChild(languageLabel);
// Language buttons
var languages = ['English', 'Russian', 'French', 'Turkish'];
var languageCodes = ['en', 'ru', 'fr', 'tr'];
self.languageButtons = [];
for (var i = 0; i < languages.length; i++) {
var langBtn = self.attachAsset('languageButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 500 + i % 2 * 500,
y: 950 + Math.floor(i / 2) * 120
});
var langText = new Text2(languages[i], {
size: 25,
fill: '#ffffff'
});
langText.anchor.set(0.5, 0.5);
langText.x = 500 + i % 2 * 500;
langText.y = 950 + Math.floor(i / 2) * 120;
langText.langCode = languageCodes[i];
self.addChild(langText);
self.languageButtons.push({
button: langBtn,
text: langText,
code: languageCodes[i]
});
}
var backBtn = self.attachAsset('backButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1500
});
var backText = new Text2('', {
size: 30,
fill: '#ffffff'
});
backText.anchor.set(0.5, 0.5);
backText.x = 1024;
backText.y = 1500;
self.addChild(backText);
self.updateLanguage = function () {
titleText.setText(translations[currentLanguage].settings);
languageLabel.setText(translations[currentLanguage].language);
backText.setText(translations[currentLanguage].back);
};
self.down = function (x, y, obj) {
if (!obj || !obj.parent || !obj.parent.toGlobal) {
var localPos = {
x: x,
y: y
};
} else {
var localPos = self.toLocal(obj.parent.toGlobal(obj.position));
}
// Check language buttons
for (var i = 0; i < self.languageButtons.length; i++) {
var btnX = 500 + i % 2 * 500;
var btnY = 950 + Math.floor(i / 2) * 120;
if (localPos.x >= btnX - 100 && localPos.x <= btnX + 100 && localPos.y >= btnY - 25 && localPos.y <= btnY + 25) {
currentLanguage = self.languageButtons[i].code;
storage.language = currentLanguage;
updateAllLanguages();
break;
}
}
// Check back button
if (localPos.x >= 949 && localPos.x <= 1099 && localPos.y >= 1475 && localPos.y <= 1525) {
currentView = 'menu';
updateView();
}
};
return self;
});
var StableView = Container.expand(function () {
var self = Container.call(this);
var background = self.attachAsset('stableBox', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1366
});
var titleText = new Text2('Your Stable', {
size: 60,
fill: '#ffffff'
});
titleText.anchor.set(0.5, 0.5);
titleText.x = 1024;
titleText.y = 300;
self.addChild(titleText);
// Action buttons
var breedBtn = self.attachAsset('breedButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1800
});
var breedText = new Text2('BREED', {
size: 30,
fill: '#ffffff'
});
breedText.anchor.set(0.5, 0.5);
breedText.x = 1024;
breedText.y = 1800;
self.addChild(breedText);
var trainBtn = self.attachAsset('trainButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1900
});
var trainText = new Text2('TRAIN', {
size: 30,
fill: '#ffffff'
});
trainText.anchor.set(0.5, 0.5);
trainText.x = 1024;
trainText.y = 1900;
self.addChild(trainText);
var raceBtn = self.attachAsset('raceButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 2000
});
var raceText = new Text2('RACE', {
size: 30,
fill: '#ffffff'
});
raceText.anchor.set(0.5, 0.5);
raceText.x = 1024;
raceText.y = 2000;
self.addChild(raceText);
self.horseIcons = [];
self.updateHorseDisplay = function () {
// Clear existing icons
for (var i = 0; i < self.horseIcons.length; i++) {
self.horseIcons[i].destroy();
}
self.horseIcons = [];
// Add current horses
for (var i = 0; i < horses.length; i++) {
var horse = horses[i];
var icon = self.attachAsset('horseIcon', {
anchorX: 0.5,
anchorY: 0.5,
x: 600 + i % 3 * 200,
y: 500 + Math.floor(i / 3) * 100
});
var nameText = new Text2(horse.name, {
size: 20,
fill: '#ffffff'
});
nameText.anchor.set(0.5, 0.5);
nameText.x = 600 + i % 3 * 200;
nameText.y = 550 + Math.floor(i / 3) * 100;
self.addChild(nameText);
var statsText = new Text2('Speed: ' + Math.floor(horse.speed) + ' Energy: ' + Math.floor(horse.currentEnergy), {
size: 16,
fill: '#ffffff'
});
statsText.anchor.set(0.5, 0.5);
statsText.x = 600 + i % 3 * 200;
statsText.y = 570 + Math.floor(i / 3) * 100;
self.addChild(statsText);
self.horseIcons.push(icon);
}
};
self.updateLanguage = function () {
titleText.setText(translations[currentLanguage].yourStable);
breedText.setText(translations[currentLanguage].breed);
trainText.setText(translations[currentLanguage].train);
raceText.setText(translations[currentLanguage].race);
};
self.down = function (x, y, obj) {
// Safety check for obj.parent
if (!obj || !obj.parent || !obj.parent.toGlobal) {
var localPos = {
x: x,
y: y
};
} else {
var localPos = self.toLocal(obj.parent.toGlobal(obj.position));
}
// Check breed button
if (localPos.x >= 924 && localPos.x <= 1124 && localPos.y >= 1770 && localPos.y <= 1830) {
if (horses.length >= 2) {
var offspring = horses[0].breed(horses[1]);
horses.push(offspring);
money -= 5000;
self.updateHorseDisplay();
updateMoneyDisplay();
}
}
// Check train button
if (localPos.x >= 924 && localPos.x <= 1124 && localPos.y >= 1870 && localPos.y <= 1930) {
if (horses.length > 0) {
horses[0].train('speed');
money -= 1000;
self.updateHorseDisplay();
updateMoneyDisplay();
}
}
// Check race button
if (localPos.x >= 924 && localPos.x <= 1124 && localPos.y >= 1970 && localPos.y <= 2030) {
if (horses.length > 0) {
startRace();
}
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x228B22
});
/****
* Game Code
****/
// Language translations
var translations = {
en: {
title: 'Thoroughbred Legacy',
play: 'PLAY',
settings: 'SETTINGS',
language: 'Language:',
back: 'BACK',
yourStable: 'Your Stable',
breed: 'BREED',
train: 'TRAIN',
race: 'RACE',
money: 'Money: $',
wins: 'Wins: '
},
ru: {
title: 'Наследие Чистокровных',
play: 'ИГРАТЬ',
settings: 'НАСТРОЙКИ',
language: 'Язык:',
back: 'НАЗАД',
yourStable: 'Ваша Конюшня',
breed: 'РАЗВЕДЕНИЕ',
train: 'ТРЕНИРОВКА',
race: 'ГОНКА',
money: 'Деньги: $',
wins: 'Побед: '
},
fr: {
title: 'Héritage Pur-Sang',
play: 'JOUER',
settings: 'PARAMÈTRES',
language: 'Langue:',
back: 'RETOUR',
yourStable: 'Votre Écurie',
breed: 'ÉLEVAGE',
train: 'ENTRAÎNER',
race: 'COURSE',
money: 'Argent: $',
wins: 'Victoires: '
},
tr: {
title: 'Safkan Mirası',
play: 'OYNA',
settings: 'AYARLAR',
language: 'Dil:',
back: 'GERİ',
yourStable: 'Ahırınız',
breed: 'ÜRETME',
train: 'EĞİTİM',
race: 'YARIŞ',
money: 'Para: $',
wins: 'Galibiyet: '
}
};
// Load saved language or default to English
var currentLanguage = storage.language || 'en';
// Game state
var currentView = 'menu';
var horses = [];
var money = 50000;
var raceInProgress = false;
// UI Elements
var moneyText = new Text2('Money: $' + money, {
size: 40,
fill: '#ffffff'
});
moneyText.anchor.set(0, 0);
moneyText.x = 150;
moneyText.y = 50;
LK.gui.topLeft.addChild(moneyText);
var scoreText = new Text2('Wins: ' + LK.getScore(), {
size: 40,
fill: '#ffffff'
});
scoreText.anchor.set(1, 0);
scoreText.x = -50;
scoreText.y = 50;
LK.gui.topRight.addChild(scoreText);
// Views
var mainMenu = new MainMenu();
var settingsMenu = new SettingsMenu();
var stableView = new StableView();
var raceView = new RaceView();
// Initialize with starter horses
horses.push(new Horse({
name: 'Thunder',
speed: 70,
stamina: 65,
temperament: 60
}));
horses.push(new Horse({
name: 'Lightning',
speed: 60,
stamina: 70,
temperament: 65
}));
function updateMoneyDisplay() {
moneyText.setText(translations[currentLanguage].money + money);
scoreText.setText(translations[currentLanguage].wins + LK.getScore());
}
function updateAllLanguages() {
updateMoneyDisplay();
if (mainMenu.parent) {
mainMenu.updateLanguage();
}
if (settingsMenu.parent) {
settingsMenu.updateLanguage();
}
if (stableView.parent) {
stableView.updateLanguage();
}
}
function updateView() {
// Remove all views
if (mainMenu.parent) {
game.removeChild(mainMenu);
}
if (settingsMenu.parent) {
game.removeChild(settingsMenu);
}
if (stableView.parent) {
game.removeChild(stableView);
}
if (raceView.parent) {
game.removeChild(raceView);
}
// Add current view
if (currentView === 'menu') {
game.addChild(mainMenu);
mainMenu.updateLanguage();
raceInProgress = false;
} else if (currentView === 'settings') {
game.addChild(settingsMenu);
settingsMenu.updateLanguage();
raceInProgress = false;
} else if (currentView === 'stable') {
game.addChild(stableView);
stableView.updateHorseDisplay();
stableView.updateLanguage();
raceInProgress = false;
} else if (currentView === 'race') {
game.addChild(raceView);
raceView.setupRace();
raceInProgress = true;
LK.getSound('hoofbeats').play();
}
}
function startRace() {
if (horses.length > 0) {
currentView = 'race';
updateView();
}
}
// Initialize view
updateView();
// Play background music
LK.playMusic('stableMusic');
// Main game loop
game.update = function () {
if (raceInProgress && raceView.parent) {
raceView.checkRaceFinish();
}
// Auto-rest horses when not racing
if (!raceInProgress) {
for (var i = 0; i < horses.length; i++) {
if (horses[i].currentEnergy < horses[i].maxEnergy) {
horses[i].currentEnergy = Math.min(horses[i].maxEnergy, horses[i].currentEnergy + 0.1);
}
}
}
// Win condition - 10 race wins
if (LK.getScore() >= 10) {
LK.showYouWin();
}
// Lose condition - out of money
if (money <= 0 && horses.length === 0) {
LK.showGameOver();
}
}; ===================================================================
--- original.js
+++ change.js
@@ -329,9 +329,9 @@
var btnX = 500 + i % 2 * 500;
var btnY = 950 + Math.floor(i / 2) * 120;
if (localPos.x >= btnX - 100 && localPos.x <= btnX + 100 && localPos.y >= btnY - 25 && localPos.y <= btnY + 25) {
currentLanguage = self.languageButtons[i].code;
- storage.set('language', currentLanguage);
+ storage.language = currentLanguage;
updateAllLanguages();
break;
}
}