deepthaw Posted December 15, 2018 Share Posted December 15, 2018 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. Quote Link to comment Share on other sites More sharing options...
deepthaw Posted December 15, 2018 Author Share Posted December 15, 2018 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? Quote Link to comment Share on other sites More sharing options...
emerson Posted December 15, 2018 Share Posted December 15, 2018 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. Quote Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted December 15, 2018 Share Posted December 15, 2018 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. Quote Link to comment Share on other sites More sharing options...
carlsson Posted December 17, 2018 Share Posted December 17, 2018 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? Quote Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted December 17, 2018 Share Posted December 17, 2018 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. Quote Link to comment Share on other sites More sharing options...
RainbowCemetery Posted December 17, 2018 Share Posted December 17, 2018 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.