I'm working on a remix of Pacman.
So far, I've got the control system for Pacman working fine.
I'm using JunctionCheck objects to determine which direction Pacman can go next. Each instance of JunctionCheck has a variable for each direction which states if that direction (north, south, east, west) is true/available or false/not available. (I probably could have set it up in an array, too....ah, but that that's 20/20.
But now I need to set up a system for the Ghosts which will be very much like the controls for Pacman, but which will be operated automatically instead of by the player/manually using the same JunctionCheck objects.
My dilemma is that there will be a mixture of 1-4 directions to choose from and, obviously, each combination will be different. It will be easy enough to manually enter which directions are available for the A.I. ghosts to choose from (that's already set), but the number of directions to choose from will be tedious to enter in without creating too any event lines.
What I'm after is something like this:
Ghost On Overlap w/ JunctionCheck | Set GhostDirection to choose(Direction 1, Direction 2, ...)[/code:eyy2o9ri]
BUT, the code will only list those directions which are true/available. If a path doesn't have and optional east path, then that won't be part of the list of options to choose from.
Any suggestions on how I can do this concisely? Thanks for your help!
Clear an array, check each of the four Junction conditions and Push the direction into the array, only if valid. You'll end up with an array with only valid directions. Now just pick a valid random index in the array, and you've got your direction.
Develop games in your browser. Powerful, performant & highly capable.
blackhornet - As always, the obvious eludes me. LOL Thank you, sir. I should be able to do that easily.