This is something I've been thinking about, but I wanted to ask first.
Basically, my game's got the controller to work and move you around and all that good stuff. Though I've been wondering about doing things such as conveyor belts or fans that can move you without you requesting to move and I'm concerned the way I'm doing things now is not going to be compatible if I decided to implement these things.
So my question would be: Is there a proper way to be checking all the inputs? Right now I'm doing something like this:
-Set a flag for what direction you moved to 0 (1 is left, 2 is right), set flags for if you moved horizontally/vertically to false
-Checks if you pressed left/right to move (can be applied to ground movement or falling/jumping)
-If you requested to move and it's possible, move. Sets the horiz. move flag to true and the direction flag to the requested direction.
-Checks if you requested to jump and if possible, move up. Sets the vert. move flag to true
-While jumping, it checks each pixel if you hit something on your way up and changes the jumping flag to false if you did and immediately exits the jumping routine. Also, the check for directional input gets called again for each pixel you move up so the player can "squeeze" into narrow spaces. If I didn't do this check, you'd have to be pixel perfect to get in between such spaces. This particular check ALSO checks if the horiz. move flag is true because if it didn't, you'd be able to move twice in certain frames and get a much faster speed.
-Checks if you are falling. If the flag for jumping is true, this is skipped entirely. If not and falling is possible, do it. Sets that vert. flag.
-The same directional input check and checks per pixel for jumping also occur for falling.
-Basically after this, it's just checks for shooting, animation, and death.
My methodology does work currently, but I think there are possibly better ways I could be doing it that I may not be seeing. If anyone's got any ideas, I'd love to hear 'em.
Basically, my game's got the controller to work and move you around and all that good stuff. Though I've been wondering about doing things such as conveyor belts or fans that can move you without you requesting to move and I'm concerned the way I'm doing things now is not going to be compatible if I decided to implement these things.
So my question would be: Is there a proper way to be checking all the inputs? Right now I'm doing something like this:
-Set a flag for what direction you moved to 0 (1 is left, 2 is right), set flags for if you moved horizontally/vertically to false
-Checks if you pressed left/right to move (can be applied to ground movement or falling/jumping)
-If you requested to move and it's possible, move. Sets the horiz. move flag to true and the direction flag to the requested direction.
-Checks if you requested to jump and if possible, move up. Sets the vert. move flag to true
-While jumping, it checks each pixel if you hit something on your way up and changes the jumping flag to false if you did and immediately exits the jumping routine. Also, the check for directional input gets called again for each pixel you move up so the player can "squeeze" into narrow spaces. If I didn't do this check, you'd have to be pixel perfect to get in between such spaces. This particular check ALSO checks if the horiz. move flag is true because if it didn't, you'd be able to move twice in certain frames and get a much faster speed.
-Checks if you are falling. If the flag for jumping is true, this is skipped entirely. If not and falling is possible, do it. Sets that vert. flag.
-The same directional input check and checks per pixel for jumping also occur for falling.
-Basically after this, it's just checks for shooting, animation, and death.
My methodology does work currently, but I think there are possibly better ways I could be doing it that I may not be seeing. If anyone's got any ideas, I'd love to hear 'em.