Author Topic: Short Intro Challenge - Sphere mapping with plasma background  (Read 7935 times)

0 Members and 1 Guest are viewing this topic.

Offline Optimus

  • DBF Aficionado
  • ******
  • Posts: 2456
  • Karma: 128
    • View Profile
    • Optimouse Demo Site
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  ::)
« Last Edit: June 12, 2006 by Optimus »
Challenge Trophies Won:

Offline Tetra

  • DBF Aficionado
  • ******
  • Posts: 2532
  • Karma: 83
  • Pirate Monkey!
    • View Profile
Really like this one! The math behind that sphere completely mystifies me ???

Nice going with two great effects in one :)

Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17394
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
In 20 lines that would be slick, 14 lines for this is extraordinary  O0 My favourite so far, speed is ok too :)
Shockwave ^ Codigos
Challenge Trophies Won:

Offline Rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2748
  • Karma: 492
    • View Profile
    • http://www.rbraz.com/
Wow, that's really cool   :o
Challenge Trophies Won:

Offline relsoft

  • DBF Aficionado
  • ******
  • Posts: 3303
  • Karma: 47
    • View Profile
Been away for 2 days and you guys make some amazing stuff. Great jobs and proggies guys!!!!
Challenge Trophies Won:

Offline Optimus

  • DBF Aficionado
  • ******
  • Posts: 2456
  • Karma: 128
    • View Profile
    • Optimouse Demo Site
Thanks, thanks! Now I am thinking about my second entry. Something diferrent this time..
Challenge Trophies Won:

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
That is purely awesome, nice one Optimus.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline cirux

  • Atari ST
  • ***
  • Posts: 129
  • Karma: 4
    • View Profile
Wow, thats amazing to have both effects in such few lines

Offline Phoenix

  • C= 64
  • **
  • Posts: 99
  • Karma: 4
    • View Profile
That's awesome for 14 lines!