Version of Robotron arcade game using LPC1768, a Gameduino shield, a serial EEPROM (for high scores), two microswitch joysticks and two buttons plus a box to put it in. 20 levels of mayhem.
Dependencies: 25LCxxx_SPI CommonTypes Gameduino mbed
Diff: MathFuncs.h
- Revision:
- 8:82d88f9381f3
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MathFuncs.h Sat Jun 08 17:51:33 2013 +0000 @@ -0,0 +1,43 @@ +/* + * SOURCE FILE : MathFuncs.h + * + * Definition of class MathFuncs. + * + */ + +#ifndef MathFuncsDefined + + #define MathFuncsDefined + + #include "Types.h" + + /** Various useful maths related functions. */ + class MathFuncs { + + public : + + /** Constrain a number to be between 2 values. + * + * @param x Number to constrain. + * @param min Minimum value. + * @param max Maximum value. + * @returns A number between min and max. + */ + static Int16 Constrain( Int16 x, Int16 min, Int16 max ) { + if( x < min ) { + return min; + } + else if( x > max ) { + return max; + } + else { + return x; + } + } + + }; + +#endif + +/* END of MathFuncs.h */ +