Jump to content

  • Log In with Google      Sign In   
  • Create Account


How to create and work with not tile based map?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
10 replies to this topic

#1 Zed McJack   Members   -  Reputation: 349

Like
1Likes
Like

Posted 14 November 2012 - 01:23 PM

Ok, I know its early to think about creating map while I am still cleaning code for MyPong, but the idea for a strategic game like Paradox's Europa Universalis or Crusader King is haunting me.

Anyway, from what I was researching their huge map is just bmp file. The provinces are painted with different RGB color which gives them number of 16,777,216 possible provinces. Thats way to much for my need, but its good to know how it works. The other files establish the ID of the province and coresponding provincial atributes.
There are of course tons of missing information here but I could not find more info on this type of mapping which for me is not tile based though I might be wrong.

If someone could give me links of their thoughts on this I would appreciate it.

Sponsor:

#2 makuto   Members   -  Reputation: 833

Like
1Likes
Like

Posted 05 December 2012 - 04:14 PM

I'm not sure if I understand your question. If you can, post the "huge map". That will make it a lot easier to see what you are wondering about.

Want to get to know my work and I better? See my website: Au 79 Games

I wrote General Tips on the Process of Solo Game Development


#3 sox   Crossbones+   -  Reputation: 484

Like
2Likes
Like

Posted 05 December 2012 - 04:55 PM

I built an image-based map system like this back in the stone ages (256 colors, DOS). The advantage of such a system is the conceptual simplicity of it... you're basically building a 2D lookup table that relates screen pixels to province data.

There are several disadvantages, however:
1) An errant photoshop filter or export tool could subtly alter your color data, thus corrupting your province lookups
2) You double the space required for every map
3) You have to avoid lossy image formats

The alternative is to use a triangle meshes. It will be a bit more complex to pick provinces based on point-in-triangle tests, but they will take a ton less space and will give you more flexibility.

In the end, either system should do the job, so use whatever you're comfortable with.

#4 Zed McJack   Members   -  Reputation: 349

Like
0Likes
Like

Posted 06 December 2012 - 01:36 AM

I'm not sure if I understand your question. If you can, post the "huge map". That will make it a lot easier to see what you are wondering about.

Below is the screenshot of zoomed in map from EU3 game. This filter is political so it shows you countries. There are dozen filters that paint the map differently depending on what you want to see. For example Terrain map, Rebel risk map, Holy roman empire map, Economy map etc.
The basis of this shown map is a BMP file of 38MB, with resolution 5616x2160 where the individual provinces are painted with different RGB color.
As you could see from the pic the borders are irregular and province can have any number of bordering provinces from 1(island) to 7-8 I never actually counted what is maximum. I dont see this as tile based map, but you can prove me wrong.
In tile based map you have screen (rectangle) divided in rows and columns. Each tile is a position on map. So you store tiled based map in an array and its easy to tell what (game) object is at what position and where it is heading.
With eu3 map this is not the case.

Attached Thumbnails

  • EU3map.jpg


#5 Cdrandin   Members   -  Reputation: 443

Like
0Likes
Like

Posted 06 December 2012 - 02:11 AM

Aren't pixels essentially very tiny "tiles". Looks to me those irregular lines are just tiled in probably, but could be yet very inefficient. My guess, check collision in between these countries, at the point of collision place a tile and I guess do it for all edges then have it anti-aliased to make it look smoother and there is your outline i guess. I wouldn't know, but would be interested as to how to get that feature working.

Edited by Cdrandin, 06 December 2012 - 02:11 AM.


#6 Zed McJack   Members   -  Reputation: 349

Like
0Likes
Like

Posted 06 December 2012 - 02:29 AM

Aren't pixels essentially very tiny "tiles". Looks to me those irregular lines are just tiled in probably, but could be yet very inefficient. My guess, check collision in between these countries, at the point of collision place a tile and I guess do it for all edges then have it anti-aliased to make it look smoother and there is your outline i guess. I wouldn't know, but would be interested as to how to get that feature working.

Well, in this game the problem is not in checking collisions because there are not too many objects moving around. When enemy armies are in the same province the battle commence and that is all. Much of it is just abstracted, there are no bullets flying, just my attributes vs your attributes + - some other modifiers and die roll.
The map is static, meaning the shapes of provinces are fixed in that big file (I havent supplied yet (but I can if you insist)), so if province change hands just different color is applied, there are no collisions to check.

The armies are not moving, you issue an movement order, the path is calculated and an arrow is drawn that is being filled up. When arrow fills, the movement of armies occur and the engine draws the army sprite in the other province, and redraws the arrow if army is moving even further or erases the arrow if that province was final destination.

#7 Zed McJack   Members   -  Reputation: 349

Like
0Likes
Like

Posted 12 December 2012 - 03:02 AM

Ok, Ive researched this a bit further.
The map is actually tiled based, but not in simple way.
The position of the mouse click (X,Y) is used to find out what province is being clicked at in the following way.
There used to be a file made of two parts of information.
First part stored y values and pointer to the second part where there was block of information containing following pairs starting pixel, province id, ending pixel.

So it was actually look-up table where you would first search your Y value and then jump to block that represent the X row. And than scan till you find your X pixels value and coresponding province id.

That was in EU2 when they used 2D graphics, from EU3 they switched to 3D, but as I am planing to use 2D in my game it is good to know how they did it.

This was just a simple hit test. But bigger problem was painting the map according to the applied filter. Its much more complicated and I dont really understand how they do that. They used quad tree, but its still mystery to me.
If someone has some good reading please post links or write here.
(I regret that I tagged topic with python cause I probably missed someone who has experience with this from other languages. Can moderator fix that?)

#8 amrazek111   Members   -  Reputation: 692

Like
1Likes
Like

Posted 12 December 2012 - 08:38 AM

Why not define provinces in terms of polygons? Sort the polygons spatially in some way and then a point-in-polygon test to determine exact polygon that's been selected. This has some advantages:
  • Your artist could create any kind of map with any kinds of colors and details on it. An editor could be used to draw out the borders of the provinces. No requirements would be placed on the map, so your artist could add trees and other fine details without issue. This also means you could release the editor to your players and have them create their own maps easily if they wanted.
  • You could easily determine which provinces are attackable from a given province based on which edges are shared. This would additionally make it easy to draw those attacker arrows, since you would have well-defined edges and could select the most visually appropriate one pretty easily
  • Territories can be any shape (as long as the polygon isn't complex) and border any number of provinces (or none--say, an island)
  • Those overlays based on territory, economy or what have you would be really easy to implement. Just overlay a translucent filled polygon on each territory. You could also use the province's polygon to clip drawing on that province -- say, if you wanted to draw a texture on it.
Boost has a really nifty Polygon library for C++ that would make this a snap. I'm sure Python has something similar you could use.

#9 Zed McJack   Members   -  Reputation: 349

Like
0Likes
Like

Posted 12 December 2012 - 01:45 PM

Why not define provinces in terms of polygons? Sort the polygons spatially in some way and then a point-in-polygon test to determine exact polygon that's been selected.


Uh, I am note sure what you mean with "Sort the polygons spatially in some way"? You mean drawing polygons one by one? This might be what they do cause there is a file that represents rectangles that define extreme borders of the province in question (left, top, bottom, right). In this way they know where to draw the province although I have not seen single province images. They might acquire them from the big map or somehow?

This has some advantages:

  • Your artist could create any kind of map with any kinds of colors and details on it. An editor could be used to draw out the borders of the provinces. No requirements would be placed on the map, so your artist could add trees and other fine details without issue. This also means you could release the editor to your players and have them create their own maps easily if they wanted.


I cant imagine an editor with indenpendetly drawn provinces? How do you control their precise position on map?

  • You could easily determine which provinces are attackable from a given province based on which edges are shared. This would additionally make it easy to draw those attacker arrows, since you would have well-defined edges and could select the most visually appropriate one pretty easily


All adjacent provinces are kept in a file similar to the one I described for hit testing. There is a province Id, followed by ids of adjacent provinces so its easy to know where you can go.

  • Territories can be any shape (as long as the polygon isn't complex) and border any number of provinces (or none--say, an island)
  • Those overlays based on territory, economy or what have you would be really easy to implement. Just overlay a translucent filled polygon on each territory. You could also use the province's polygon to clip drawing on that province -- say, if you wanted to draw a texture on it.
Boost has a really nifty Polygon library for C++ that would make this a snap. I'm sure Python has something similar you could use.


I am not sure if Python has such library, I am even not sure can it be done in Python? But I need some more info about substance of working with maps like this one.

#10 BeerNutts   Crossbones+   -  Reputation: 2779

Like
2Likes
Like

Posted 12 December 2012 - 02:04 PM

FYI, gleed2d provides a method of creating levels without tiles, and just applying images directly onto a map at any location. it stores the data in xml, so I assume python has an xml parser you can use to read the data out.

Here's a newer version of gleed2d, but it seems it's only the source for C#
Here's an example of someone else using gleed2d.

Good Luck!
My Gamedev Journal: 2D Game Making, the Easy Way

---(Old Blog, still has good info): 2dGameMaking
-----
"No one ever posts on that message board; it's too crowded." - Yoga Berra (sorta)

#11 amrazek111   Members   -  Reputation: 692

Like
1Likes
Like

Posted 12 December 2012 - 03:31 PM

Uh, I am note sure what you mean with "Sort the polygons spatially in some way"? You mean drawing polygons one by one? This might be what they do cause there is a file that represents rectangles that define extreme borders of the province in question (left, top, bottom, right). In this way they know where to draw the province although I have not seen single province images. They might acquire them from the big map or somehow?

It's a matter of performance. You don't want to try to draw every province, army, arrow, etc every frame. Instead, you want to draw what the user can see. You're already on the right track: calculate axis-aligned bounding boxes and then sort them with some simple algorithm. Then, you can query your sorted bounding boxes to see which polygons lie in an area. You'll end up using this for a lot of things: for instance, in addition to rendering you could also use it to narrow down possibilities for which province was clicked, or have the AI use it to determine how many hostile armies are within range of a given province, and so on.

A really simple way to do this might be a balanced binary search tree sorted by the x or y axis. There are lots of tree variants though. Search "spatial partitioning" for more ideas.

I cant imagine an editor with indenpendetly drawn provinces? How do you control their precise position on map?

You use your editor* (that you'll write to work with the game) to place provinces wherever you want. You would have two files: 1 is the map, which could be just a simple BMP. The second would define vertices that make up the provinces and possibly contain any particular details (for instance, starting points or region wealth or city locations, whatever features your game has) that can be changed via the editor.

* I've never used gleed2d so I don't know if it'll do what you want or not, but if it does that could save you a considerable amount of time.

All adjacent provinces are kept in a file similar to the one I described for hit testing. There is a province Id, followed by ids of adjacent provinces so its easy to know where you can go.

That works. You could have the editor define that for you, or have the game engine figure it out while loading the map to make things a little more automatic. Either way.

I am not sure if Python has such library, I am even not sure can it be done in Python? But I need some more info about substance of working with maps like this one.

You could probably come up with your own solution pretty easily. I was getting ahead of myself and thinking about the editor automatically filing in oceans and unused areas, or randomly generating a set of provinces on any given map. A way to define polygons and a function to check if a point is inside any given polygon is really all you need or want at this point.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS