New float double and long double random gen functions. more comments

This commit is contained in:
2018-08-18 22:48:33 -04:00
parent a815367c9d
commit 30416b0334
10 changed files with 26 additions and 14 deletions
@@ -46,3 +46,13 @@ const float cRandom::Rand( const float max, const float min /*= 0.0f*/ ) const
{ {
return (float)((max - min) * rand()/(float)RAND_MAX + min); return (float)((max - min) * rand()/(float)RAND_MAX + min);
} }
const double cRandom::Rand(const double max, const double min) const
{
return (double)((max - min) * rand() / (double)RAND_MAX + min);
}
const long double cRandom::Rand(const long double max, const long double min) const
{
return (long double)((max - min) * rand() / (long double)RAND_MAX + min);
}
@@ -22,9 +22,14 @@ namespace MathEngine {
const bool Setup() const; const bool Setup() const;
/* Gives you a Random Integer less then or equal to max and more then or equal to min */
const unsigned long int Rand( const unsigned long int max, const unsigned long int min = 0 ) const; const unsigned long int Rand( const unsigned long int max, const unsigned long int min = 0 ) const;
/* Gives you a Random float less then or equal to max and more then or equal to min */
const float Rand( const float max, const float min = 0.0f ) const; const float Rand( const float max, const float min = 0.0f ) const;
/* Gives you a Random double less then or equal to max and more then or equal to min */
const double Rand(const double max, const double min = 0.0f) const;
/* Gives you a Random long double less then or equal to max and more then or equal to min */
const long double Rand(const long double max, const long double min = 0.0f) const;
private: private:
/// Variables /// Variables
static cRandom* sp_inst;/// = nullptr static cRandom* sp_inst;/// = nullptr
@@ -19,6 +19,7 @@ EXPIMP_TEMPLATE template class EXPORT_FROM_MYDLL std::basic_string<char>;
#define __cString__MAX_LEN 65535 #define __cString__MAX_LEN 65535
namespace UtilityEngine { namespace UtilityEngine {
/* smaller then std::string */
class EXPORT_FROM_MYDLL cString class EXPORT_FROM_MYDLL cString
{ {
public: public:
@@ -18,16 +18,6 @@ cUtility::cUtility()
cUtility::~cUtility() cUtility::~cUtility()
{} {}
/// public:
// cUtility& cUtility::operator=( const cUtility& copy )
// {
// if (this != &copy)
// {
// }
//
// return *this;
// }
/// Functions /// Functions
/*static*/ cUtility& cUtility::Inst() /*static*/ cUtility& cUtility::Inst()
{ {
@@ -46,8 +46,10 @@ namespace UtilityEngine {
static cUtility& Inst(); static cUtility& Inst();
static void Delete(); static void Delete();
/* prints out a message to stderror. */
void Message( const cString& msg, const cString& debugInfo = "", const eTypeSDL typeSDL = eTypeSDL::NONE ) const; void Message( const cString& msg, const cString& debugInfo = "", const eTypeSDL typeSDL = eTypeSDL::NONE ) const;
/* Prints out what Version of SDL2, SDL2_image, SDL2_mixer, SDL2_net, and SDL2_ttf based on what you pass it to stderror. */
void PrintVersion( const eTypeSDL typeSDL = eTypeSDL::ALL ) const; void PrintVersion( const eTypeSDL typeSDL = eTypeSDL::ALL ) const;
private: private:
@@ -11,6 +11,7 @@
#include "dllExport.h" #include "dllExport.h"
namespace VideoEngine { namespace VideoEngine {
/* cAnimatedSprite is Sprite that only displays a small part of the texture and can be move up, down, left, and right to display the next frame. */
class EXPORT_FROM_MYDLL cAnimatedSprite : public cSprite class EXPORT_FROM_MYDLL cAnimatedSprite : public cSprite
{ {
public: public:
@@ -64,7 +65,6 @@ namespace VideoEngine {
unsigned long int m_nextTime;/// = 0 unsigned long int m_nextTime;/// = 0
unsigned long int m_RATE;/// = 0 unsigned long int m_RATE;/// = 0
};/// END CLASS DEFINITION cAnimatedSprite };/// END CLASS DEFINITION cAnimatedSprite
}/// END NAMESPACE DEFINITION VideoEngine }/// END NAMESPACE DEFINITION VideoEngine
#endif/// END IFNDEF _CANIMATEDSPRITE_HPP_ #endif/// END IFNDEF _CANIMATEDSPRITE_HPP_
@@ -13,6 +13,7 @@
using UtilityEngine::cString; using UtilityEngine::cString;
namespace VideoEngine { namespace VideoEngine {
/* cCamera is texture that cSprites and cAnimatedSprites can be rendered and then renderer cCamera to the Screen */
class EXPORT_FROM_MYDLL cCamera class EXPORT_FROM_MYDLL cCamera
{ {
public: public:
@@ -14,6 +14,7 @@
using UtilityEngine::cString; using UtilityEngine::cString;
namespace VideoEngine { namespace VideoEngine {
/* cImage holds a SDL_Texture or SDL_Surface for use by a cSprite or cAnimatedSprite */
class EXPORT_FROM_MYDLL cImage class EXPORT_FROM_MYDLL cImage
{ {
public: public:
@@ -15,6 +15,7 @@
using UtilityEngine::cString; using UtilityEngine::cString;
namespace VideoEngine { namespace VideoEngine {
/* cImageFile holds a SDL_Texture or SDL_Surface from a file on the system for use by a cSprite or cAnimatedSprite */
class EXPORT_FROM_MYDLL cImageFile : public cImage class EXPORT_FROM_MYDLL cImageFile : public cImage
{ {
public: public:
@@ -21,6 +21,7 @@
using UtilityEngine::cString; using UtilityEngine::cString;
namespace VideoEngine { namespace VideoEngine {
/* cSprite is a class that holds an cImage to be displayed to a Screen or cCamera */
class EXPORT_FROM_MYDLL cSprite class EXPORT_FROM_MYDLL cSprite
{ {
public: public: