/**** * 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' }, { name: 'Germany', capital: 'Berlin', population: '83 million', language: 'German', currency: 'Euro', continent: 'Europe', landmark: 'Brandenburg Gate', culture: 'Known for engineering and Oktoberfest', funFact: 'Has over 1,500 breweries' }, { name: 'China', capital: 'Beijing', population: '1.4 billion', language: 'Mandarin', currency: 'Yuan', continent: 'Asia', landmark: 'Great Wall of China', culture: 'Ancient culture with modern technology', funFact: 'Most populated country in the world' }, { name: 'United Kingdom', capital: 'London', population: '67 million', language: 'English', currency: 'Pound Sterling', continent: 'Europe', landmark: 'Big Ben', culture: 'Known for tea and royal family', funFact: 'Birthplace of Shakespeare' }, { name: 'Italy', capital: 'Rome', population: '60 million', language: 'Italian', currency: 'Euro', continent: 'Europe', landmark: 'Colosseum', culture: 'Famous for art, history and cuisine', funFact: 'Has more UNESCO sites than any country' }, { name: 'Spain', capital: 'Madrid', population: '47 million', language: 'Spanish', currency: 'Euro', continent: 'Europe', landmark: 'Sagrada Familia', culture: 'Known for flamenco and paella', funFact: 'Second most spoken language globally' }, { name: 'Russia', capital: 'Moscow', population: '146 million', language: 'Russian', currency: 'Ruble', continent: 'Europe/Asia', landmark: 'Red Square', culture: 'Rich literature and ballet tradition', funFact: 'Largest country by land area' }, { name: 'Mexico', capital: 'Mexico City', population: '128 million', language: 'Spanish', currency: 'Peso', continent: 'North America', landmark: 'Chichen Itza', culture: 'Ancient Mayan and Aztec heritage', funFact: 'Birthplace of chocolate and tomatoes' }, { name: 'Argentina', capital: 'Buenos Aires', population: '45 million', language: 'Spanish', currency: 'Peso', continent: 'South America', landmark: 'Iguazu Falls', culture: 'Famous for tango and beef', funFact: 'Has won FIFA World Cup 3 times' }, { name: 'South Africa', capital: 'Cape Town', population: '60 million', language: 'Multiple (11 official)', currency: 'Rand', continent: 'Africa', landmark: 'Table Mountain', culture: 'Rainbow nation with diverse cultures', funFact: 'Has 3 capital cities' }, { name: 'Turkey', capital: 'Ankara', population: '84 million', language: 'Turkish', currency: 'Lira', continent: 'Europe/Asia', landmark: 'Hagia Sophia', culture: 'Bridge between Europe and Asia', funFact: 'Invented Turkish coffee and delight' }, { name: 'Thailand', capital: 'Bangkok', population: '70 million', language: 'Thai', currency: 'Baht', continent: 'Asia', landmark: 'Grand Palace', culture: 'Known for Buddhist temples and cuisine', funFact: 'Never been colonized by Europeans' }, { name: 'Greece', capital: 'Athens', population: '11 million', language: 'Greek', currency: 'Euro', continent: 'Europe', landmark: 'Parthenon', culture: 'Birthplace of democracy and Olympics', funFact: 'Has over 6,000 islands' }, { name: 'Netherlands', capital: 'Amsterdam', population: '17 million', language: 'Dutch', currency: 'Euro', continent: 'Europe', landmark: 'Windmills of Kinderdijk', culture: 'Known for tulips and cycling', funFact: 'One third of country is below sea level' }, { name: 'Norway', capital: 'Oslo', population: '5 million', language: 'Norwegian', currency: 'Krone', continent: 'Europe', landmark: 'Northern Lights', culture: 'Viking heritage and fjords', funFact: 'One of the happiest countries' }, { name: 'Sweden', capital: 'Stockholm', population: '10 million', language: 'Swedish', currency: 'Krona', continent: 'Europe', landmark: 'Vasa Museum', culture: 'Known for IKEA and ABBA', funFact: 'Birthplace of Nobel Prize' }, { name: 'South Korea', capital: 'Seoul', population: '52 million', language: 'Korean', currency: 'Won', continent: 'Asia', landmark: 'Gyeongbokgung Palace', culture: 'Known for K-pop and technology', funFact: 'Fastest internet in the world' }, { name: 'Indonesia', capital: 'Jakarta', population: '274 million', language: 'Indonesian', currency: 'Rupiah', continent: 'Asia', landmark: 'Borobudur Temple', culture: 'Diverse archipelago nation', funFact: 'Has over 17,000 islands' }, { name: 'Nigeria', capital: 'Abuja', population: '218 million', language: 'English', currency: 'Naira', continent: 'Africa', landmark: 'Zuma Rock', culture: 'Nollywood film industry', funFact: 'Most populous African country' }, { name: 'Iran', capital: 'Tehran', population: '85 million', language: 'Persian', currency: 'Rial', continent: 'Asia', landmark: 'Persepolis', culture: 'Ancient Persian civilization', funFact: 'Invented ice cream and windmills' }, { name: 'Poland', capital: 'Warsaw', population: '38 million', language: 'Polish', currency: 'Zloty', continent: 'Europe', landmark: 'Wawel Castle', culture: 'Rich history and Chopin heritage', funFact: 'Marie Curie was Polish' }, { name: 'Chile', capital: 'Santiago', population: '19 million', language: 'Spanish', currency: 'Peso', continent: 'South America', landmark: 'Easter Island', culture: 'Known for wine and poets', funFact: 'Longest and narrowest country' }, { name: 'Morocco', capital: 'Rabat', population: '37 million', language: 'Arabic, Berber', currency: 'Dirham', continent: 'Africa', landmark: 'Hassan II Mosque', culture: 'Gateway between Africa and Europe', funFact: 'Famous for colorful markets' }]; 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 in a grid layout var countriesPerRow = 6; var countrySpacingX = 280; var countrySpacingY = 140; var startX = -700; var startY = -400; for (var i = 0; i < countries.length; i++) { var country = new Country(countries[i]); var row = Math.floor(i / countriesPerRow); var col = i % countriesPerRow; country.x = startX + col * countrySpacingX; country.y = startY + row * countrySpacingY; 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
@@ -199,8 +199,228 @@
continent: 'North America',
landmark: 'Niagara Falls',
culture: 'Known for politeness and maple syrup',
funFact: 'Second largest country by area'
+}, {
+ name: 'Germany',
+ capital: 'Berlin',
+ population: '83 million',
+ language: 'German',
+ currency: 'Euro',
+ continent: 'Europe',
+ landmark: 'Brandenburg Gate',
+ culture: 'Known for engineering and Oktoberfest',
+ funFact: 'Has over 1,500 breweries'
+}, {
+ name: 'China',
+ capital: 'Beijing',
+ population: '1.4 billion',
+ language: 'Mandarin',
+ currency: 'Yuan',
+ continent: 'Asia',
+ landmark: 'Great Wall of China',
+ culture: 'Ancient culture with modern technology',
+ funFact: 'Most populated country in the world'
+}, {
+ name: 'United Kingdom',
+ capital: 'London',
+ population: '67 million',
+ language: 'English',
+ currency: 'Pound Sterling',
+ continent: 'Europe',
+ landmark: 'Big Ben',
+ culture: 'Known for tea and royal family',
+ funFact: 'Birthplace of Shakespeare'
+}, {
+ name: 'Italy',
+ capital: 'Rome',
+ population: '60 million',
+ language: 'Italian',
+ currency: 'Euro',
+ continent: 'Europe',
+ landmark: 'Colosseum',
+ culture: 'Famous for art, history and cuisine',
+ funFact: 'Has more UNESCO sites than any country'
+}, {
+ name: 'Spain',
+ capital: 'Madrid',
+ population: '47 million',
+ language: 'Spanish',
+ currency: 'Euro',
+ continent: 'Europe',
+ landmark: 'Sagrada Familia',
+ culture: 'Known for flamenco and paella',
+ funFact: 'Second most spoken language globally'
+}, {
+ name: 'Russia',
+ capital: 'Moscow',
+ population: '146 million',
+ language: 'Russian',
+ currency: 'Ruble',
+ continent: 'Europe/Asia',
+ landmark: 'Red Square',
+ culture: 'Rich literature and ballet tradition',
+ funFact: 'Largest country by land area'
+}, {
+ name: 'Mexico',
+ capital: 'Mexico City',
+ population: '128 million',
+ language: 'Spanish',
+ currency: 'Peso',
+ continent: 'North America',
+ landmark: 'Chichen Itza',
+ culture: 'Ancient Mayan and Aztec heritage',
+ funFact: 'Birthplace of chocolate and tomatoes'
+}, {
+ name: 'Argentina',
+ capital: 'Buenos Aires',
+ population: '45 million',
+ language: 'Spanish',
+ currency: 'Peso',
+ continent: 'South America',
+ landmark: 'Iguazu Falls',
+ culture: 'Famous for tango and beef',
+ funFact: 'Has won FIFA World Cup 3 times'
+}, {
+ name: 'South Africa',
+ capital: 'Cape Town',
+ population: '60 million',
+ language: 'Multiple (11 official)',
+ currency: 'Rand',
+ continent: 'Africa',
+ landmark: 'Table Mountain',
+ culture: 'Rainbow nation with diverse cultures',
+ funFact: 'Has 3 capital cities'
+}, {
+ name: 'Turkey',
+ capital: 'Ankara',
+ population: '84 million',
+ language: 'Turkish',
+ currency: 'Lira',
+ continent: 'Europe/Asia',
+ landmark: 'Hagia Sophia',
+ culture: 'Bridge between Europe and Asia',
+ funFact: 'Invented Turkish coffee and delight'
+}, {
+ name: 'Thailand',
+ capital: 'Bangkok',
+ population: '70 million',
+ language: 'Thai',
+ currency: 'Baht',
+ continent: 'Asia',
+ landmark: 'Grand Palace',
+ culture: 'Known for Buddhist temples and cuisine',
+ funFact: 'Never been colonized by Europeans'
+}, {
+ name: 'Greece',
+ capital: 'Athens',
+ population: '11 million',
+ language: 'Greek',
+ currency: 'Euro',
+ continent: 'Europe',
+ landmark: 'Parthenon',
+ culture: 'Birthplace of democracy and Olympics',
+ funFact: 'Has over 6,000 islands'
+}, {
+ name: 'Netherlands',
+ capital: 'Amsterdam',
+ population: '17 million',
+ language: 'Dutch',
+ currency: 'Euro',
+ continent: 'Europe',
+ landmark: 'Windmills of Kinderdijk',
+ culture: 'Known for tulips and cycling',
+ funFact: 'One third of country is below sea level'
+}, {
+ name: 'Norway',
+ capital: 'Oslo',
+ population: '5 million',
+ language: 'Norwegian',
+ currency: 'Krone',
+ continent: 'Europe',
+ landmark: 'Northern Lights',
+ culture: 'Viking heritage and fjords',
+ funFact: 'One of the happiest countries'
+}, {
+ name: 'Sweden',
+ capital: 'Stockholm',
+ population: '10 million',
+ language: 'Swedish',
+ currency: 'Krona',
+ continent: 'Europe',
+ landmark: 'Vasa Museum',
+ culture: 'Known for IKEA and ABBA',
+ funFact: 'Birthplace of Nobel Prize'
+}, {
+ name: 'South Korea',
+ capital: 'Seoul',
+ population: '52 million',
+ language: 'Korean',
+ currency: 'Won',
+ continent: 'Asia',
+ landmark: 'Gyeongbokgung Palace',
+ culture: 'Known for K-pop and technology',
+ funFact: 'Fastest internet in the world'
+}, {
+ name: 'Indonesia',
+ capital: 'Jakarta',
+ population: '274 million',
+ language: 'Indonesian',
+ currency: 'Rupiah',
+ continent: 'Asia',
+ landmark: 'Borobudur Temple',
+ culture: 'Diverse archipelago nation',
+ funFact: 'Has over 17,000 islands'
+}, {
+ name: 'Nigeria',
+ capital: 'Abuja',
+ population: '218 million',
+ language: 'English',
+ currency: 'Naira',
+ continent: 'Africa',
+ landmark: 'Zuma Rock',
+ culture: 'Nollywood film industry',
+ funFact: 'Most populous African country'
+}, {
+ name: 'Iran',
+ capital: 'Tehran',
+ population: '85 million',
+ language: 'Persian',
+ currency: 'Rial',
+ continent: 'Asia',
+ landmark: 'Persepolis',
+ culture: 'Ancient Persian civilization',
+ funFact: 'Invented ice cream and windmills'
+}, {
+ name: 'Poland',
+ capital: 'Warsaw',
+ population: '38 million',
+ language: 'Polish',
+ currency: 'Zloty',
+ continent: 'Europe',
+ landmark: 'Wawel Castle',
+ culture: 'Rich history and Chopin heritage',
+ funFact: 'Marie Curie was Polish'
+}, {
+ name: 'Chile',
+ capital: 'Santiago',
+ population: '19 million',
+ language: 'Spanish',
+ currency: 'Peso',
+ continent: 'South America',
+ landmark: 'Easter Island',
+ culture: 'Known for wine and poets',
+ funFact: 'Longest and narrowest country'
+}, {
+ name: 'Morocco',
+ capital: 'Rabat',
+ population: '37 million',
+ language: 'Arabic, Berber',
+ currency: 'Dirham',
+ continent: 'Africa',
+ landmark: 'Hassan II Mosque',
+ culture: 'Gateway between Africa and Europe',
+ funFact: 'Famous for colorful markets'
}];
var worldMapContainer = new Container();
game.addChild(worldMapContainer);
var mapBackground = LK.getAsset('worldMap', {
@@ -213,53 +433,20 @@
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
-];
+// Position countries on the map in a grid layout
+var countriesPerRow = 6;
+var countrySpacingX = 280;
+var countrySpacingY = 140;
+var startX = -700;
+var startY = -400;
for (var i = 0; i < countries.length; i++) {
var country = new Country(countries[i]);
- country.x = countryPositions[i].x;
- country.y = countryPositions[i].y;
+ var row = Math.floor(i / countriesPerRow);
+ var col = i % countriesPerRow;
+ country.x = startX + col * countrySpacingX;
+ country.y = startY + row * countrySpacingY;
worldMapContainer.addChild(country);
countryObjects.push(country);
}
// Create search interface