モクモク
https://gyazo.com/fbf87f29f5b41aa9aa3086b3a563a66d
Emoji を使って煙のようなエフェクト
code:cpp
# include <Siv3D.hpp> // OpenSiv3D v0.3.2
struct Smoke : IEffect
{
const Vec2 m_pos;
const double m_size;
const double m_speed;
const double m_time;
const double m_delay;
Smoke(const Vec2& pos)
:
m_pos(pos + RandomVec2(Random(20, 70))),
m_size(Random(0.8, 2.0)),
m_speed(Random(30, 100)),
m_time(Random(0.3, 0.7)),
m_delay(Random(0.0, 0.3))
{
}
virtual bool update(double timeSec) override
{
const double time = timeSec - m_delay;
if (time < 0) return true;
const double t = 1.0 - time / m_time; // 1.0 ~ 0.0
const auto scale = Vec2(80, 120) * m_size * (0.5 + t * 0.5);
TextureAsset(U"smoke").resized(scale).rotated((628 * Random(8) / 8) / 100.0).drawAt(m_pos + Vec2(0, -m_speed * (1.0 - t)), ColorF(Palette::White, 0.8 * t));
return time < m_time;
}
};
void Main()
{
Graphics::SetBackground(ColorF(0.1, 0.1, 0.2));
TextureAsset::Register(U"smoke", Emoji(U"☁"), TextureDesc::Mipped);
Effect effect;
while (System::Update())
{
if (MouseL.down())
{
for (int i : step(8))
{
effect.add(std::unique_ptr<IEffect>(new Smoke(Cursor::PosF())));
}
}
effect.update();
}
}