August 04, 2025

Tiny Code Christmas - Day 2

Link to the second day

On day 2, we created an animated image of 3 christmas trees, a snow man and snow falling down in 256 bytes.

For painting the christmas trees and the snow man, we reused the code from the day before.

The falling snow took 4 lines and 60 bytes. We use the `time()` function for getting a variable changing from frame to frame.
In a loop, we drew white pixels depending on the current time.
To make it less apparent there is only one pixel per line, the x positions are spaced out with the help of a modulo.
There is also a small time-dependend jitter in the x-direction to make it look more natural.

for i = 1, 240 do
j = i + time()/100
pix(93 * i%240 - j%3, j%240, 12)
end

Link to my solutions

Here is the resulting image: 





No comments:

Post a Comment