View Full Version : How to change an image?
I want to use the map below (perhaps not the exact image but a similar one) for I game I am working on. Basically I want the individual "countries" to be able to change color when the nation changes hands. What would be the best way to go about doing this? Thanks!
http://www.narcity.com/0000game/FirstUsedMap.gif
ACJavascript
12-27-2002, 01:07 AM
You cannot change a Full Image like that... What you could do is,, take that image,, Fill one of the countries red or somthing,, then save it as country1,, then go back to the original and color in another counntry and call that 2. . ect... ect...
Then when you change countrys just call up the image that suites the country... :D
Mabye not the best way to do it but it should work hehe :D
duniyadnd
12-27-2002, 11:23 AM
If you're proficient with a program like photoshop that have the slicing feature, you can fill can create different colors for all the countries (though this is a big hassle for the number of countries you have).
Then for the countries, you can store them as an array, say there is "n" countries.
Once that's taken place, fill the array with the integer corresponding with the color.
eg. with n countries = 10 (0-9)
alliances (a) = 3 (0-2)
each country has a certain alliance:
array could be like so:
[0 1 2 2 2 2 1 0 0 0 0]
with each position in the array dealing with a constant country.
You would go through the images (ie. probably lable each section as r_country1.jpg (for red) b_country1.jpg (for blue) etc. and have a search script to look for the best image that satisfies the array, something like a true and false game)
for (var i = 0; i < n.length; i++)
{
if (array[i] = 0)
{
image[i] = r_country[i].jpg
}
if (array[i] = 1)
{
image[i] = r_country[i].jpg
}
etc...
}
However, this creates a problem for us: as the way the countries are set up, there will be some overlapping sections for the images (ie. that country A is red, and country B is blue, but at one point, country B is green, and might change to blue and change A to green by mistake as that is the first color it catches). So you have to be aware of the countries around the one that is being changed as well.
Possibly try to restrict the surrounding of the country to a maximum of two other countries (search one above the array, and one below and fix those as well, and keep spreading in that manner).
The best way is to set up a symmetrical image of the countries and use that.
Duniyadnd
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.