/**** * Classes ****/ var Country = Container.expand(function (countryData) { var self = Container.call(this); self.countryData = countryData; self.isSelected = false; var countryShape = self.attachAsset('country', { anchorX: 0.5, anchorY: 0.5 }); var selectedShape = self.attachAsset('selectedCountry', { anchorX: 0.5, anchorY: 0.5, alpha: 0 }); var countryLabel = new Text2(countryData.name, { size: 24, fill: 0xFFFFFF }); countryLabel.anchor.set(0.5, 0.5); countryLabel.y = 10; self.addChild(countryLabel); self.select = function () { self.isSelected = true; selectedShape.alpha = 1; countryShape.alpha = 0; }; self.deselect = function () { self.isSelected = false; selectedShape.alpha = 0; countryShape.alpha = 1; }; self.down = function (x, y, obj) { if (!self.isSelected) { showCountryInfo(self.countryData); } }; return self; }); var InfoPanel = Container.expand(function () { var self = Container.call(this); var panel = self.attachAsset('infoPanel', { anchorX: 0.5, anchorY: 0.5 }); self.titleText = new Text2('', { size: 60, fill: 0x2C3E50 }); self.titleText.anchor.set(0.5, 0); self.titleText.y = -350; self.addChild(self.titleText); self.infoTexts = []; for (var i = 0; i < 8; i++) { var infoText = new Text2('', { size: 36, fill: 0x34495E }); infoText.anchor.set(0, 0); infoText.x = -850; infoText.y = -250 + i * 70; self.addChild(infoText); self.infoTexts.push(infoText); } var backBtn = self.attachAsset('backButton', { anchorX: 0.5, anchorY: 0.5, x: 0, y: 320 }); var backBtnText = new Text2('Back to Map', { size: 32, fill: 0xFFFFFF }); backBtnText.anchor.set(0.5, 0.5); backBtn.addChild(backBtnText); backBtn.down = function (x, y, obj) { hideCountryInfo(); }; self.updateInfo = function (countryData) { self.titleText.setText(countryData.name); var infoLines = ['🏛️ Capital: ' + countryData.capital, '👥 Population: ' + countryData.population, '💬 Language: ' + countryData.language, '💰 Currency: ' + countryData.currency, '🌍 Continent: ' + countryData.continent, '🏛️ Famous Landmark: ' + countryData.landmark, '🎭 Cultural Fact: ' + countryData.culture, '📚 Fun Fact: ' + countryData.funFact]; for (var i = 0; i < self.infoTexts.length; i++) { if (i < infoLines.length) { self.infoTexts[i].setText(infoLines[i]); } else { self.infoTexts[i].setText(''); } } }; return self; }); var SearchInterface = Container.expand(function () { var self = Container.call(this); var searchBtn = self.attachAsset('searchButton', { anchorX: 0.5, anchorY: 0.5 }); var searchText = new Text2('Search Countries', { size: 36, fill: 0xFFFFFF }); searchText.anchor.set(0.5, 0.5); searchBtn.addChild(searchText); self.currentIndex = 0; searchBtn.down = function (x, y, obj) { showRandomCountry(); }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87ceeb }); /**** * Game Code ****/ var countries = [{ name: 'United States', capital: 'Washington D.C.', population: '331 million', language: 'English', currency: 'US Dollar', continent: 'North America', landmark: 'Statue of Liberty', culture: 'Known for Hollywood and diverse cuisine', funFact: 'Has the world\'s largest economy' }, { name: 'France', capital: 'Paris', population: '67 million', language: 'French', currency: 'Euro', continent: 'Europe', landmark: 'Eiffel Tower', culture: 'Famous for cuisine and fashion', funFact: 'Most visited country in the world' }, { name: 'Japan', capital: 'Tokyo', population: '125 million', language: 'Japanese', currency: 'Yen', continent: 'Asia', landmark: 'Mount Fuji', culture: 'Known for technology and anime', funFact: 'Has over 6,800 islands' }, { name: 'Brazil', capital: 'Brasília', population: '215 million', language: 'Portuguese', currency: 'Real', continent: 'South America', landmark: 'Christ the Redeemer', culture: 'Famous for Carnival and soccer', funFact: 'Contains 60% of Amazon rainforest' }, { name: 'Egypt', capital: 'Cairo', population: '104 million', language: 'Arabic', currency: 'Egyptian Pound', continent: 'Africa', landmark: 'Great Pyramid of Giza', culture: 'Ancient civilization and hieroglyphs', funFact: 'Home to one of the Seven Wonders' }, { name: 'Australia', capital: 'Canberra', population: '26 million', language: 'English', currency: 'Australian Dollar', continent: 'Oceania', landmark: 'Sydney Opera House', culture: 'Known for unique wildlife', funFact: 'Smallest continent and largest island' }, { name: 'India', capital: 'New Delhi', population: '1.4 billion', language: 'Hindi, English', currency: 'Indian Rupee', continent: 'Asia', landmark: 'Taj Mahal', culture: 'Diverse cultures and spices', funFact: 'Most populous country in the world' }, { name: 'Canada', capital: 'Ottawa', population: '39 million', language: 'English, French', currency: 'Canadian Dollar', continent: 'North America', landmark: 'Niagara Falls', culture: 'Known for politeness and maple syrup', funFact: 'Second largest country by area' }]; var worldMapContainer = new Container(); game.addChild(worldMapContainer); var mapBackground = LK.getAsset('worldMap', { anchorX: 0.5, anchorY: 0.5 }); worldMapContainer.addChild(mapBackground); worldMapContainer.x = 2048 / 2; worldMapContainer.y = 1366 / 2; var countryObjects = []; var selectedCountry = null; var infoPanel = null; var isInfoVisible = false; // Position countries on the map var countryPositions = [{ x: -400, y: -100 }, // United States { x: 0, y: -200 }, // France { x: 500, y: -100 }, // Japan { x: -300, y: 200 }, // Brazil { x: 200, y: 0 }, // Egypt { x: 600, y: 300 }, // Australia { x: 400, y: 0 }, // India { x: -500, y: -200 } // Canada ]; for (var i = 0; i < countries.length; i++) { var country = new Country(countries[i]); country.x = countryPositions[i].x; country.y = countryPositions[i].y; worldMapContainer.addChild(country); countryObjects.push(country); } // Create search interface var searchInterface = new SearchInterface(); searchInterface.x = 2048 / 2; searchInterface.y = 200; game.addChild(searchInterface); // Create title var titleText = new Text2('Country Explorer Quiz', { size: 72, fill: 0x2C3E50 }); titleText.anchor.set(0.5, 0); titleText.x = 2048 / 2; titleText.y = 50; game.addChild(titleText); // Create instructions var instructionText = new Text2('Tap any country or search to learn more!', { size: 42, fill: 0x34495E }); instructionText.anchor.set(0.5, 0); instructionText.x = 2048 / 2; instructionText.y = 140; game.addChild(instructionText); function showCountryInfo(countryData) { if (selectedCountry) { selectedCountry.deselect(); } for (var i = 0; i < countryObjects.length; i++) { if (countryObjects[i].countryData.name === countryData.name) { selectedCountry = countryObjects[i]; selectedCountry.select(); break; } } if (!infoPanel) { infoPanel = new InfoPanel(); infoPanel.x = 2048 / 2; infoPanel.y = 1366; game.addChild(infoPanel); } infoPanel.updateInfo(countryData); worldMapContainer.y = -200; titleText.y = -300; instructionText.y = -300; searchInterface.y = -300; infoPanel.y = 1366 / 2; isInfoVisible = true; } function hideCountryInfo() { if (selectedCountry) { selectedCountry.deselect(); selectedCountry = null; } worldMapContainer.y = 1366 / 2; titleText.y = 50; instructionText.y = 140; searchInterface.y = 200; if (infoPanel) { infoPanel.y = 1366 + 400; } isInfoVisible = false; } function showRandomCountry() { var randomIndex = Math.floor(Math.random() * countries.length); showCountryInfo(countries[randomIndex]); } game.update = function () { // Game update logic if needed };
===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,333 @@
-/****
+/****
+* Classes
+****/
+var Country = Container.expand(function (countryData) {
+ var self = Container.call(this);
+ self.countryData = countryData;
+ self.isSelected = false;
+ var countryShape = self.attachAsset('country', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ var selectedShape = self.attachAsset('selectedCountry', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ alpha: 0
+ });
+ var countryLabel = new Text2(countryData.name, {
+ size: 24,
+ fill: 0xFFFFFF
+ });
+ countryLabel.anchor.set(0.5, 0.5);
+ countryLabel.y = 10;
+ self.addChild(countryLabel);
+ self.select = function () {
+ self.isSelected = true;
+ selectedShape.alpha = 1;
+ countryShape.alpha = 0;
+ };
+ self.deselect = function () {
+ self.isSelected = false;
+ selectedShape.alpha = 0;
+ countryShape.alpha = 1;
+ };
+ self.down = function (x, y, obj) {
+ if (!self.isSelected) {
+ showCountryInfo(self.countryData);
+ }
+ };
+ return self;
+});
+var InfoPanel = Container.expand(function () {
+ var self = Container.call(this);
+ var panel = self.attachAsset('infoPanel', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.titleText = new Text2('', {
+ size: 60,
+ fill: 0x2C3E50
+ });
+ self.titleText.anchor.set(0.5, 0);
+ self.titleText.y = -350;
+ self.addChild(self.titleText);
+ self.infoTexts = [];
+ for (var i = 0; i < 8; i++) {
+ var infoText = new Text2('', {
+ size: 36,
+ fill: 0x34495E
+ });
+ infoText.anchor.set(0, 0);
+ infoText.x = -850;
+ infoText.y = -250 + i * 70;
+ self.addChild(infoText);
+ self.infoTexts.push(infoText);
+ }
+ var backBtn = self.attachAsset('backButton', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 0,
+ y: 320
+ });
+ var backBtnText = new Text2('Back to Map', {
+ size: 32,
+ fill: 0xFFFFFF
+ });
+ backBtnText.anchor.set(0.5, 0.5);
+ backBtn.addChild(backBtnText);
+ backBtn.down = function (x, y, obj) {
+ hideCountryInfo();
+ };
+ self.updateInfo = function (countryData) {
+ self.titleText.setText(countryData.name);
+ var infoLines = ['🏛️ Capital: ' + countryData.capital, '👥 Population: ' + countryData.population, '💬 Language: ' + countryData.language, '💰 Currency: ' + countryData.currency, '🌍 Continent: ' + countryData.continent, '🏛️ Famous Landmark: ' + countryData.landmark, '🎭 Cultural Fact: ' + countryData.culture, '📚 Fun Fact: ' + countryData.funFact];
+ for (var i = 0; i < self.infoTexts.length; i++) {
+ if (i < infoLines.length) {
+ self.infoTexts[i].setText(infoLines[i]);
+ } else {
+ self.infoTexts[i].setText('');
+ }
+ }
+ };
+ return self;
+});
+var SearchInterface = Container.expand(function () {
+ var self = Container.call(this);
+ var searchBtn = self.attachAsset('searchButton', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ var searchText = new Text2('Search Countries', {
+ size: 36,
+ fill: 0xFFFFFF
+ });
+ searchText.anchor.set(0.5, 0.5);
+ searchBtn.addChild(searchText);
+ self.currentIndex = 0;
+ searchBtn.down = function (x, y, obj) {
+ showRandomCountry();
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x87ceeb
+});
+
+/****
+* Game Code
+****/
+var countries = [{
+ name: 'United States',
+ capital: 'Washington D.C.',
+ population: '331 million',
+ language: 'English',
+ currency: 'US Dollar',
+ continent: 'North America',
+ landmark: 'Statue of Liberty',
+ culture: 'Known for Hollywood and diverse cuisine',
+ funFact: 'Has the world\'s largest economy'
+}, {
+ name: 'France',
+ capital: 'Paris',
+ population: '67 million',
+ language: 'French',
+ currency: 'Euro',
+ continent: 'Europe',
+ landmark: 'Eiffel Tower',
+ culture: 'Famous for cuisine and fashion',
+ funFact: 'Most visited country in the world'
+}, {
+ name: 'Japan',
+ capital: 'Tokyo',
+ population: '125 million',
+ language: 'Japanese',
+ currency: 'Yen',
+ continent: 'Asia',
+ landmark: 'Mount Fuji',
+ culture: 'Known for technology and anime',
+ funFact: 'Has over 6,800 islands'
+}, {
+ name: 'Brazil',
+ capital: 'Brasília',
+ population: '215 million',
+ language: 'Portuguese',
+ currency: 'Real',
+ continent: 'South America',
+ landmark: 'Christ the Redeemer',
+ culture: 'Famous for Carnival and soccer',
+ funFact: 'Contains 60% of Amazon rainforest'
+}, {
+ name: 'Egypt',
+ capital: 'Cairo',
+ population: '104 million',
+ language: 'Arabic',
+ currency: 'Egyptian Pound',
+ continent: 'Africa',
+ landmark: 'Great Pyramid of Giza',
+ culture: 'Ancient civilization and hieroglyphs',
+ funFact: 'Home to one of the Seven Wonders'
+}, {
+ name: 'Australia',
+ capital: 'Canberra',
+ population: '26 million',
+ language: 'English',
+ currency: 'Australian Dollar',
+ continent: 'Oceania',
+ landmark: 'Sydney Opera House',
+ culture: 'Known for unique wildlife',
+ funFact: 'Smallest continent and largest island'
+}, {
+ name: 'India',
+ capital: 'New Delhi',
+ population: '1.4 billion',
+ language: 'Hindi, English',
+ currency: 'Indian Rupee',
+ continent: 'Asia',
+ landmark: 'Taj Mahal',
+ culture: 'Diverse cultures and spices',
+ funFact: 'Most populous country in the world'
+}, {
+ name: 'Canada',
+ capital: 'Ottawa',
+ population: '39 million',
+ language: 'English, French',
+ currency: 'Canadian Dollar',
+ continent: 'North America',
+ landmark: 'Niagara Falls',
+ culture: 'Known for politeness and maple syrup',
+ funFact: 'Second largest country by area'
+}];
+var worldMapContainer = new Container();
+game.addChild(worldMapContainer);
+var mapBackground = LK.getAsset('worldMap', {
+ anchorX: 0.5,
+ anchorY: 0.5
+});
+worldMapContainer.addChild(mapBackground);
+worldMapContainer.x = 2048 / 2;
+worldMapContainer.y = 1366 / 2;
+var countryObjects = [];
+var selectedCountry = null;
+var infoPanel = null;
+var isInfoVisible = false;
+// Position countries on the map
+var countryPositions = [{
+ x: -400,
+ y: -100
+},
+// United States
+{
+ x: 0,
+ y: -200
+},
+// France
+{
+ x: 500,
+ y: -100
+},
+// Japan
+{
+ x: -300,
+ y: 200
+},
+// Brazil
+{
+ x: 200,
+ y: 0
+},
+// Egypt
+{
+ x: 600,
+ y: 300
+},
+// Australia
+{
+ x: 400,
+ y: 0
+},
+// India
+{
+ x: -500,
+ y: -200
+} // Canada
+];
+for (var i = 0; i < countries.length; i++) {
+ var country = new Country(countries[i]);
+ country.x = countryPositions[i].x;
+ country.y = countryPositions[i].y;
+ worldMapContainer.addChild(country);
+ countryObjects.push(country);
+}
+// Create search interface
+var searchInterface = new SearchInterface();
+searchInterface.x = 2048 / 2;
+searchInterface.y = 200;
+game.addChild(searchInterface);
+// Create title
+var titleText = new Text2('Country Explorer Quiz', {
+ size: 72,
+ fill: 0x2C3E50
+});
+titleText.anchor.set(0.5, 0);
+titleText.x = 2048 / 2;
+titleText.y = 50;
+game.addChild(titleText);
+// Create instructions
+var instructionText = new Text2('Tap any country or search to learn more!', {
+ size: 42,
+ fill: 0x34495E
+});
+instructionText.anchor.set(0.5, 0);
+instructionText.x = 2048 / 2;
+instructionText.y = 140;
+game.addChild(instructionText);
+function showCountryInfo(countryData) {
+ if (selectedCountry) {
+ selectedCountry.deselect();
+ }
+ for (var i = 0; i < countryObjects.length; i++) {
+ if (countryObjects[i].countryData.name === countryData.name) {
+ selectedCountry = countryObjects[i];
+ selectedCountry.select();
+ break;
+ }
+ }
+ if (!infoPanel) {
+ infoPanel = new InfoPanel();
+ infoPanel.x = 2048 / 2;
+ infoPanel.y = 1366;
+ game.addChild(infoPanel);
+ }
+ infoPanel.updateInfo(countryData);
+ worldMapContainer.y = -200;
+ titleText.y = -300;
+ instructionText.y = -300;
+ searchInterface.y = -300;
+ infoPanel.y = 1366 / 2;
+ isInfoVisible = true;
+}
+function hideCountryInfo() {
+ if (selectedCountry) {
+ selectedCountry.deselect();
+ selectedCountry = null;
+ }
+ worldMapContainer.y = 1366 / 2;
+ titleText.y = 50;
+ instructionText.y = 140;
+ searchInterface.y = 200;
+ if (infoPanel) {
+ infoPanel.y = 1366 + 400;
+ }
+ isInfoVisible = false;
+}
+function showRandomCountry() {
+ var randomIndex = Math.floor(Math.random() * countries.length);
+ showCountryInfo(countries[randomIndex]);
+}
+game.update = function () {
+ // Game update logic if needed
+};
\ No newline at end of file