• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GML Visual Multi-directional path with junctions

Z

Zjapie

Guest
Hi guys,

New here, hopefully in the right place with a not too stupid question.

I am creating a board game type of game where players can move their pawn across multiple paths from point to point. Multiple directions and crossings are possible.
I am looking for a way in which I can visualize and technically frame possible steps (See image).

At each point I could determine what possible outcomes are at which dice rolled number. I expect there is a type of way (in GameMaker Studio 2 - DnD) that the program calculates the options, but I haven't found it yet.

Can someone tell me which direction to look for best?
 

Attachments

H

Homunculus

Guest
Definitely not doable in DnD, but I’d say also with paths in general (although you could get a bit creative and figure out a way, probably). The problem is not as easy as it seams since we are able to intuitively solve it just by looking at the picture. In practice, paths not really suitable for this kind of scheme if you ask me, you'll probably want to program your own graph system made of connected nodes, which is definitely beyond DnD capabilities in any sensible way.
 

FrostyCat

Redemption Seeker
Definitely not doable in DnD
It's definitely doable in GMS 2 DnD because it supports direct instance ID references much better now. Too many people are taking rumoured limitations of legacy DnD and applying them at face value to GMS 2 DnD, without ever having used either.

For starters, I can easily see Object Variables being used to specify what the next nodes, if the nodes are implemented with objects.
 
H

Homunculus

Guest
I may be guilty of not knowing some of the new DnD features, but defining the nodes as instances is the easy part. Traversing them and their connections trying to find all possible paths, is a whole other thing.
 

NightFrost

Member
Technically this could be viewed as a pathfinding problem. This might be outside your level, but the board could be presented as a graph, and a breadth-first search would be used across it where the search is primed to discover graph nodes at N steps away from start.
 

TheouAegis

Member
A really old-school method:

  • Have an array that is as big as the number of nodes on the board. Each index of this array will hold a "pointer" to a specific index in the next array...
  • Have another array that specifies for each node all the other nodes that you can move to, capped off with a breakpoint value, like -1. The first index will point to where each node starts in the second array.
  • Then make a third array that is as big as the highest value a player can roll (e.g., 6 indexes for a 1d6, 12 indexes for a 2d6). When the dice are rolled, clear this array and use it to keep track of which nodes you've "traversed" while plotting out where the player can go.
  • Have another array, which you also clear with each dice roll, to hold all the possible nodes the player could choose from. Let the player loop through this array to pick out a place to go to, then traverse through the other arrays once again to plot out the path to where the player is trying to go. Alternatively, if you can ensure there is only 2, 3 or 4 possible routes for any roll, you could store all possible traversals inside multiple, sequential arrays and then actually moving the player will be a teensy bit faster.
  • As for moving from node to node, have another array that holds the coordinates of each node. Get the target node the player is trying to move to, fetch its coordinates from the array of node positions, set the speed and direction based on the direction from the current coordinates to the next node's coordinates, then set the sprite based on that (if desired). When the distance to the target node's coordinates is less than the speed the player is traveling, snap the player to the node, process whatever action needs to happen on that node, then end the player's turn.

....Objects will probably be easier for you. lol
 
Z

Zjapie

Guest
Thanks guys!

Yes, my knowledge is still limited. But I really enjoy 'puzzling' with code!
So now i know which direction to look for (and try). If you are unfamiliar with this material (like me), some of the terms and ways of thinking that can help me the next step.

:)
 
Top