How do I... Grid Movement [SOLVED]

Get help using Construct 2

Post » Wed Jun 11, 2014 11:11 pm

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

XOX

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.

Edit:
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 :D 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
Last edited by Phealin on Thu Jun 12, 2014 7:28 pm, edited 1 time in total.
B
6
S
1
Posts: 13
Reputation: 847

Post » Wed Jun 11, 2014 11:28 pm

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.

https://www.scirra.com/tutorials/999/random-dungeon-generator-node-based#h2a16
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).
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,848

Post » Thu Jun 12, 2014 2:47 am

You could do grid movements with plugin called (chess) board by Rexrainbow.
One tutorial is here but a bit old: https://www.scirra.com/tutorials/864/board-movements

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

https://github.com/rexrainbow/C2_plugins

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.
B
6
S
2
Posts: 24
Reputation: 531

Post » Thu Jun 12, 2014 9:44 am

Here is an quick example of basic roguelike type movement.

roguelikemovement-slide.capx


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

roguelikemovement-slide key down.capx
You do not have the required permissions to view the files attached to this post.
B
46
S
23
G
7
Posts: 459
Reputation: 6,763

Post » Thu Jun 12, 2014 10:50 am

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?
B
6
S
1
Posts: 13
Reputation: 847

Post » Thu Jun 12, 2014 11:29 am

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 :)
B
6
S
1
Posts: 41
Reputation: 762

Post » Thu Jun 12, 2014 4:31 pm

@EightBitBattleCat 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 :P

http://imageshack.com/a/img843/267/75sm.png

Image

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
B
6
S
1
Posts: 13
Reputation: 847

Post » Thu Jun 12, 2014 5:31 pm

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.
B
46
S
23
G
7
Posts: 459
Reputation: 6,763

Post » Thu Jun 12, 2014 5:36 pm

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.

@Minor
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.
You do not have the required permissions to view the files attached to this post.
B
6
S
1
Posts: 41
Reputation: 762

Post » Thu Jun 12, 2014 5:50 pm

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

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


Update: After looking at @EightBitBattleCat 's file I realized the "loop while" thing was not there and upon removing them I can now move :D Now I just gotta get collisions going and I'm good to go :D
B
6
S
1
Posts: 13
Reputation: 847

Next

Return to How do I....?

Who is online

Users browsing this forum: Blendi1223, Darknessed and 38 guests