Share your repls and programming experiences

← Back to all posts
Flurry — Enjoy a flurry of snowflakes from the comfort of your computer!
fuzzyastrocat (1865)

This is a very old project (like, very very old) that I decided to port over to repl for the holiday season. It's a fully computer-generated snow scene (the snowflakes are generated anew every time!). There's not a ton to say about it — it's just a nice background-esque thing with calming snowflakes drifting through the air.

How it works

The cool part is how it's made. Each snowflake is made using a controlled particle system and then mirrored sixfold to create the nice symmetry. The method was inspired by this coding train video.

The motion of the snowflakes is controlled by perlin noise, and each has a preset "rotation offset" to make them look like they are spinning at different times.

So, go ahead and check it out in fullscreen!

Hope you enjoy!

Comments
hotnewtop
xxpertHacker (930)

Seems to have poor performance.

fuzzyastrocat (1865)

@xxpertHacker This is a known issue with some systems, there is a fix that I have not yet had time to implement.

DynamicSquid (4899)

Cool!

Oh, quick question about lang dev if you don't mind :)

How am I supposed to do built in classes like arrays and strings?

For example the array class has methods push, pop, etc; and to handle that, I just have a bunch of ugly if statements, but is there a better way?

I know for many compiled langs like C++, they have a basic primitive type like char*, and they they create an array class around that. But my lang doesn't have that. Should my lang have that?

fuzzyastrocat (1865)

@DynamicSquid Ok, I'll handle this one at a time.

If you have builtin classes, then you need to make their functionality builtin. Exactly how you do this depends on the structure of your language, but ideally you should be able to make builtin classes just like user-defined classes would be constructed. Whether that means pre-adding objects to a list of classes, creating a new object in the global space, or however your language implements OOP, it should be able to be done just like a user-defined class would be defined. This is the "cleanest" approach.

Now, as for the basic primitive thing, that depends. Really, it's a question of how low-level you want your language's foundation do be. Do you want to have a builtin list type and then build all abstractions on top of that? An object type? A raw pointer type? It's really up to how low you wanna go.

DynamicSquid (4899)

@fuzzyastrocat Hmm... I want my language to be fairly high level, so I guess creating a builtin list type would be the best bet.

Ugh, lang dev takes so long. I always think of something new to add or change and I can never finish!

How are your langs coming along?

fuzzyastrocat (1865)

@DynamicSquid They are not! I got kinda busy, didn't have time to do it and therefore lost interest. I'll probably pick it up sometime in a week or two.

DynamicSquid (4899)

@fuzzyastrocat Oh lol. When you get back to it, I hope they're smoother to develop than mine :)

Baconman321 (1097)

Really slow. Otherwise, cool algorithm!

LOL I am the master of performance and yet I don't have any tips rn. I'll let u know if I have tips for performance

fuzzyastrocat (1865)

@Baconman321 The algorithm is inherently "slow", there's no way around that. However, it runs perfectly fast on my system. Do you mean that there is a slow startup or a low FPS?

tussiez (1648)

@fuzzyastrocat Most likely a loop, the tab is eating 24% of my CPU and 60% of integrated graphics

fuzzyastrocat (1865)

@tussiez @Baconman The only thing I could do to potentially speed it up is cache the snowflake image in a graphics object. The issue with this is that now there's a bunch of graphics objects which might not work at all on some systems. So unfortunately I think it has to stay as-is.

tussiez (1648)

@fuzzyastrocat Hmm
How exactly are you updating the snowflakes? Textures shouldn’t be an issue, as long as you use images that aren’t insanely high-res, e.g 1024x1024

fuzzyastrocat (1865)

@tussiez I'm drawing the snowflakes by drawing the particles which constitute the snowflakes.

tussiez (1648)

@fuzzyastrocat Ah, that’s why it runs so slowly.

tussiez (1648)

@tussiez You’re updating all the particles

fuzzyastrocat (1865)

@tussiez I'm not updating all the particles, just drawing them.

tussiez (1648)

@fuzzyastrocat The particles still seem to be the source of the issue

tussiez (1648)

@fuzzyastrocat It's a lot of particles to draw either way.. :shrug:
I still appreciate the work you put into building the snowflakes "from scratch" and applying transformations

fuzzyastrocat (1865)

@tussiez As I said in the post, this is a very old project. I don't have the time right now to fix it, but later I may.

Baconman321 (1097)

@fuzzyastrocat You could try running some of the calculations in the GPU or using webassembly...

fuzzyastrocat (1865)

@Baconman321 GPU wouldn't be worth it, it'd be much better to cache in a graphics object. Webassembly has nothing to do with it, it's not the calculation speed it's the render speed.

tussiez (1648)

R e a l l y n i c e !
I s t h i s r u n n i n g @ 6 0 F P S ? I t a p p e a r s t h a t t h i s a p p i s r u n n i n g s l o w l y o n m y l a p t o p.

fuzzyastrocat (1865)

@tussiez It should be, it's probably just that your laptop can't handle the rendering as fast.

tussiez (1648)

@fuzzyastrocat I have a pretty good laptop...

tussiez (1648)

@fuzzyastrocat You could add a frame counter to see if the app is actually running full speed. I would’ve forked the Repl, but I’m on my phone rn

tussiez (1648)

@fuzzyastrocat Okay, seems to be running good now

fuzzyastrocat (1865)

@ZDev1 Aww... how can I improve it then?

zplusfour (901)

@fuzzyastrocat it's very good!
I think you don't need to add something

kmurp62rulz (6)

t h i s p l e a s e s m e

EpicGamer007 (1736)

I t l o o k s s o d a n g a w e s o m e . E s p e c i a l l y o n
f u l l s c r e e n . G o o d j o b !

TsunamiOrSumth (545)

w h y a r e w e a l l t a l k i n g l i k e t h i s ?

fuzzyastrocat (1865)

@FlaminHotValdez Heh thanks!

suddenly there's a trend of people writing one-word comments like t h i s on this project