We want to animate falling snow flakes in the
Solarus game engine framework.

The main screen size is 320x240 (
QVGA for those from bygone days), traditionally animated using
wrapping tiles.
Let's pick up a 32x24 one, because the dimensions (width
&& height) of one tile must be multiple of 8 under Solarus.
Put it into motion with 24
frames so the animation can loop at 40
_ms delay per frame (slow snow,
persistence of vision).
We get a 18.432_
kpx animation (32*24*24), tiled 10x10 on the screen as shown hereafter.
One small tileWxH | | | kpx | | | tiling |
32x24 | | | 18.432 | | | 10x10 |
Preferring something with less -- if not without -- patterns ?
We could generate a more evenly randomized tile and ...
we would replace patterns with a grid or ...
we should try to make one single 320x240 tile.
One big tileWxH | | | kpx | | | tiling |
320x240 | | | 18432 | | | 1x1 |
This tile is 1000 times heavier (32
0*24
0*24
0=18432_kpx).
Too large / too tall for Solarus, which prefers the overall size of tiles sets
to be less than 2048 for compatibility reasons.
So, besides getting rid of patterns, we also need to limit pixels overweight in the process.
The good news is both those goals
can be reasonably achieved by superimposing
two differently sized tiles so that they conceal each other's patterns.
Two differently sized tilesWxH | | | kpx | | | tiling |
32x40+40x24 | | | 74.24 | | | 2x2 |
Let's begin the
off-putting underlying theory detailed explanations with a basic layout of two same size tiles.
Each one has its own patterns, we label them

and

.
When we overlay both, we obtain a new pattern, unrandomly labeled

.
Not that good once tiled on the screen. We still see patterns.
Tile #1WxH | | | kpx | | | tiling | 24x24 | | | 13.824 | | | 13.33x8 |
 | | Tile #2WxH | | | kpx | | | tiling | 24x24 | | | 13.824 | | | 13.33x8 |
 | | OverlayWxH | | | kpx | | | tiling | 24x24 | | | 13.824 | | | 13.33x8 |
 |
If we do the same thing with
differently sized tiles as aforementioned, we get something more interesting.
Let's just take a tile of 2 patterns

and another one of 3 patterns

:
The overlay builds a 'meta-tile' comprised of 6 new patterns which then resume their cycling.
Those 6 patterns are built upon only 5: 2 from tile #3 (

and

) plus 3 from tile #4 (

,

and

).
Arithmetically, 6=
lcm(2,3) and 5=2+3 (
arrest this man, he talks in maths).
We do not 'see' 3 repeating

or 2 repeating

but only one larger

.
Tile #3WxH | | | kpx | | | tiling | 16x24 | | | 9.216 | | | 20x10 |
 | | Tile #4WxH | | | kpx | | | tiling | 24x24 | | | 13.824 | | | 13.33x10 |
 | | OverlayWxH | | | kpx | | | tiling | 48x24 | | | 23.040 | | | 6.66x10 |
 |
With this second tile example, the meta-tile is 48x24 (from a 16x24 tile and a 24x24 one).
Tiny compared to 320x240 but the bigger the meta-tile, the fewer patterns.
So what would be the best ratio for our screen (smallest tiles for biggest patterns-concealing) ?
That would be scann'd and
dimensioj-kalkuli is here to enumerate all the possible combinations;
among which two in particular attract attention.
| | | meta-tile | | | tile set | | | W / H | | | H / W | | |
sizes A | | | 160 | | | 1280 | | | 40 | | | 32 | | |
sizes B | | | 120 | | | 960 | | | 40 | | | 24 | | |
Since 32 is
1/
10 of the screen's width and 24,
1/
10 of its height,
let 32 be the width for tile #5 and 24, the height for tile #6.
We get a 160x120 meta-tile.
1/
4 of the screen.
Shiny.
There is also another scheme: 40x32 + 24x40.
Unfortunately, 40*32*32+24*40*40 = 79.36_kpx when 32*40*40+40*24*24 = 74.24_kpx only !
Now is time for
kahelo-animi to (slowly) generate
images magically.
Tile #5WxH | | | kpx | | | tiling | 32x40 | | | 51.2 | | | 10x6 |
 | | Tile #6WxH | | | kpx | | | tiling | 40x24 | | | 23.04 | | | 8x10 |
 | | OverlayWxH | | | kpx | | | tiling | 32x40+40x24 | | | 74.24 | | | 2x2 |
 |
Compared with the first two one-tile solutions,
≈ lightest * 4 but
≈ heaviest / 250.
Totally worth it, as it prevents eye bleeding. Judge yourself.
One small tileWxH | | | kpx | | | tiling | 32x24 | | | 18.432 | | | 10x10 |
 | | Two differently sized tilesWxH | | | kpx | | | tiling | 32x40+40x24 | | | 74.24 | | | 2x2 |
 | | One big tileWxH | | | kpx | | | tiling | 320x240 | | | 18432 | | | 1x1 |
 |
And, voila !
solarus-vetero.tiles.png solarus-vetero.datCrystal bits of snowflakes all around my head and in the wind.The scenery provides its own patterns hiding as shown below
(customary
animated GIF everywhere for compatibility).
Foreground flakes Are sparse, scattered and fast. Could also be big and bright.
| | 
Background flakes Are numerous, tight and slow. Could also be tiny and dark.
|
Of course, the principle is not
tied to two tiles top, it
would work well with way more.
Needless to say, laziness can grasp even the most motivated ...
Similar to the context-free
chaos theory, this method should be quite ecumenical
and could
theologically theoretically be applied to animations other than snow: mist, rain,
swell ...
It might as well already exists, just like
this ancient 'differential scrolling' was indeed a mere parallax.