How To Check Movement Direction – PuzzleScript

This post is part of a series in learning how to make games with PuzzleScript. If you haven’t read my previous tutorials, I recommend you do so here, as that is assumed knowledge for this post.

Specifying Directions

There might be times when you want to check if an object is moving in a certain direction. I experimented a bit with this in Puzzledorf, but it didn’t suit my puzzles. If you have a unique idea to try it with though, this is how you do it.

Open up PuzzleScript, make a new game based on the Basic example and replace their Rules with the following code:

[ Left Player ] -> [ Crate ]

Run the game and see what happens.

If you try and walk left at any point, the player will turn into a crate. This is a really good example of how specifying directions works.

We’re used to this format I’ve used before to explain code in PuzzleScript:

[ Condition ] -> [ Event ]

If the condition is true, the event will occur.

But now that we want to check for directions, it follows new rules:

[ Movement Direction Object Affected ] -> [ New State of Object ]

So our previous code:

[ Left Player ] -> [ Crate ]

Is checking if the player is moving Left. If it is, swap the player with the crate object.

Direction Types

The different types of directions you can choose from are:

  • Up
  • Down
  • Left
  • Right
  • Horizontal (checks to see if there is any horizontal movement)
  • Vertical (checks to see if there is any vertical movement)

Conclusion

The next tutorial is on how to create custom movements.

Next Tutorial >

If you enjoyed reading, try my game Puzzledorf out on Steam and Humble Bundle.

2 thoughts on “How To Check Movement Direction – PuzzleScript

Add yours

    1. Not that I am aware of. If you check that the player is moving in a direction, or using the action key, then you know he’s pressing a key and you can do something. But I am not sure if you can check for keys other than the default Puzzle Script ones.

      You’d have to hunt through the Puzzlescript documentation / forums or try looking at other Puzzle Script games on their front page and pressing the pseudo “Hack” button to look at their code to see if anyone else is doing what you are trying to achieve. When you start getting to that advanced stage, that’s how to take yourself further.

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Blog at WordPress.com.

Up ↑

%d bloggers like this: