|
Mod | |||
Result = Mod(Number, Divisor) | |||
Parameters: Number=numeric value whose remainder you want to find Divisor=the number used to divide the number parameter |
|||
Returns: Result |
|||
The Mod function (modulus) returns the remainder after a number is divided by a divisor. There's a number handy usages for the MOD function in game programming, a couple that come to mind would be in wrapping movement coordinates, wrapping sprite animations, or even things like finding the locate of a point over a grid. EXAMPLES FACTS: * Mod is implemented as function in PlayBASIC, were it's an operator in some languages. * The Mod(Number,Divisor) function is the equivalent of this code, Result = Number-((Number/Divisor)*Divisor) Example: Showing the use of the Mod function
This example would output.
Wrap Coordinates: This example uses the MOD function to keep the XPOS variable inside the 0 to 799 bounds. Making our object (a circle in this example) appear to move around the screen left to right forever
|
Related Info: | Operators | Sprites | WrapValue : |
|
|||||||||||||||||||||||||||||||||||||||
(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com |