So after you select the marine do you then click on the destination tile you wish him to move to? If so I'm guessing you would also need to find a path around obsticles as well?
For this you will need what is called a graph. It can represent a series of discrete locations and the connections between them. To find the path from source to destination you will have to run a path finding algorithm such as a breadth first search to discover what path the unit should take.
You would also need an array containing each unit and the number of moves it has left in this turn.
Also I would recomend using hexagons instead of squares. It will not be any harder from a coding perspective and will mean that players can travel diagonally much easier.
This kind of task would be about 2nd year college/university level. So I would not recomend it for someone without a little experience under their belt.
An easier task would be letting the user decide the path that the unit takes by only letting them select the tiles adjacent to the current tile. For your example of the marine that can travel 20 tiles that would involve 20 clicks from start to finish though. Or you could not bother with obsticles and let units travel through eachother and the environment. Both of these tasks would be considerably easier.
Happy to help if you want ideas on how to go about any of this.
thequiet Regular ShmoeHello again! I'm looking for an efficient way to create a turn-based pathing system. I could link a video directly outlining what I want, but it's a showcase of a WIP and I believe that's technically stealing.
First, my disclaimer: I DO NOT WANT A TURN BASED TRIGGER SYSTEM. JUST A MOVEMENT SYSTEM.
Anyway, here's what I want:
When a player selects his unit to move, the unit has a specific amount of movement tiles it can move before being locked out of movement until the next turn. For example, say a marine can move 10 squares per turn. That means, if he moves 5 squares, he can move 5 more squares before having to wait until the next turn.
I have NO idea how to create this effect. I'm not looking for any fancy graphic effect, I just want a nice, clean and working solution. I'd be very grateful. Thanks in advance!
Note: I will PM the video to anyone willing to help, and I can expand further in detail if I must.