# include <Siv3D.hpp>
void Main()
{
for (int32 i = 0; i < 10; ++i)
{
Println(Random());
}
WaitKey();
}
# include <Siv3D.hpp>
void Main()
{
for (int32 i = 0; i < 10; ++i)
{
Println(Random(1, 6));
}
WaitKey();
}
# include <Siv3D.hpp>
void Main()
{
for (int32 i = 0; i < 10; ++i)
{
Println(Random(-100.0, 100.0));
}
WaitKey();
}
# include <Siv3D.hpp>
void Main()
{
for (int32 i = 0; i < 10; ++i)
{
Println(Random(L'A', L'Z'));
}
WaitKey();
}
# include <Siv3D.hpp>
void Main()
{
// 乱数シードを 12345 に設定
Reseed(12345);
for (int32 i = 0; i < 10; ++i)
{
Println(Random(1, 6));
}
WaitKey();
}
# include <Siv3D.hpp>
void Main()
{
// 乱数生成エンジンをシード 12345 で初期化
RNG rng(12345);
// 型と範囲を決める分布クラス
UniformDistribution<int32> dist(1, 6);
for (int32 i = 0; i < 10; ++i)
{
Println(dist(rng));
}
WaitKey();
}
# include <Siv3D.hpp>
void Main()
{
for (int32 i = 0; i < 10; ++i)
{
// 33% の確率で true
Println(RandomBool(0.33));
}
WaitKey();
}
# include <Siv3D.hpp>
void Main()
{
for (int32 i = 0; i < 10; ++i)
{
// リストからランダムに選択
Println(RandomSelect({ 0, 100, 200, 500, 1000 }));
}
WaitKey();
}
# include <Siv3D.hpp>
void Main()
{
while (System::Update())
{
if (Input::MouseL.clicked)
{
const Color color = RandomSelect<Color>(
{ { 255, 128, 128 },{ 128, 255, 128 },{ 128, 128, 255 }});
Graphics::SetBackground(color);
}
}
}
# include <Siv3D.hpp>
void Main()
{
Array<Vec2> points;
for (int32 i = 0; i < 100; ++i)
{
points.push_back(RandomVec2({ 0, 320 }, { 0, 240 }));
}
while (System::Update())
{
for (const auto& point : points)
{
Circle(point, 5).draw();
}
}
}
# include <Siv3D.hpp>
void Main()
{
const Circle circle(320, 240, 200);
Array<Vec2> points;
for (int32 i = 0; i < 100; ++i)
{
points.push_back(RandomVec2(circle));
}
while (System::Update())
{
for (const auto& point : points)
{
Circle(point, 5).draw();
}
circle.drawFrame();
}
}
# include <Siv3D.hpp>
void Main()
{
Array<Color> colors;
for (int32 i = 0; i < 100; ++i)
{
colors.push_back(RandomColor());
}
while (System::Update())
{
for (int32 y = 0; y < 10; ++y)
{
for (int32 x = 0; x < 10; ++x)
{
Rect(x * 40, y * 40, 40, 40).draw(colors[y * 10 + x]);
}
}
}
}
# include <Siv3D.hpp>
void Main()
{
Array<int32> values = { 1,2,3,4,5 };
Shuffle(values);
Println(values);
WaitKey();
}
← 前の章へ戻る | - 目次 - | 次の章へ進む →