0 Favourites

Simple grid movement

  • 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 :

    https://ibb.co/bH3uEQ

    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!

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • 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

  • 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?

  • 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...

  • 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".

  • 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 ?

  • 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.

  • Magistross

    Thanks, I'll have a look

  • 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.

  • Magistross

    Thanks !

    It seems to be working !

  • Magistross

    Sorry for the late answer! I was on holidays! But now back to dev and games!!

    Thank you so much! It works perfectly!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
564 105,205
rexrainbow's avatar
rexrainbow
Unread hot topic
233 22,247
TiAm's avatar
TiAm
Unread hot topic
0 Favourites
Path Movement Behavior
98 52,470
R0J0hound's avatar
R0J0hound