1 (edited by 1337phail 2019-09-07 09:44:48)

Topic: X-Lax, an x-axis parallax demo.` (python)


Edit : loopcount is definitely NOT set to forever, but I think I've fixed the rest of my .gif building problems...

Here's the code...


password is, again : leetforpan

This is a no-frills example of parallax scrolling. 

If you move your head from side to side, things at different depths will appear to move at different rates.  This is called parallax scrolling in the demoscene, and can be vertical or horizontal.  It can create some serious 3d effects without a bit of 3d in it.

This one, of course, is really no-frills.

An experienced python coder can probably figure it out; for the non-programmers, this just does two things : shrinks a graphic (here a hand-drawn rock, and not an interesting one) by y/maxy of its size.  The farther "up" (which is also back, if you're not perfectly on the plane of the ground) it is, the smaller it is...

...the other thing it does is to move it right (left, to the viewer)... by whatever it's up-and-down position (y offset) is.

Yup.  Aaaabsolutely no frills.  In fact, you can see a cropping error in the background at the very end.  I kinda don't care; it was done quickly and works pretty well.

It also engages in artistic exaggeration; the background moves, making it (heh) two kinds of pan demos at once.  This is unrealistic (stare at a far enough horizon from a moving car, and it won't appear to move for a loooong time), but the exaggeratuon also gives a field of movement.

I don't have a good animated gif burner for batch-compiling frames on the hard drive.  Which is too bad - these things totally need a graphic front end.  Sorry 'bout that.  I'd recommend resizing it if someone made one, this thing is 640x480 and just under 1,500 frames. 

It runs at 20fps according to time.sleep, so with computation time, you're probably watching it at 30fps.

It is, seriously, NOOOOO frills at all - it's the simplest code.  It does demonstrate the concept of parallax scrolling in animation.  The scene is an oddly-rocky, imppossibly shallow ocean scrolling by.  In, well... not 3d, but thanks to parallax scrolling, it looks that way.

Have fun!