How do I move the player accordingly

Get help using Construct 2

Post » Wed May 11, 2016 9:01 pm

Hi Everyone,

How do I go about having the player go up by tapping up arrow key, the player continues moving up. Then when I tap left arrow key,
the player continues to move up until the player sees an opening to the left then the player turns.

Thank You.
Posts: 78
Reputation: 1,308

Post » Wed May 11, 2016 9:55 pm

One way of doing this might be to use the 8 direction behavior. You can have a variable set to something like 1,2,3,4 (or left, right, up, down...really whatever works), and then have events set up that simulate movement if the variable is set up a certain way.

You will have a second variable that tracks key presses in the same way.

For example:
-One up pressed - set variable to "up"

For the second part, having the player turn accordingly, I would recommend setting a sprite (a line, maybe with height of 30 and width of 1) and then have that sprite set it's angel depending on the variable, (up, down, left, right).

Next have invisible sprites set up on openings that the player can go into, when the line sprite overlaps that invisible sprite, you set the main player movement variable to the second variable that is dynamically tracking key presses. You simply set the movement to a simulate control based on the primary variable.

So to summarize, with this idea you'll need 2 variables, one for dynamic tracking of key presses, and an additional one that is set for actual movement control, that is set the the secondary variable when the player's "line tracker sprite" collides with the invisible "opening sprite." The line tracker sprite needs to have it's angle adjusted depending on key presses.

I don't know whether this will work for your project because I don't really know what it is, but I'm imagining this as being something that could work for a paceman style game.

Good luck,
Posts: 333
Reputation: 16,616

Return to How do I....?

Who is online

Users browsing this forum: ezgaming420, marcinkowski and 3 guests