Board game-like movement off grid

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By lodbro

I’m pretty new to Godot, coming from Gamemaker 1.4 after they removed the downloads. I need some help creating an off-grid map where if you are adjacent to a certain sprite (province), you may move to it. For example, say you are in the Eastern US province, and you would like to go to the Western US province, you would have to be on a sprite adjacent to it in order to move, you would then click your unit and then right click the province you want to move to and he would move there, eventually I need this to be turn based, but I’ll cross that bridge when I get there

I have map graphics stored as sprites (each province stored as a separate sprite) like this:
provinces as seperate sprites

Any questions about what I want to do, just ask, Thanks in advance for any help!

:bust_in_silhouette: Reply From: picnic

Assuming your unit isn’t going to move around within a province…

Number your areas - for example, the pink bit at the top of South America might be area 10. Each area then has a list of areas that can be moved to, so area 10’s list might be [9, 11, 12] for the three adjacent areas. Each area also has a centre point (maybe the centre of your sprite?) to which units move.

So, from area 10 the player right-clicks on area 11 (you need to detect where they are clicking of course). You know that area 11 is in it’s list [9, 11, 12] so it’s a valid move, and you know the co-ordinates of the point to move to (area 11’s centre/sprite co-ords).

There are plenty of ways to implement this, but a class or some sort of structure for each area would be ideal, with members such as name, list, sprite, centre_x, centre_y etc etc

Hope that helps :smiley:

Thank you , I will try that! <3

lodbro | 2018-07-01 08:53