SDXFrameWork  0.07
SDXFrameWork
 全て クラス ネームスペース 関数 変数 列挙型 列挙型の値 ページ
Static Public メソッド | すべてのメンバ一覧
クラス SDX::Rand

乱数生成関数群. [詳細]

#include <Rand.h>

Static Public メソッド

static void Reset (int 初期化子)
 乱数を初期化する. [詳細]
 
static double Get (double 最大値)
 0~最大値の乱数を取得. [詳細]
 
static int Get (int 最大値)
 
static double Get (double 最小値, double 最大値)
 範囲を指定して乱数を取得. [詳細]
 
static int Get (int 最小値, int 最大値)
 
static bool Coin (double trueになる確率)
 範囲を指定して乱数を取得. [詳細]
 

説明

乱数生成関数群.

//乱数で取得して表示する
bool SampleRand()
{
using namespace SDX;
System::Initialise("sample", 600, 400);
while (System::Update())
{
//乱数を初期化する
int a = Rand::Get(100);
double b = Rand::Get(100.0);
//現在時間で初期化して取得
int c = Rand::Get(100);
double d = Rand::Get(100.0);
//a,bは初期化子が同じなので常に同じ、cdは一秒毎に変化
Drawing::String(10, 10, Color::White, { "a:", a });
Drawing::String(10, 50, Color::White, { "b:", b });
Drawing::String(10, 90, Color::White, { "c:", c });
Drawing::String(10, 130, Color::White, { "d:", d });
if (Input::key.Return.on) break;//Enterで終了
}
return true;
}

関数

static void SDX::Rand::Reset ( int  初期化子)
static

乱数を初期化する.

static double SDX::Rand::Get ( double  最大値)
static

0~最大値の乱数を取得.

static double SDX::Rand::Get ( double  最小値,
double  最大値 
)
static

範囲を指定して乱数を取得.

static bool SDX::Rand::Coin ( double  trueになる確率)
static

範囲を指定して乱数を取得.