Simple grid movement

Discuss game development design and post your game ideas

Post » Mon Sep 25, 2017 12:50 pm

Hello everyone!

I am working on turn based game, like Ancient Empires. So i am using a tilemap, but I can't find a way to set a path cost to each tile, to pick a tile, and to set a instance variable to each one etc..

I am stuggling to show the movement of the unit like this :

Image
image uploader

I have found great behavior for the movement, the pathfinding, a lot of helping code, like EasyStar.js. But I cannot manage just to show the possible tiles to move like on the picture, in a simple loop, knowing that each tile mountain, forest, snow has different path cost...

Any help will be appreciated!
B
28
S
10
G
1
Posts: 24
Reputation: 2,266

Post » Mon Sep 25, 2017 3:08 pm

You can make invisible tiles over the entire area where the player is able to watch, then, change the animation/frame of the tiles where he can move with the current weight of move.

This is something similar to the pathfind system. https://www.scirra.com/arcade/other-gam ... -test-1841
Image
B
110
S
24
G
18
Posts: 1,391
Reputation: 22,997

Post » Tue Sep 26, 2017 4:35 am

Thx. But this doesnt work with tilemap, but with separate tiles as frames of an animation.
In this example you can find a path. That's ok, most of the plugins, behaviors, scripts I've found do this.

All I want, is to get this grid, around the hero with all possible moves, at low cost. I've done something with easyStar.js. But I have to find all the paths possible and to use an array to save which tiles I've used already, saving "tileX, tileY" as a string then checking tokenat(array.curValue,0) AND tokenat(array.curValue,1) to check if the tiles has already been colored.. and it takes like 0.5 sec to appear on screen, on a PC... Very slow... I just wanted to set a boolean on the tile ( is it possible on a tilemap??) to check if it has been colored... or something like that..

Should I use the plugin board/square_Tx of rex?

Just to be clear : I don't need a path to all possible movement destinations, just a yes/no answer on whether an agent can get there. I will compute a path later once the player picks a highlighted tile.

Any ideas?
B
28
S
10
G
1
Posts: 24
Reputation: 2,266

Post » Tue Sep 26, 2017 2:13 pm

@tdcostas, I think you really messed my post at all... Also, you don't need a plugin for it, as the sample above, you can do it using events...

What you asked for is very simple, and possible to do inside C2 with by 5 events, pay attention to the sample and adapt it to your needs (using the tilemap instead of separated sprites).

Every tile in the tilemap can be checked and you can setup individual weights for it using a 2D array, with a line for X, Y and Weight.

Highlighting the area where is possible to move on will need the bubble logic of my sample, where you start from the player, going to the surround area, giving them a weight and limiting the bubble to a desired range. You will need it to avoid obstacles and turns around.

I could give you a sample, but been busy to spare this time now, hope luck to you... and peace...
Image
B
110
S
24
G
18
Posts: 1,391
Reputation: 22,997

Post » Mon Oct 02, 2017 3:45 pm

Hey @tdcostas

I tried to create some sort of breadth-first search algorithm to play nice along with my EasyStar.JS plugin. I soon found out that I needed a way to retrieve the cost of a tile if I was to be able to do anything.

Here's the result and the new behavior files needed to run it.

In this example, you'll notice that I'm never using any actual pathfinding. You'd use it however to move to a selected tile, but that's the easy part. ;)

Note that I take for granted that the minimum cost for a tile is 1. That's why I set the "movecost" array size to "MovePoints*2+1".
B
81
S
33
G
27
Posts: 1,029
Reputation: 21,143

Post » Tue Oct 10, 2017 6:27 pm

Hey @Magistross
I'm working on C3, your exemple interests me quite a lot. Would you have a version of the behavior that runs on C3 ?
B
40
S
17
G
5
Posts: 281
Reputation: 6,143

Post » Tue Oct 10, 2017 8:13 pm

@Laurent I have no short term intention of converting my plugin to C3 but I'll try to see if blackhornet's converter could do the trick.
B
81
S
33
G
27
Posts: 1,029
Reputation: 21,143

Post » Wed Oct 11, 2017 7:03 am

@Magistross
Thanks, I'll have a look
B
40
S
17
G
5
Posts: 281
Reputation: 6,143

Post » Thu Oct 12, 2017 6:42 pm

@Laurent

Here's an automatic conversion of the plugin using blackhornet's tool.

I also updated the grid example and you'll need the latest plugin version to open it with C2.
B
81
S
33
G
27
Posts: 1,029
Reputation: 21,143

Post » Thu Oct 12, 2017 8:30 pm

@Magistross
Thanks !
It seems to be working !
B
40
S
17
G
5
Posts: 281
Reputation: 6,143

Next

Return to Game Development, Design & Ideas

Who is online

Users browsing this forum: No registered users and 1 guest