砂嵐(スノーノイズ)
https://scrapbox.io/files/6444daa26dde5e001c07eba1.png
使い方
SnowNoise{RectF 表示させたい領域};
描画する
draw(ColorF 色:省略可);
用途
ゲームの演出など
コード
code:スノーノイズ.cpp
# include <Siv3D.hpp>
class SnowNoise
{
public:
SnowNoise(const Size& size)
{
Image image{ size / 2 };
for (auto& texture : m_textures)
{
for (auto y : step(image.height()))
{
double r = Random(0.0, 1.0);
for (auto x : step(image.width()))
{
imageyx = ColorF{ (double)RandomBool(r) };
}
}
texture = Texture{ image };
}
}
void draw(const Vec2& pos = { 0,0 }, ColorF color = Palette::White)const
{
const int32 n = static_cast<int32>(Scene::Time() * 10) % m_textures.size();
m_texturesn.scaled(2).draw(pos, color);
}
private:
Array<Texture> m_textures{ 10 };
};
void Main()
{
SnowNoise nois{ Scene::Size() };
while (System::Update())
{
nois.draw();
}
}
#ゲーム
#背景