Restrictive Click to Move on a Grid

Get help using Construct 2

Post » Wed Jun 26, 2013 6:07 pm

So I've been doing a bit of the tutorials to get familiar with Construct 2, which is a really awesome tool - loving it.

What I'm trying to accomplish is moving a player about a hexagon grid by using the mouse as a click-to-move feature. I've got that part actually working, however, the player can move themselves freely about the map. There isn't any pathfinding or limit to their distance.

I'm trying to implement the functionality to only move to the space adjacent to the player, essentially a 1 space radius around the player.
This is a bit more confusing than I thought and it was hard to search the forums for this - I found mouse movement, but it was just point-to-point and I found grid movement, but that was using WASD or other keys.

So, the main problem is only allowing the mouse click to move the player onto an adjacent hex tile only. I went about it a few different ways and it seemed UID's were the way to go, although this got just as confusing. I think I need to use instance variables too?

https://www.dropbox.com/s/nkd170m1q9l261s/1_HexGrid_MouseClickMoving.capx

The capx should have everything in it (I made it a project, but everything should be in the layout - chess, tile - that's about it.)
Also, I was fudging it a bit just now and saw something weird where it spawns one at where it should, but then when it moves, there is another one. Not sure how that came about since I got rid of all the stuff I was trying to do, and put it back to how it was.
B
2
Posts: 2
Reputation: 154

Post » Thu Jun 27, 2013 5:19 pm

Alright, so maybe I wasn't clear in what I'm trying to. Got a lot of views, but no replies.

If you can, think Heroes of Might and Magic 2, where in a battle your troops move via hex grid. They have a limit to their movement, like the Skeleton or Peasant. So then bake that down to moving them one space at a time and that's what I'm trying to make.

I'm trying to make it so that you can only move a player piece to a neighboring grid cell using the mouse.

I tried accessing getting the UID of the player piece, so that way I can determine where it can move to. However, I was hoping there was some kind of "check for neighbors" function, because I can't figure a way to get it's neighboring tile's XY.

Is this too advanced for someone starting out with Construct 2? I can see most tutorials are for realtime movement with very few talking about turned based on a grid type movement.SonOfaSheperd2013-06-27 17:20:09
B
2
Posts: 2
Reputation: 154

Post » Thu Oct 19, 2017 12:27 pm

It seems that no one has a clue, even after so many years...Sad...It would be great if someone figures out how to make a Heroes of Might and Magic system.
B
2
Posts: 1
Reputation: 152

Post » Thu Oct 19, 2017 1:27 pm

@RODInteractive
This can be done fairly easy, but it depends on how you build you grid.
Have you seen the FAQ? There are a few examples of grid movement:
how-do-i-frequently-asked-questions_t63692
Check out my awesome game Doptrix
B
17
S
9
G
29
Posts: 517
Reputation: 16,833

Post » Thu Oct 19, 2017 1:36 pm

Hey @RODInteractive!

This page has a very detailed description on how to use and implement hexagonal grids:

https://www.redblobgames.com/grids/hexagons/

It's not focused on construct, but you can do everything there with it. If you need any further help with your first tries, just let us know.

Hope this helps. Cheers!
Bruno

I like to eat, but I'm no cook. Why liking to play games would make you a game designer?
B
19
S
5
G
2
Posts: 535
Reputation: 3,237


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 40 guests