Skip to content

Instantly share code, notes, and snippets.

@voidproc
Last active May 15, 2017 02:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save voidproc/486f0229b095272fc611ebca1319750c to your computer and use it in GitHub Desktop.
Save voidproc/486f0229b095272fc611ebca1319750c to your computer and use it in GitHub Desktop.
#include <Siv3D.hpp>
struct Twinkle : IEffect
{
Vec2 pos;
double angle;
double scale;
Twinkle(const Vec2 pos) : pos(pos), angle(RandomSelect({ 0_deg, 45_deg })), scale(Random(0.2, 1.0))
{
}
bool update(double t) override
{
scale *= 0.988;
const double outer = (4 + 25 + 25 * Sin(t * 6_pi)) * scale;
const double inner = (0.5 + 1 + 1 * Sin(t * 6_pi)) * scale;
Geometry2D::CreateNStar(4, outer, inner, angle, pos).draw(Alpha(1 + 120 + 120 * Sin(t * 6_pi)));
return t < 0.50;
}
};
void Main()
{
Effect effect;
while (System::Update())
{
if (System::FrameCount() % 2)
effect.add<Twinkle>(Mouse::Pos() + RandomVec2(Random(80.0)));
effect.update();
}
}
@voidproc
Copy link
Author

voidproc commented Oct 2, 2016

Polygon に対する毎フレームの scaled, rotated, movedBy を避けるよう修正(https://twitter.com/Reputeless/status/782582249950617601)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment