How to make a grand strategy map! | Godot 4 Tutorial

Sdílet
Vložit
  • čas přidán 21. 01. 2024
  • Tutorial for Godot showing how to make a grand strategy map with selectable regions through processing a image (.png) file.
    Follow my grand strategy journey:
    • DevLog #1 A new Tiny G...

Komentáře • 80

  • @Bluepikminproductions
    @Bluepikminproductions Před 23 dny +4

    BTW the import_file function for anybody (you're welcome)
    func import_file(filepath):
    var file = FileAccess.open(filepath, FileAccess.READ)
    if file != null:
    return JSON.parse_string(file.get_as_text().replace("_", " "))
    else:
    print("Failed to open file:", filepath)
    return nu

  • @marsguy2200
    @marsguy2200 Před 5 měsíci +17

    "Victoria 2" proceeds to show Vic 3... anyways a banger as always

    • @GSInteractive
      @GSInteractive  Před 5 měsíci +2

      Haha I didn't even realize my mistake there... I’m glad you enjoyed it!

  • @yatuk
    @yatuk Před 5 měsíci +11

    I have been searching for this THANK YOU!

    • @GSInteractive
      @GSInteractive  Před 5 měsíci +2

      Happy to help! I searched a long while myself before finally figuring it out

  • @ledsvik
    @ledsvik Před 4 měsíci

    Great video! Always wondered about that. Great thing is that you fast forward when coding, when it's not necessary to explain a lot. Keep up the good work! 😀

  • @vextronx
    @vextronx Před měsícem

    This is extremely useful. Thank you!

  • @cyberguy1345
    @cyberguy1345 Před 5 měsíci +5

    Please continue the series, it is very interesting as a fellow map game enjoyer.

    • @GSInteractive
      @GSInteractive  Před 5 měsíci +2

      Glad to hear it! I am working on it, it just takes time to figure stuff out. Its unfortunately very little material out there regarding maps like this.

    • @subwooferwatches2043
      @subwooferwatches2043 Před 5 měsíci

      Yes pls

  • @triplem8484
    @triplem8484 Před 5 měsíci

    Great thanks so much for the tutorial! I hope more come soon.

  • @camerarushcountryball999
    @camerarushcountryball999 Před 5 měsíci +1

    This was all I needed TY❤❤❤❤❤❤❤❤❤❤

  • @wonderblundr
    @wonderblundr Před 5 měsíci +2

    Thank you so much for this

    • @GSInteractive
      @GSInteractive  Před 5 měsíci

      My pleasure! I firmly believe that sharing knowledge enriches everyone in the Godot and gamedev community.

  • @psychowaffle4478
    @psychowaffle4478 Před měsícem

    Totally doable if you follow along to the letter. Awesome tutorial

  • @edwardwpalmeriii
    @edwardwpalmeriii Před 5 měsíci +1

    Thank You!!!! Absoulte legend :D

    • @GSInteractive
      @GSInteractive  Před 5 měsíci

      You’re welcome! I’m glad you got something useful from it :)

  • @kardrasa
    @kardrasa Před 5 měsíci +1

    this dude is wild!

  • @ZarzenLetsPlay
    @ZarzenLetsPlay Před 5 měsíci +7

    I remember as a 12 year old about 10 years ago I came up with a very convoluted solution to this problem in GameMaker haha I had a big head ache after that because it pretty much involved making a seperate .png for every region I wanted to add. Good times haha

    • @GSInteractive
      @GSInteractive  Před 5 měsíci

      Indeed, it’s quite humorous that we arrived at the same solution. If you observe the loop that forms the 2D mesh, it does initially generate a separate image file, much like the method you used a decade ago.

  • @isoid
    @isoid Před 5 měsíci +1

    Wow this is perfectly timed, exactly what I needed! Thanks!

  • @anton671games9
    @anton671games9 Před 5 měsíci

    Wow,i am wait that.

  • @user-cg7no4zq9f
    @user-cg7no4zq9f Před 3 měsíci +2

    Keep going brev we need to copy u to take on paradox

  • @WhoEvenFilms
    @WhoEvenFilms Před 2 měsíci +3

    Im having some issues and I honestly don't know why, do you have a download for this project?

    • @GSInteractive
      @GSInteractive  Před 23 dny

      Unfortunately not, but if you follow it closely it should work as expected

  • @DavidCastrohe
    @DavidCastrohe Před 2 měsíci +1

    Can you make a tutorial of how to make that you Can conquest regions using this same tutorial please thank you

    • @GSInteractive
      @GSInteractive  Před 23 dny

      I have some plans for a more extensive tutorial in the future that will cover such topics

  • @allis69one
    @allis69one Před 5 měsíci

    Great stuff, will reccomend, altho I feel bad for Poland.

  • @oguzkagan5599
    @oguzkagan5599 Před 5 měsíci +1

    You are progressing very well. I tried doing the same in Unity. Because I don't know Godot. I have a map of 1920x1080 pixels. It takes me too long to color. Can you help me how to make this faster? How did you do it? My own method is to paint the pixels in my empty map according to the pixels in my bitmap map. But it needs to process more than 2 million pixel data.

    • @GSInteractive
      @GSInteractive  Před 5 měsíci

      Thank you! I tried map of similar size using the method in the video and it takes about 3 minutes, the whole process. I did some testing using C# in Godot, and that actually took WAY longer, probably because it is not as tightly integrated with the engine and I called "Get pixel" every time.
      It sounds like we are doing the same methodology, so it seems to boil down to that Godot is efficient at reading and storing pixel data.
      If you figure out a way to not read every pixel i would love to know! Best of luck

  • @CivilizedWasteland
    @CivilizedWasteland Před 2 měsíci +2

    I'm having trouble with enclaves and exclaves, i can't get it to cut out the shapes.

    • @vextronx
      @vextronx Před měsícem

      Did you find any solution to this? The problem is most likely with the algorithm behind the "opaque_to_polygons" method, but I'm not sure how to deal with it.

    • @vextronx
      @vextronx Před měsícem

      I found the solution (provided that we had the same one). Apparently that method doesn't like it when the background is completely transparent. I changed it to a colour that is not present in the json file, and it works like a charm!

    • @CivilizedWasteland
      @CivilizedWasteland Před měsícem +1

      @@vextronx i changed the original so much now that it hardly looks the same, but my general strategy was checking if there was more than one polygon (if the array was larger than 1) Finding the polygon in the array of polygons with the biggest size(number in array) and then setting the whole array of polygons to one polygon which works but you have to set it up. Then i added 1 to the Z-level so its always above and none of the extra bits get hidden.

    • @GSInteractive
      @GSInteractive  Před 23 dny +1

      Glad that you found a solution :)

  • @clavesi
    @clavesi Před 5 měsíci +1

    Just a heads up for anyone else experiencing a weird border effect. Turn off "Fix Alpha Border" in the Import tab.

    • @GSInteractive
      @GSInteractive  Před 5 měsíci +1

      Thank you for contributing, it's appreciated!

  • @Snauzi
    @Snauzi Před 5 měsíci

    I've had issues reproducing the project, probably because of the different JSON intestation, how do you generate them? I had to use str(regions_dict[region_color]) in the region_name assignation in load regions because the code saw it as Dictionary instead of String and now I don't know how to read it after because during the polygon generation pixel_color_dict has as keys the colors instead of the regions :/

    • @GSInteractive
      @GSInteractive  Před 5 měsíci

      I indent using tabs, but it shouldn't matter as far as I know. Anyways, here's the copy of the file used in the tutorial project:
      {
      "#3fff31" : "Norway"
      ,"#d44a31" : "Sweden"
      ,"#d49f48" : "Finland"
      ,"#d43c48" : "Denmark"
      ,"#d48da0" : "Northern Germany"
      ,"#cc1513" : "Lithuania"
      ,"#27d1a0" : "Latvia"
      ,"#278da0" : "Estonia"
      }
      It is important that you use: regions_dict[region_color] as it calls the value corresponding to the "region_color" key in the regions_dict dictionary.
      It already knows that this value is a string because of the " " notations inside the .txt file.

    • @GSInteractive
      @GSInteractive  Před 5 měsíci +1

      If you want more values, ex. population I would use a list as dictionary value.
      ex.
      {
      "#3fff31" : ["Norway" , 500000]
      ,"#d44a31" : ["Sweden", 700000]
      }
      region.region_name = regions_dict[region_color][0]
      region.region_pop = regions_dict[region_color][1]

    • @Snauzi
      @Snauzi Před 5 měsíci

      Now it works, thanks! I was trying with a much more complicated starting data, like the one showed at the beginning of the video, so names and colors were inverted as dictionary parts and the colors were RGB

  • @blockyuniverseproductions6587

    The grey area doesn't seem to be showing up. It highlights the regions, but the underlying map is fully visible.

    • @GSInteractive
      @GSInteractive  Před 23 dny

      Hard to say what's wrong based of this, but I hope you figured it out. Best advice is just to follow every step closely

  • @RiesenradGameStudios
    @RiesenradGameStudios Před 17 dny

    i am not a fan of region maps, it makes things so static - what i like to do in godot is creating a grid and assigning cells to a faction, this way it gets way more organic and also is a good solution for procedurally generated worlds and apply a colored area2d to 1. visually show "regions" if necessary or wanted by the player and 2. take in structures/resources that are inside the territory for bonus production etc.

    • @GSInteractive
      @GSInteractive  Před 6 dny

      I like the idea! Probably not so easy to implement, but I hope someone mages to do it :)

  • @regularname1825
    @regularname1825 Před 4 měsíci

    ey this is awesome, just one thing... my Area2D polygons show up as a single pixel area.. not exactly sure why it doesn't cover the entire region instead:/

    • @GSInteractive
      @GSInteractive  Před 4 měsíci

      Thank you! hard to say without more to go on, but try to print the pixel color dictionary and see if it appends coordinates? sounds like it overwrites and store only one coordinate per color.

    • @regularname1825
      @regularname1825 Před 4 měsíci

      @@GSInteractive sorry I'm a complete beginner in Godot and coming from languages like c++ dictionaries make my head hurt, I found the issue though! apparently:
      if pixel_color not in pixel_color_dict:
      pixel_color_dict[pixel_color] = []
      pixel_color_dict[pixel_color].append(Vector2(x,y)) ( this was indented to be part of the if statement thus it would only append the first pixel_coordinates it found lol since the second time around it wouldn't fit the requirements, reason why I still think this kind of indentation syntax should be illegal!) thank you so much!

  • @subaybadem2821
    @subaybadem2821 Před 19 dny

    My image file is quite large and as far as I understand, I am experiencing crashes for this reason and my regions are not visible. Can you help me?

    • @GSInteractive
      @GSInteractive  Před 17 dny

      Unfortunately, if its too big then its too big... Remember that it loops through every pixel, so it gets exponentially heavier the bigger the picture is. But I have successfully done tests doing images that are 1024 x1080, which is quite large( 1105920 pixels).

    • @subaybadem2821
      @subaybadem2821 Před 17 dny

      @@GSInteractive i understand thx

  • @DavidCastrohe
    @DavidCastrohe Před 2 měsíci +1

    Also the import file don’t work

    • @GSInteractive
      @GSInteractive  Před 23 dny

      One commenter has posted the import_file function, hope it helps you :)

    • @DavidCastrohe
      @DavidCastrohe Před 23 dny

      @@GSInteractive okay

  • @Jurok999
    @Jurok999 Před 4 měsíci

    very interesting, ive had an idea for a strategy game for a while now that uses drawn regions instead of provinces, would it be possible to make some sort of noise map or something similar that could be used to calculate things like: population, literacy, economy, etc., and then have the player draw sub divisions (provinces,states,etc.) on the world map? fyi i have no game dev experience, but godot might be the one i end up learning.

    • @GSInteractive
      @GSInteractive  Před 4 měsíci

      Thank you! I am not sure i totally understand your concept, but Godot have great drawing capabilities, if that is what you're looking for :)

    • @Jurok999
      @Jurok999 Před 4 měsíci

      @ractive yeah kinda, my main thought was players themselves would be able to draw the subdivisions within their country, instead of having to rely on a set province/state system. think hoi4 style front line but free form and for provinces instead. then use noise maps to define how much eco. population, etc; within those player defined zones. you could try to attach mechanics to it, say small zones are more efficiently influenced and built up but less impactful overall. you could assign governors to zones to better connect internal politics, have it based on government type. idk if i explained any better the second time but hopefully.
      it would be much better for internal management and economy, a weak point in alot of strategy games.

  • @can22224
    @can22224 Před 2 měsíci

    im stuck at the txt file because i cant put it into godot 3.5

  • @luisa9855
    @luisa9855 Před měsícem

    how to draw the province line

  • @investidorintrepido6798
    @investidorintrepido6798 Před 5 měsíci

    Can you publish the code?

    • @GSInteractive
      @GSInteractive  Před 5 měsíci

      I do not plan to release a public repository at the moment, but it might be something I do down the line :)

    • @investidorintrepido6798
      @investidorintrepido6798 Před 5 měsíci

      @@GSInteractive That's too bad, some of those little functions are pretty cool

  • @pawegorka8589
    @pawegorka8589 Před 17 dny

    North germany mhu? 😅

  • @tombkings6279
    @tombkings6279 Před 4 měsíci

    at 18:17 my regions dont show up. I send this comment as a S.O.S

    • @GSInteractive
      @GSInteractive  Před 4 měsíci

      S.O.S even!
      Just to double-check, you clicked the remote tab and not the local?
      If so, the problem is most likely either that there are no values in the dictionary it is looping through or that it doesn't instantiate the region scene.
      My advice is to first put a print inside the loop to try and find the error.

    • @tombkings6279
      @tombkings6279 Před 4 měsíci

      @@GSInteractive I forgot to put in the ready fuction:
      func _ready():
      LoadRegions()

    • @DavidCastrohe
      @DavidCastrohe Před 2 měsíci

      @@GSInteractivewhat if loop don’t work