Making a grid of available moves(like Advance Wars)?

Get help using Construct 2

Post » Thu Oct 20, 2016 8:11 pm

Hi, I want to make a gid based moving like in Ancient Empires or Advance Wars games.
And i want to do a grid of available moves like this with terrain cost.
Image

I looked through other topics like this, but didn't find any complex description or example of such a thing.

I am thinking about making a loop, where object "Spawner" generates "Move" cells around it in all 4 directions with a step(grid), then "Move" and after that "Spawner" destroys. Then each "Move" object generates "Spawner" and everything repeats depending on Action Points.

But I could not succeed in this approach.

So, I am looking for help.
Is anyone there ho did such a thing, or have any ideas of doing so?
B
7
S
1
Posts: 15
Reputation: 453

Post » Thu Oct 20, 2016 10:57 pm

You'll need to set up a few variables.

Moves remaining, and move cost for each tile.

Create an "available move" (blue tile) at the origin, with the movesRemaining instance variable.

For each tile around it, create a new available move IF the moveCost is less than or equal to movesRemaining. Then subtract the moveCost from the origin tile's movesRemaining value to set the new move tile's movesRemaining.

Repeat again for each new set of tiles until no new tiles are created (all have 0 movesRemaining). In the event of any overlaps, keep only the instance with the highest movesRemaining.

You can use a flag/toggle to keep track of which tile has "spawned" movement tiles already to make it more efficient.
Mistakes were made.
B
54
S
28
G
115
Posts: 1,705
Reputation: 65,083

Post » Thu Oct 20, 2016 11:21 pm

alextro wrote:@fisholith
Great references you got there. Interactive demo from Pathfinding.js sure teach a lot with various algorithms.
And cool video demonstrates alternative method to achieve it.

I am about to implement the case for existing flood-fill range demo: https://dl.orangedox.com/UkkZMMQmTfgSKdbeYx
Actually that would be first part of tutorial (perhaps in future).


No terrain cost just a distance cost within ranged movement.
ImageImage
B
114
S
51
G
24
Posts: 790
Reputation: 23,480

Post » Fri Oct 21, 2016 8:24 am

Thanks, everyone. I will look into it more.
B
7
S
1
Posts: 15
Reputation: 453

Post » Fri Oct 21, 2016 9:06 am

For a "simple" grid movement "ghost", you can check the tutorial I made about turn-based local mutliplayer game board, one of the mechanic is to provide such "ghost" of available movement.
But it doesn't take into account the movement cost.
Possibly you could modify it in order to add it to your own mechanic.
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
296
S
119
G
96
Posts: 7,332
Reputation: 71,306

Post » Fri Oct 21, 2016 12:33 pm

Message: Voni can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
Made it working. But now i am looking for some optimization and it will be good to have all this in one loop, when clicked on a unit.

Here is capx
http://www.mediafire.com/file/z0f50764fgcsdr7/ * MovementGreed.capx (delete * and spaces)

If you have some ideas about this and other improvements, share with them here=)
B
7
S
1
Posts: 15
Reputation: 453

Post » Fri Oct 21, 2016 4:24 pm

Here's a more "logical" (thus less "visual)" way to do it. Also it's done in a single tick, so it has the perks of being instant. ;)

https://dl.dropboxusercontent.com/u/700 ... tGrid.capx
B
76
S
31
G
27
Posts: 1,015
Reputation: 20,790

Post » Fri Oct 21, 2016 4:36 pm

Wow, interesting metod, I will look into it more.
B
7
S
1
Posts: 15
Reputation: 453


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 9 guests