• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Zed McJack

How to create and work with not tile based map?

10 posts in this topic

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.
1

Share this post


Link to post
Share on other sites
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.
1

Share this post


Link to post
Share on other sites
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.
2

Share this post


Link to post
Share on other sites
[quote name='makuto' timestamp='1354745689' post='5007542']
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.
[/quote]
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.
0

Share this post


Link to post
Share on other sites
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
0

Share this post


Link to post
Share on other sites
[quote name='Cdrandin' timestamp='1354781472' post='5007674']
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.
[/quote]
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.
0

Share this post


Link to post
Share on other sites
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?)
0

Share this post


Link to post
Share on other sites
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:[list]
[*]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.
[/list]
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.
1

Share this post


Link to post
Share on other sites
[quote name='amrazek111' timestamp='1355323136' post='5009837']
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.
[/quote]

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?

[quote]
This has some advantages:[list]
[*]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.
[/list]
[/quote]

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

[quote][list]
[*]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
[/list]
[/quote]

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.

[quote][list]
[*]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.
[/list]
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.
[/quote]

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.
0

Share this post


Link to post
Share on other sites
FYI, [url="http://gleed2d.codeplex.com/"]gleed2d[/url] 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.

[url="http://stevedunns.blogspot.com/2012/01/announcing-new-version-of-gleed-2d-xna.html"]Here's a newer version of gleed2d[/url], but it seems it's only the source for C#
[url="http://siondream.com/blog/games/gleed2d-level-loading-system-for-libgdx/"]Here's an example[/url] of someone else using gleed2d.

Good Luck!
2

Share this post


Link to post
Share on other sites
[quote name='Zed McJack' timestamp='1355341554' post='5009935']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?[/quote]
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.

[quote]I cant imagine an editor with indenpendetly drawn provinces? How do you control their precise position on map?[/quote]
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.

[quote]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.[/quote]
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.

[quote]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.
[/quote]
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.
1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0