case/switch statement...
harrio
Member Posts: 234
what's cookin chefs,
in working out my movement rules i have found that the implementation of a case or switch rule structure might save a lot of time. i'm finding that if i have different behaviors for the changing of one global variable, i have to create rule groups for each different instance of the variable. this gets long and tedious with a variable that has several possible values. could something like this be implemented...
enemy mvt group (behavior)
when enemy mvt = down
rule: move down
when enemy mvt = up
rule: move up
when enemy mvt = right
rule: move right
when enemy mvt = left
rule: move left
this could be effective as opposed to the if-then structure we already have because we could define as many outcomes to the value of a variable as we need. and we could define if none of the values are chosen how to handle that instance, be it an error msg or ignoring the case statement and continuing with the other game rules.
does this make sense as something to add?
in working out my movement rules i have found that the implementation of a case or switch rule structure might save a lot of time. i'm finding that if i have different behaviors for the changing of one global variable, i have to create rule groups for each different instance of the variable. this gets long and tedious with a variable that has several possible values. could something like this be implemented...
enemy mvt group (behavior)
when enemy mvt = down
rule: move down
when enemy mvt = up
rule: move up
when enemy mvt = right
rule: move right
when enemy mvt = left
rule: move left
this could be effective as opposed to the if-then structure we already have because we could define as many outcomes to the value of a variable as we need. and we could define if none of the values are chosen how to handle that instance, be it an error msg or ignoring the case statement and continuing with the other game rules.
does this make sense as something to add?