Dark Bit Factory & Gravity

GENERAL => Challenges & Competitions => Topic started by: Optimus on June 12, 2006

Title: Short Intro Challenge - Sphere mapping with plasma background
Post by: Optimus on June 12, 2006
I guess I managed to obfuscate a lot of code. And with only the effect I was in 12 lines iirc. I had no inspiration for additional effects. At first I decided to call for music playing so that I intentionally reach 20 lines. But still I managed to obfuscrate the music init code too. So even if I am only at 14 lines I decided to stop here with this. Sorry, I never have motivation to fill those lines or those bytes left in size coding compos  :P

It shows that much more can be done in 20 lines. And I was even too lazy to improve!  O0

Code: [Select]
#include "tinyptc.bi"
#include "fmod.bi"
if ptc_open( "20 lines Optytro 3", 320, 240) then dim shared buffer(320*240) as integer
if FSOUND_Init(48000, 8, 0) then FMUSIC_PlaySong (FMUSIC_LoadSong ("contraduct_design.xm"))
do
l! = timer * 64.0
for y%=-120 to 119
    for x%=-160 to 159
        k! =  sqr((10240 + sin(l!/32.0)*6144)- x%*x% - y%*y%)/256.0
        if k!>0.1 then buffer((y%+120) * 320 + x% + 160) = (((((x%/k! + l!*8) AND (y%/k! + l!*8)) AND 255)) SHL 16) OR ((sqr(x%*x%+y%*y%)) AND 255) else buffer((y%+120) * 320 + x% + 160) = ((sin((sin(x%/45) * 41263 + sin((y% + l!*2)/45) * 65446 + sin((x% + sin((y% + l!*1)/64) * 256)/67) * 36676 + sin((x% + y% + y%)/127) * 7896)/4096) * 127 + 128) SHL 16) OR (((x%+160) SHR 1) SHL 8) OR (y% + 120)
    next x%
next y%
ptc_update@buffer(0)
loop until inkey$<>""

Goodnight..

p.s. Music by the hardliner btw.
p.p.s. I could obfuscrate more but it started being too slow. E.g. I made a test where I removed X, Y loops, inserted a For i=0 to 320*240-1 loop, and in all the big line with maths, I changed X with ((i mod 320) - 160) and Y with ((i \ 320) - 120). Crazy!!! But I decided to not put this here because it made the code even more slow and I already had more than enough lines anyways..
p.p.p.s. External files are allowed eh? Like fmod.dll and a music. Or not? I've seen somewhere that they are allowed..
p.p.p.p.s. And it still impresses me that by using FPU in such a crazy way with so many calcs per pixel (at least for small resolutions) can still have an ok speed. Not the way I knew to optimize things in quickbasic  ::)
Title: Re: Short Intro Challenge - Sphere mapping with plasma background
Post by: Tetra on June 12, 2006
Really like this one! The math behind that sphere completely mystifies me ???

Nice going with two great effects in one :)

Title: Re: Short Intro Challenge - Sphere mapping with plasma background
Post by: Shockwave on June 12, 2006
In 20 lines that would be slick, 14 lines for this is extraordinary  O0 My favourite so far, speed is ok too :)
Title: Re: Short Intro Challenge - Sphere mapping with plasma background
Post by: Rbz on June 13, 2006
Wow, that's really cool   :o
Title: Re: Short Intro Challenge - Sphere mapping with plasma background
Post by: relsoft on June 13, 2006
Been away for 2 days and you guys make some amazing stuff. Great jobs and proggies guys!!!!
Title: Re: Short Intro Challenge - Sphere mapping with plasma background
Post by: Optimus on June 13, 2006
Thanks, thanks! Now I am thinking about my second entry. Something diferrent this time..
Title: Re: Short Intro Challenge - Sphere mapping with plasma background
Post by: Clyde on June 16, 2006
That is purely awesome, nice one Optimus.
Title: Re: Short Intro Challenge - Sphere mapping with plasma background
Post by: cirux on June 19, 2006
Wow, thats amazing to have both effects in such few lines
Title: Re: Short Intro Challenge - Sphere mapping with plasma background
Post by: Phoenix on June 21, 2006
That's awesome for 14 lines!