• 2D
  • Mock-up for a non-interactive combat system for FreeOrion

In terms of 2D assets, there are free and paid ones on Itch.
https://itch.io/game-assets

Database access is possible, but it's mostly unnecessary. If you are just reading from files, you can use a spreadsheet, which you can export as a CSV file and read in Godot (this is like a ghetto database). For read/write you probably want to use JSON.
https://gdscript.com/solutions/how-to-save-and-load-godot-game-data/

For 2D tile-based games, you can create a TileMap and a TileSet. The map is like the whole world that you see on screen. The set is the options for tiles. You can make multiple sets, one for desert theme, on for a forest, one for a town, etc.
https://docs.godotengine.org/en/stable/tutorials/2d/using_tilemaps.html

    cybereality

    Thanks, I guess that I'll have to learn JSON then...
    I know a little bit of YAML, so I guess it shouldn't be too hard.

    I wasn't aware of TileMaps and TileSets, thanks for the tip.
    Though, reading your link (I didn't test it as a godot project yet) I wonder if it's not overkill for what I want : basically, my game will be a checkerboard with ships on it, and cards to be placed on columns, rows, or tiles to give these ships orders.
    The logical grouping of tiles will be into rows, columns, ... so that when an order is given on a column (for example) all the ships placed on the column should apply it. Some effects will also target a whole set of tiles.
    I want also to have "parent tiles" i.e my 99 checkerboard is also a 33 checheboard (i.e it's possible to give an order to the "left front parent tiles" that will apply to the 9 tiles that are in the 3 front rows and the 3 left columns), that would be another set of tiles.

    Do I need a TileMap for that ?

    Since in the definitive version I want to have a (2n+1) checkerboard rather than a 9*9 (n being the number of combat rounds as defined in the game settings, something that will be given to the combat system by FreeOrion) I guess I do (in order to use "autotile") but for the mockup is it useful ?

    Writing this, I realize that the tiles would need to be in different sets (a single tile is both member or a row, a column, and a "parent tile"), so I'm not sure that TileMap is the right node to use...

      I don't have a lot of experience with tiles, but from what I have, it's very easy to paint up a large board with tiles, but when you need to manipulate a certain tile in some way, it's not intuitive.
      For expanding a tile, If you are working with rectangular sprites, it's very easy to change their scale. They won't look any clearer, but they will be larger, but you might be able to start the scale larger and then scale it down for the board. You could make it a class, and then keep other things with it, like stats, or extra sprites, and then position them locally to the tile when it's expanded.

      I wrote 9x9 and 3x3 checkerboards, the editor automatically converted it into italic apparently.

      LienRag

      A TileMap is just a convenient way of painting the same set of images repeatedly, sometimes with collision shapes in them. You could use a dictionary keyed on vectors to keep track of your tiles. You could assign them to groups and call methods in every member of a group simultaneously. When I think database I usually translate it into Dictionary in godot.

      I would avoid json for what you're doing, since it doesn't handle native vectors or rectangles. It's easier to use store_var() to save the data or nodes directly.

        duane

        I'm not sure if I need vectors ?
        Tokens on the checkerboard will need to move, so maybe vectors are a good option, I have actually no idea about how to use them.
        Tokens will move from one tile to another, and change facing inside the tile, but it's a strict position : the token is on a tile or it is not, there is no "moving half-tile".

        I know what a dictionary is but not sure why it should be keyed on vectors ?

        I thought to use an two-dimensional array for the tiles, since intuitively it seems the most adequate way to have a coordinate system.

        duane You could assign them to groups and call methods in every member of a group simultaneously.

        That seems to be the right way to do it, thanks.

        duane I would avoid json for what you're doing, since it doesn't handle native vectors or rectangles. It's easier to use store_var() to save the data or nodes directly.

        I don't think that I need to save vectors nor rectangles ?
        I need to store the tokens position (which tile they're on and what is their facing) on the first turn and the orders given to them, that's all.
        The orders are cards to be placed on BoardPlacementSlots if I understand the documentation of the GodotCardGameTutorial that I just read, so I just need to save the turn, the order label, and the slot it is using.

        The idea is that the players define "tactical doctrines" in abstraction, and when a battle occur, it is solved by applying the relevant "tactical doctrine" (so, initial ship positioning and orders) to the actual fleets.
        So what I need is to store each tactical doctrine separately (in the mock-up, I intend to have only one tactical doctrine).

        I wasn't able to find documentation about store_var ?

          A Dictionary is flexible, it could be used to simulate a 2D array.

            LienRag

            In my roguelike, I keep a lot of objects confined to a virtual grid by assigning each of them a vector (of two integers) showing their position. I never store any of them in any structure. When I want to find one, I just loop through all the children of their parent object, looking for a particular coordinate (vector). Since the game is turn-based, it doesn't have to be especially fast.

            If I needed more speed, I might take each and assign them to a Dictionary by "dic[Vector2(<x>, <y>)] = <object>". You can use 2D Arrays in gdscript, but I find it more complicated. That's just one way to do things.

            store_var() is a method of File that stores a Variant in a binary format. It supports (as far as I know) all of the native godot objects, so it can be simpler than json.

              You can also load CSV files into Godot. This gives you basically a 2D Excel spreadsheet. I used this for a project to store text and stats and stuff. It's a little harder to save in Godot, but for reading it works well and you can use LibreOffice Calc (or Excel) to write the data, then export as CSV. Sort of like a ghetto read-only database.

                5 days later

                cybereality A Dictionary is flexible, it could be used to simulate a 2D array.

                Really ? How exactly ?

                cybereality you can use LibreOffice Calc (or Excel) to write the data, then export as CSV.

                Not really, except maybe for testing.
                The idea is that the first phase (designing the tactical doctrine) should save each tactical doctrine, and that the tactical doctrine can then be used with various fleet composition.
                So the ability to save to the format is paramount.
                I guess JSON it is then, since I don't really need to save any Godot object.

                Maybe I can use CSV for ship data though, since these ones are not to be modified by the combat system (in FreeOrion they are designed in separate panels), and the mock-up only needs to read them.

                duane In my roguelike, I keep a lot of objects confined to a virtual grid by assigning each of them a vector (of two integers) showing their position. I never store any of them in any structure.

                I downloaded your roguelike but it's quite huge.
                Could you pinpoint one example of this more precisely ?
                From what you write (without having seen the code) I don't understand the advantage of your way.

                  LienRag

                  There's not much to see, really. The monsters are added through a slightly complicated chain of events as children of the dungeon, which inherits from TileMap. So, when I want to check a particular grid location I do

                  func map_unit(pos:Vector2):
                  	for c in get_monsters():
                  		if c.grid_position == pos:
                  			return c
                  
                  func get_monsters():
                  	var out = []
                  	for c in get_children():
                  		if c.get('is_creature'):
                  			out.append(c)
                  	return out

                  That's a simplified version.

                  The advantage for me is that I don't have to maintain the objects in two places. They're always going to be part of the scene tree, so if I use another structure to track them, I'm duplicating effort, and creating the possibility of the two getting out of sync (which actually happened when I was doing it that way).

                  Note that I'm checking for an "is_creature" property instead of using "is Creature" to check the object type. That's just because gdscript 1.x still has huge issues with cyclic references. In a project with a lot of code, it becomes impossible to use typed variables with custom class names or even to use the "is" keyword without errors.

                  I just offer that as an alternative. There are lots of ways to do it.

                  2 months later

                  Since there are only tiles, tokens and cards in the game but all the player's actions will be on the cards, I guess I'd better use already existing card games resources.
                  But apparently there are many different ones, at least two : the Card Game Framework by dbo and the Card Engine by Braindead.

                  Which one is best to use ?
                  I really need only simple things :
                  1 - A list of different cards
                  2 - A few decks to draw from
                  3 - Animation to show the cards in each deck when one wants to draw (it's not random drawing in my game, the player chooses the card he wants - so I guess functionally it's more a "hand" than a "deck" but UI wise they'll be shown as decks on the board)
                  4 - Ability (and the corresponding animation I guess) to choose a card and play it on the board (on BoardPlacementSlots I guess).
                  5 - Ability for BoardPlacementSlots to hold (and show) many cards on it
                  6 - Ability (and the corresponding animation) to check which cards are on BoardPlacementSlot

                  And that's it.

                  I dabbled a little bit with one of them (dbo's I guess) before I changed computer and had to re-download everything (which led me to understand that there are more than one) and apparently the way to use it was to open it with Godot and then add my scenes inside of it ?
                  Isn't it a bit heavy and cumbersome ?
                  Do both framework (or others I don't know of) work that way ?

                  I'm much prefer have clear snippets of code/ressources that I could import into my project and then modify according to what I need.

                  4 days later

                  Well, I tried BrainDeadBzh's framework CardEngine and looked a bit at its documentation.

                  But it says "To create a database press the "Create new database" button."
                  Where do I find this button ?
                  There's a screenshot of the button but on a panel I don't know where to look for.

                  Or is the addon just not working ?
                  I got "Impossible de charger le script de l’extension depuis le chemin : « res://addons/cardengine/card_engine.gd ». Cela peut être dû à une erreur de programmation dans ce script.
                  L'extension « res://addons/cardengine/plugin.cfg » a été désactivée pour prévenir de nouvelles erreures." when trying to enable it in the Project Settings/extensions panel.

                  I did try CardEngine in different versions of Godot but to no avail, I still get the same error message.

                  I also tried a different add-on to test whether I was doing something wrong, but this other add-on works.

                  The error message seems simple enough, but I don't understand why it appears : I checked that there is actually a card_engine.gd file in addons/cardengine and its syntax doesn't seem different than any other plugin's.
                  It's also, as far as i can see, correctly referred to in the plugin.cfg file.

                  It would probably be more helpful if you could provide the error in english.


                  as per github repo :

                  Currently under development, do not expect it to work.

                  Everything is work in progress.

                  You can maybe open an issue on the repo tho. @braindeadbzh seems to be registered on the forums so perhaps they can confirm if this is the preferred way to move forward.