The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates.

godotengine.org | Twitter

+1 vote

Godot 3.3
Game Type: 2D
For OS: Windows

Hello I am creating a Grand Strategy Game similar to Risk, Civ V, Hearts of Iron and others. I am using an image with each territory/region represented as a different single color. The problem is, I do not know how to make each territory/region selectable (clickable) and change that selection to white (or whatever color). Also I am wanting all the territories to be green (or whatever color) when the game first starts and the users sees it, as well as having each territory/region having a black outline
I have included an image that has 4 map images on it (ignore the white color that is just to help show separation in the map images). Hopefully this helps some.

enter image description here

Images
#1. Base map image, each single color represents a single territory/region. User never sees this base map,
#2. The map the actual user will see (notice that each territory/region has a black border around it). Also no one owns (conquered) any territories/regions yet.
#3. A territory/region a user clicks on (selects( The selection is gray. Also no one still owns (conquered) any territories/regions yet.
#4. Some territories/regions are now owned (conquered) now by the Red, Blue, and Light-Green armies. The user is also selecting a territory/region as indicated by the gray color selection.

The territories/regions colors and the owners are store in 2 separate json files

territories.json
[
{
"id" : 1,
"color" : [0, 100, 100],
"owner" : 2
},
{
"id" : 2,
"color" : [255, 76, 63],
"owner" : 1
},
....
]

owners.json
[
{
"id" : 0,
"color" : 19, 116, 146]
},
{
"id" : 1,
"color" : [0, 0, 255]
},
....
]

All the territories are dark green with a black border around them at run-time, their actual single colors comes from the territories json file and which the user never sees it as depicted in Image #1,the dark green color as depicted in Image #2 comes from the owners json file with the ID of 0 indicating no owner, .So when a user clicks an area it turns gray as depicted in Images #3 and #4 to show that it is selected, once it is owned (conquered) depicted in Image #4 it's color changes to reflect the owner who's color comes from the owners.json file . This is what I don't know how yo accomplish and need help with, please??

in Engine by (47 points)

1 Answer

0 votes

The only things I can come up with are a whole lot of work, I don't think you're going to be able to get around it:

  • In PhotoShop/Gimp, cut up the territories into their own layers,
    saving each as a PNG file. Import them into Godot and carefully place
    them as sprites. Then you change their modulate property to change
    their colors.
  • In Godot carefully make Polygons that are the same shape as the
    territories, then you can arrange the Polygons into the map - this is
    probably the best way to do it because it gives you Polygon objects
    to use for your CollisionShape2Ds so you can handle user input.

My sincere recommendation is to not focus so much on aesthetics and focus more on game play and go with a Civ6 style hexagon/square TileMap. Crazy shapes are NOT fun to work with when programming.

by (3,906 points)

this is quite logical, I support

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.