so here's the deal: i'm tinkering with a real-time game right now, and i'm trying to implement a patrolling enemy. it moves forward until it hits something, turns right, moves forward, turns right, etc. i have four different objects, each with a different facing. here's the code as i have now:
left [ GuardLeft ] -> [ > GuardLeft ]
[ > GuardLeft | Obstacle ] -> [ GuardUp | Obstacle ]
down [ GuardDown ] -> [ > GuardDown ]
[ > GuardDown | Obstacle ] -> [ GuardLeft | Obstacle ]
right [ GuardRight ] -> [ > GuardRight ]
[ > GuardRight | Obstacle ] -> [ GuardDown | Obstacle ]
up [ Guardup ] -> [ > Guardup ]
[ > Guardup | Obstacle ] -> [ GuardRight | Obstacle ]
the rules are listed in counter-clockwise order so that they won't turn and then move immediately. FOR EXAMPLE, if i turned the guard to the right and then made all right-facing guards move, it would turn and move in the same moment, because the rules execute in order.
doing it this way, though, that's exactly what happens when a guard turns from left-facing to up-facing - because the "turn to face up" rule happens before the "move up" rule. so the result it that those turns happen at a different speed than the others, which is exactly not what i want.
is there some syntax or way to order the code that would help here that i just haven't found? it seems like there should be an easy way to implement this.