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

MathFuncs.h

Committer:
RichardE
Date:
2013-06-08
Revision:
8:82d88f9381f3

File content as of revision 8:82d88f9381f3:

/*
 * 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 */