the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 76 lines 2.4 kB view raw
1#include "stdafx.h" 2 3#include "JavaMath.h" 4 5Random Math::rand = Random(); 6 7//Returns a double value with a positive sign, greater than or equal to 0.0 and less than 1.0. 8//Returned values are chosen pseudorandomly with (approximately) uniform distribution from that range. 9//When this method is first called, it creates a single new pseudorandom-number generator, exactly as if by the expression 10// 11//new java.util.Random 12//This new pseudorandom-number generator is used thereafter for all calls to this method and is used nowhere else. 13//This method is properly synchronized to allow correct use by more than one thread. However, if many threads need to 14//generate pseudorandom numbers at a great rate, it may reduce contention for each thread to have its own pseudorandom-number generator. 15// 16//Returns: 17//a pseudorandom double greater than or equal to 0.0 and less than 1.0. 18double Math::random() 19{ 20 return Math::rand.nextDouble(); 21} 22 23//Returns the closest long to the argument. The result is rounded to an integer by adding 1/2, taking the floor of the result, 24//and casting the result to type long. In other words, the result is equal to the value of the expression: 25//(long)Math.floor(a + 0.5d) 26//Special cases: 27// 28//If the argument is NaN, the result is 0. 29//If the argument is negative infinity or any value less than or equal to the value of Long.MIN_VALUE, the result is equal to the 30//value of Long.MIN_VALUE. 31//If the argument is positive infinity or any value greater than or equal to the value of Long.MAX_VALUE, the result is equal to the 32//value of Long.MAX_VALUE. 33//Parameters: 34//a - a floating-point value to be rounded to a long. 35//Returns: 36//the value of the argument rounded to the nearest long value. 37__int64 Math::round( double d ) 38{ 39 return (__int64)floor( d + 0.5 ); 40} 41 42int Math::_max(int a, int b) 43{ 44 return a > b ? a : b; 45} 46 47int Math::_min(int a, int b) 48{ 49 return a < b ? a : b; 50} 51 52float Math::_max(float a, float b) 53{ 54 return a > b ? a : b; 55} 56 57float Math::_min(float a, float b) 58{ 59 return a < b ? a : b; 60} 61 62float Math::wrapDegrees(float input) 63{ 64 while(input>=360.0f)input-=360.0f; 65 if (input >= 180.0f) input -= 360.0f; 66 if (input < -180.0f) input += 360.0f; 67 return input; 68} 69 70double Math::wrapDegrees(double input) 71{ 72 while(input>=360.0)input-=360.0; 73 if (input >= 180.0) input -= 360.0; 74 if (input < -180.0) input += 360.0; 75 return input; 76}