Web Programming Question

Narz

keeping it real
Joined
Jun 1, 2002
Messages
31,514
Location
Haverhill, UK
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! :thumbsup:

FirstUsedMap.gif


- Narz :king:
 
That all depends on what you want to use to make the game. What language are you using?
 
Non-language specific answer: One way is for the game to poll all the lands after each battle and determine which country owns it at that time. Once it determines which country the game should check what color that is and then if it changed from last time it should update the color.
There might be a more elegant way than this but this will work. :)

After re-reading the thread title I would guess this would be a very inelegant way to handle it for a webbrowser.....but still doable.
 
Using an object-oriented approach would be your best bet. Javascript would be great for a web page. you would have something similair to the following:

******************************
Object country {

string owner;

Void public set_owner(string newOwner) {
owner = newOwner;
}

String public get_owner() {
return owner;
}
}
*****************************

ANd the code would look as the following:

*****************************
new country state1;
state1.set_owner("America");
print(state1.get_owner());
state1.set_owner("England");
print(state1.get_owner());

*******************************

And the output would look like:

*******************************

America
England

*******************************

Hope that helps, if you need, I can try to explain it differently
 
Note, my above code is not a real programming language, It is only to show a general structure of what the actual language would look like.
 
I'm assuming from the title you want to this to be game to be played on the web, via a web browser.

This is a little tricky but I'd probably use images (for each country) and absolutely position them (CSS-P) on the screen. As countries(images) change hands I would dynamically assign a new CSS class to the image so that it's border changes color.

To sum up:
You would have one image for each country
You would use dhtml/css to absolutely position them close together.
You would have one CSS class for each country. That class would be dynamically re-assigned to an image each time a country changes hands.

Or you could take an entirely different approach and build the game as a java application, and try to render it through an applet. That approach would give you more flexibility in terms of rendering complex shapes on a web browser.
 
Back
Top Bottom