How do I... Grid Movement [SOLVED]

1 favourites
  • 15 posts
From the Asset Store
Snap to visible grid - perfect solution for any game genre
  • So I've looked at a few tutorials but none seem to adress this kind of movement.

    The movement I'm looking for is similar to that of Legend of Zelda (the older games) or Pokemon as you press move, you move one tile/grid square.

    I have a grid 32x32 and all my sprites are 32x32 in size, the closest I can get to it is a bullet movement where I press a button and it checks if it is moving or not, if it's not it's enabled with a 64 pixels per second speed and after half a second it's disabled so it stops in it's tracks after exactly 32 pixels and it looks like I want it to.

    The problem now is I dont collide with solid objects and if I activate "bounce of solids" I bounce off the walls even if I dont hit them as an example is this


    X is a wall and O is empty space even though it's a 32 pixel wide gap and my player model is 32 pixels wide it should work right? But it somehow bounces off anyway.

    I have tried making the collision box of the player smaller but it just makes things worse because if I collide with the wall it sends me bouncing all over the place or knocks me off the grid alignment and then it's messed up.

    I'm probably just missing the obvious here, I have never used Construct 2 for anything more advanced than the tutorial.

    Thanks in advance and hope someone here can give me some decent advice as to how to go about this the correct way.


    To shorten it, I want the player to move in a 32x32 sized grid each step being 32 pixels long and not stop half way if you release the button the player hits move once, player object moves exactly 32 pixels and stops and whenever it hits a solid object it stops just like in Legend of Zelda / Pokemon.

    Update: Finally I got it exactly the way I wanted, thank you SO MUCH everyone for your help Now I am just cursing my poor economy for not allowing me to buy even a private license. *Claws at Families system* I want it so much... Ah well, guess I have to save or hope it comes on steam sale at some point xD

  • Not sure if this is to advanced if you have only used C2 for the tutorials. But this is how I do it in my own tutorial, maybe it can give you some ideas of how to do it. Otherwise let me know and ill try to explain it.

    There is a demo in the top that you can try so you can see how it works and whether its actually something like that you are looking for.

    Just scroll down to topic called "Player control" (Step 12).

  • You could do grid movements with plugin called (chess) board by Rexrainbow.

    One tutorial is here but a bit old:

    Last time I checked he has isometric, hexagonal and square boards witht the movement built in (maybe need some behaviours).

    But I would do move towards angle with certain speed and then stop the action when the position has been captured. If there is no direct control of the player, then I wouldn't use solids, the grid could be done as an array or tilemap. You could check for tile or array value for each position.

  • Here is an quick example of basic roguelike type movement.


    If you'd like to constantly move by a grid square while the key is "down" here is an example of that too


  • For some reason my reply is gone...

    Anyway thanks for the advices, I will look at them all.

    The roguelikemovement-slide key down posted by Minor is the closest to what I want but when I adapt it into my own game it still dont work I still cant get into the 32x32 gap between my wall objects, it is really strange..

    Any thoughts on what could be causing this?

    I have tried setting the origin point of all objects at both 16, 16 (aka center) and at 0,0 (aka top left) and both wall and player are 32x32 solid squares with collision boxes at 32,32 on both so it shouldnt cause problems right?

  • What I do for rogue like movement is quite simple. I make a sprite. I give this sprite 2 variables: "buffer_x" and "buffer_y".

    Then I check for press presses:

    if "buffer_x" and "buffer_y" are 0

    • repeat while pressing right / add 32 (the size of the tiles) to buffer_x
    • repeat while pressing down / add 32 (the size of the tiles) to buffer_y

    if buffer x > 0

    • set buffer_x = buffer_x - 2
    • set player's x position = player's x position + 2

    Repeat for all directions.

    Hope this made sense and was useful

  • I sortof get it but at the same time I dont. I know how you mean I just seem to have issues executing it

    This is how I understood how I make it:

    First I check if the players "buffer_x = 0" and "buffer_y = 0" then I add a "Sub-Event" that have a "Loop While" and "Right arrow is down" with the action "Add 32 to buffer_x" and do the same for the down, left and up key except the left and up keys "Subtracts 32 from Buffer_x" and Buffer_y all in their own sub-events under the first event.

    Then a sepparate event checking if "buffer_x > 0" with the action "Set buffer_x to player.buffer_x -2" and "Set Player.X to Player.X +2"

    If that was just too messy (Probably was XD) here's a link to a screenshot on how I made it <img src="{SMILIES_PATH}/icon_razz.gif" alt=":P" title="Razz">

    When I press left, right, up or down it do not change my buffer_x / buffer_y variable, I probably screwed it up but hopefully you can point out how

  • Just to say when you have added my version to your game and it doesn't work. Don't have your player as a solid or it will never pass through a 32x32 gap as Construct will register a collision.

    Oh and quick note that EightBitBattleCat's way of doing roguelike movement is almost exactly as I did it in the example.

  • It looks right, not sure why it's not working. Here's a file I was working on but scrapped. It's got some stuff in it you don't need but it has a functioning system that does what's being discussed in this thread.


    I apologize. I wasn't able to open your files as I prefer only running stable releases of C2 so I didn't know what your files contained.

  • Minor It looks different but I suppose the idea behind it is the same, they do sound alike.

    Also I do not have player as solid nor do I have the wall as solid and they still collide, I'm not sure why atall.. Maybe it has something to do with the offset being wrong on the wall object but I cant see how it can be..

    Also I've noticed another problem, if I collide with the wall on the X axis I sometimes lose the ability to move on the Y axis and same the other way around but not every time, it's all very strange.

    I probably forgot something really important, gonna have a look at that capx and hopefully I can spot it!

    Update: After looking at 's file I realized the "loop while" thing was not there and upon removing them I can now move

  • Yeah - a lot of things have built in "while" functions unless you set a "Trigger once" condition

  • I had another idea from your example, another thing that should have come natural to me but I was just being impatient and was looking for a much more advanced answer than was needed. Instead of having the player look for a collision (which causes the player to get stuck everywhere whenever there's a object next to it) I have collision detectors following around me so again thanks! Now I can finally proceed

  • No problem I find it's the best method for this type of movement. Phealin was having trouble recreating it from your description and I was just trying to save him the trouble, since he would have just ended with the same thing as my example.

  • Greetings,

    I have a particularly simple way to implement what you're looking for, including collisions. I just posted a tutorial about it here at: ... d-movement

    Hope this helps!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Subscribe to Construct videos now

    Saludos <img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt=":D" title="Very Happy">

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)