Thursday, February 25, 2010

Conditional Commands for Rusher Game Framework

I showed one of my classmates the Command Utility for Rusher Game Framework. He gave me a quick thought about conditional commands, which execute different commands depending of different conditions. I thought the idea was great, so when I turned on my laptop I directly rushed into creating conditional commands for Rusher.

Below are the conditional commands that are now available in Rusher, which is now version 0.5 Alpha.

If Command

The If command executes a "true subcommand" if the return value of the test function is true, otherwise the alternative "false subcommand" is executed. Additional parameters for the test function can be passed as an array.



While Command

The While command repeatedly executes a subcommand until the test function returns false.



DoWhile Command

Pretty much like the While command, the DoWhile command repeatedly executes a subcommand until the test function returns false, except that for the first time the subcommand is always executed regardless of the test function.



For Command

The For command is consisted of two subcommands: the "initCommand" is executed first, then the "loopCommand" is executed repeatedly until the test function returns false.



Switch Command

The Switch command contains a index function, which returns an integer, and an array of subcommands. It executes the subcommand in the array corresponding to the index returned by the index function.



Repeat Command

The Repeat command repeatedly executes a subcommand for a specified number of times. This command basically does not count as a conditional command, but it certainly is equally useful.


No comments: