IGNORED

# 4 way movement on 8 way sticks.

## Recommended Posts

Just curious (since some folks here have probably dealt with it for real):

How do games restricted to 4-directional movement (pac-man) deal with handling input from an 8-way stick where diagonals (two directions at once) can happen?

I can think of several ways (priority algorithms, simply ignoring diagonals, etc.) but figured somebody could explain firsthand.

##### Share on other sites

To clarify: Im playing pac-man on a console with 8-way sticks and approach an intersection from which down and right are both valid directions. I move the stick to down/right, what happens and why? Does it act differently if I move it from down or right to down/right?

##### Share on other sites

A situation like this I believe would vary from game to game. One approach could be to use the joystick input as an offset for a lookup table to determine the direction to take, and have a predefined direction chosen for all multi-directional inputs. Another approach could be to recognize a multi-directional input is present and mask the input with a random value so that an undefined direction is taken. Another approach could be to determine if one of the directions for the multi-directional input is the current player movement direction, then decide to either continue in that direction or to change directions.

##### Share on other sites

Usually priorities result into the best result. E.g. when you are moving horizontally while pushing the joystick diagonal, vertical movement becomes priority. And vice versa. That way you can very precisely and pixel perfect corner in a maze.

Without these priorities, cornering becomes tedious and/or inaccurate.

##### Share on other sites

How would you handle priorities if Pac-Man (or any other character) would stand still at the junction? There are several narrow maze games where the character doesn't move automatically, and even situations where diagonal movement is possible at some positions (e.g. open space) but not near walls. In a such game, would diagonals be treated as there is no way, or either axis have preference?

##### Share on other sites

If Pac-Man stands still, then the joystick must be in neutral position. And it is very unlikely that you can activate both switches of a diagonal at the very same time. So I doubt special code for this very rare corner case exists.

##### Share on other sites

been like 10 years since i made a pacman style game but i just did like other people said, when two directions are pressed at once prioritize a change of axis

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.