Skip to content

Instantly share code, notes, and snippets.

@voidproc voidproc/monday.cpp
Created Oct 4, 2016

Embed
What would you like to do?
#include <Siv3D.hpp>
class Bubble : public IEffect
{
public:
Bubble(const Vec2& pos, const Vec2& vel, const double r) : pos_(pos), vel_(vel), r_(r)
{
}
bool update(double t) override
{
pos_ += vel_;
double col_h = ((r_ - 4.0) / 90.0) * 100.0 + 120.0;
double col_v = Saturate(0.2 * (1.0 - t));
Circle(pos_, r_).draw(HSV(col_h, 1.0, col_v));
return t < 1.0;
}
private:
Vec2 pos_;
Vec2 vel_;
const double r_;
};
void Main()
{
const Font font(72, Typeface::Heavy);
Effect effect;
while (System::Update())
{
Graphics2D::SetStencilState(StencilState::Replace);
Graphics2D::SetStencilValue(1);
// いい感じにしたいテキストをここで描く
font(L"今日は月曜日").drawCenter(Window::Center());
Graphics2D::SetStencilState(StencilState::Test(StencilFunc::Equal));
Graphics2D::SetBlendState(BlendState::Additive);
// なんかいい感じのエフェクトをここで描く
if (System::FrameCount() % 2)
{
const double r = Random(4.0, 94.0);
effect.add<Bubble>(Vec2(Random(Window::Size().x), Window::Size().y), Circular(r / 12.0, 0_deg), r);
effect.add<Bubble>(Vec2(Random(Window::Size().x), 0), Circular(r / 12.0, 180_deg), r);
}
effect.update();
Window::ClientRect().draw(Color(40 + 20 + 20 * Sin(System::FrameCount() / 30.0)));
Graphics2D::SetBlendState(BlendState::Default);
Graphics2D::SetStencilState(StencilState::Default);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.