Skip to content

Instantly share code, notes, and snippets.

@voidproc voidproc/twinkle.cpp
Last active May 15, 2017

Embed
What would you like to do?
#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

This comment has been minimized.

Copy link
Owner 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
You can’t perform that action at this time.