Results 1 to 8 of 8
  1. #1
    Join Date
    Feb 2004
    Location
    The Village
    Posts
    364

    RISK type game - how to draw the map of europe.

    Hey Folks,

    Well I've been away a long, long time. A lot of personal stuff happened to me in the past few years (like emigrating to New Zealand for one)......and I lost the path. Anyway, I'm back onto it and I want to pickup where i left off.

    I've re-watched the C++ vtms that I had when I got the C++ DVD and I've created my own evil monkeys game, i.e. the console one. Very cool.

    Before I continue I wanted to try to do a simple game myself....basically I want to do a risk type game. Whilst I have a good idea on how to do all of the different classes/objects that I'll need (regions, armies, etc)....one part that I'm struggling with is how to draw a realistic looking map of europe. I wanted the map to be divided up into the RISK regions (loosely based on it) and for the region to change colour when a player captured it etc.

    Right now I'm only up to the console evil monkeys game so right now I'm thinking solely on a console display. Any ideas on how to do that? Or would it be alot easier doing it via WxWidgets or even OpenGL?

    Should i just concentrate on getting the game mechanics working first and do the map later when I've covered the WxWidgets VTMs?

    Many thanks in advance.
    "I will not be pushed, filed, stamped, indexed, briefed, de-briefed nor numbered!" :- No. 6.

  2. #2
    Join Date
    Mar 2005
    Posts
    934
    You can use a game library like sdl or allegro that comes with functions for drawing, loading, and manipulating images. Both are directly accessible from C++, and they also have wrappers for other languages like python.

    http://www.libsdl.org/
    http://alleg.sourceforge.net/

    Edit:
    Most people would not draw the map in the game. It is better to create a map in Photoshop, Illustrator, GIMP or Inkscape and load it into the game. You can save memory by using small overlays of each country in the different colors that you want to use. And since your country images would be rectangular, you would use a transparency color outside of the borders of the country so that only you would not affect the color of the surrounding countries.
    Last edited by pellea72; 07-01-2013 at 09:03 PM.
    "I don't WANT to pet the chicken."

  3. #3
    Join Date
    Jun 2003
    Location
    Trier, Germany
    Posts
    1,350
    OpenGL might be too big a leap if you have only done the EvilMonkeys console game before.

    SDL is a reasonable choice, especially with the 2.0 release around the corner. However, SDL is still comparably technical and might not be the best for 'getting things done'. I love to SDL's capabilities as a windowing toolkit for OpenGL, but for plain 2d graphics, there are better choices. Allegro is one of them.

    If you like new and shiny things, you might want to use SFML. It offers a similar featureset like Allegro, but is (imho) more beginner-friendly and also seems to be more popular at this point in time (which is of course just my personal impression and impossible to back up with hard data). Also: Allegro and SDL are C libraries while SFML is C++. This can be an advantage or a disadvantage, depending on where you stand and what you are trying to achieve.

    If you find all of those to be too technical and too distracting for what you are trying to achieve, check out LÖVE. It uses Lua as a programming language (which is imho a very useful language to know as a C++ programmer) and is one of the most beginner friendly, yet very powerful toolkit for building 2d games. The downside here is of course that you would have to learn another language, so you will have to decide for yourself whether that's the right thing to do right now. This could be an advantage if you find yourself struggling with the technicalities of C++ a lot. Lua is orders of magnitude easier to learn and use than C++ while still offering very powerful modern language features.

  4. #4
    Join Date
    Mar 2005
    Posts
    934
    I'm going to have to check out SFML and LÖVE. I'm familiar with the older Allegro code base. But since the 5.0 branch is essentially a new library, I may as well see what else is out there.
    "I don't WANT to pet the chicken."

  5. #5
    Join Date
    Feb 2004
    Location
    The Village
    Posts
    364
    Cool, thanks guys. I think I'm going to first concentrate on getting the game classes and mechanisms all setup first. Once i'm going with that then I'll come back to the draw engine part but sfml looks really cool. Many thanks....I'll probably be back with more questions before i even get to the "draw map" stage.
    "I will not be pushed, filed, stamped, indexed, briefed, de-briefed nor numbered!" :- No. 6.

  6. #6
    Join Date
    Mar 2005
    Posts
    934
    starkhorn, keep us posted on your progress. It sounds like a game I might like to play. I used to play Axis and Allies all the time.
    "I don't WANT to pet the chicken."

  7. #7
    Join Date
    Feb 2004
    Location
    The Village
    Posts
    364
    Quote Originally Posted by pellea72 View Post

    Edit:
    Most people would not draw the map in the game. It is better to create a map in Photoshop, Illustrator, GIMP or Inkscape and load it into the game. You can save memory by using small overlays of each country in the different colors that you want to use. And since your country images would be rectangular, you would use a transparency color outside of the borders of the country so that only you would not affect the color of the surrounding countries.
    Hi pellea72,

    So I'm testing with sfml and drawing 2D image files with GIMP. I've gotten a png for each region that I want to display.....so now I'm trying to figure out how to display them all in the correct places, so they look like a real map of europe.

    My thinking here was to use a tile map system which would be configured via a text file., i.e. each image = a rectangle with no background colour outside of the borders of each region. Tile-map and image file dimensions are equal in width/length.

    So text file would have something like:

    x,x,x,1
    x,x,2,x

    etc

    the number would be the region id (each region has the image file as a field). Then I would draw the image file at the location of the tilemap.

    My concern is how to align up each image so that they fit nicely, i.e. say for the spain/portugal region, my txt file would be as below. 1 = North Spain, 2 = portugal, 3 - south Spain.

    x,1
    2,3

    The N Spain (region 1) image file contains the part of the region that should cover the top of Portugal. But if I program something like above then how can I avoid portugal "sticking out" by 100 pixels to the left of N Spain?

    Hmm -sorry not sure if I've explained that well. When I got home from work I will post images.
    "I will not be pushed, filed, stamped, indexed, briefed, de-briefed nor numbered!" :- No. 6.

  8. #8
    Join Date
    Feb 2004
    Location
    The Village
    Posts
    364
    Ok so here are my images. As you can see, my North Spain region covers the top of Portugal/West Spain

    Here is North Spain

    Click image for larger version. 

Name:	nSpain.png 
Views:	108 
Size:	1.5 KB 
ID:	73838

    Here is Portugal/West Spain

    Click image for larger version. 

Name:	wSpain.png 
Views:	110 
Size:	1.2 KB 
ID:	73839

    Here is South Spain

    Click image for larger version. 

Name:	sSpain.png 
Views:	107 
Size:	1.1 KB 
ID:	73840


    and this is obviously how they should look

    Click image for larger version. 

Name:	hispania.png 
Views:	120 
Size:	2.0 KB 
ID:	73841
    Last edited by starkhorn; 08-22-2013 at 03:43 PM.
    "I will not be pushed, filed, stamped, indexed, briefed, de-briefed nor numbered!" :- No. 6.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •