This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
functions:mod [2017/07/15 15:12] – created korshun | functions:mod [2017/07/15 15:13] (current) – korshun | ||
---|---|---|---|
Line 25: | Line 25: | ||
mod(4, 3) -> 1 | mod(4, 3) -> 1 | ||
mod(5, 3) -> 2 | mod(5, 3) -> 2 | ||
+ | </ | ||
+ | |||
+ | Using mod to implement menu cycling easily: | ||
+ | |||
+ | < | ||
+ | if (KeyPressed(BT_DOWN)) | ||
+ | menuindex++; | ||
+ | if (KeyPressed(BT_UP)) | ||
+ | menuindex--; | ||
+ | | ||
+ | menuindex = mod(menuindex, | ||
</ | </ |