Dark Bit Factory & Gravity

GENERAL => Challenges & Competitions => Topic started by: Shockwave on June 16, 2006

Title: SHort intro challenge Textured Lava blob
Post by: Shockwave on June 16, 2006
This is definately my last attempt at this.
Hope you like it. By the way, it can be further condensed but I left it as it is because I like the effect and didn't want to ruin it by purely optimising for size as the effect fits easily in 20 lines anyway :)

Code: [Select]
#DEFINE PTC_WIN
 #Include Once "tinyptc.bi"
 If( ptc_open( "TEXTURED BLOB LAVA LAMP BY SHOCKWAVE ^ DBF 18 LINES.", 640, 480 ) = 1 ) Then dim shared buffer(640*480) as integer, buffer2(640*480) as integer, colours (320) as integer, strt as double,intr as double,buffer3(640*480) as integer, fact as double
 for a=-300 to 640*480
    if a<0 then colours(a+300)=rgb( 0,0,(a+300) *.35  ) else if a>=0 then buffer2(a) = rgb(0,0,((int(a/640)) xor (int(a mod 640))))
    if a>=0 then buffer3(a) = rgb(0,((int(a/640)) xor (int(a mod 640))),0) next
 do     
    for y=0 to 479
        leng=250+(199*cos((y-timer*214)/63))*sin((y+(timer * 263))/(150+150*sin(timer*.00002)))
        intr = (640/leng)
        strt = 0
        fact=0.001
        if intr <=0 then intr=1
        for x=0 to 640
            if x>=320- (leng/2) and x<= 320 + (leng/2) then buffer((y*640)+x) = ((buffer2((y*640)+int(strt)))*fact) else buffer((y*640)+x)=buffer3((y*640)+x)+colours( y shr 1 )
            if x>=320- (leng/2) and x<= 320 + (leng/2) then strt=strt+intr
            if x>=320- (leng/2) and x<= 320 + (leng/2) then if x<320 then fact=fact+.002 else if x>320 then fact=fact-.002 end if next next
 ptc_update@buffer(0)  loop until inkey$<>""
Title: Re: SHort intro challenge Textured Lava blob
Post by: Shockwave on June 16, 2006
Same code, different background..
Code: [Select]
#Include Once "tinyptc.bi"
 If( ptc_open( "TEXTURED BLOB LAVA LAMP BY SHOCKWAVE ^ DBF 18 LINES.", 640, 480 ) = 1 ) Then dim shared buffer(640*480) as integer, buffer2(640*480) as integer, colours (320) as integer, strt as double,intr as double,buffer3(640*480) as integer, fact as double
 for a=-300 to 640*480
    if a<0 then colours(a+300)=rgb( (a+300) *.15 ,(a+300) *.25 ,(a+300) *.35  ) else if a>=0 then buffer2(a) = rgb(0,0,((int(a/640)) xor (int(a mod 640))))
    if a>=0 then buffer3(a) = rgb(0,((int(a/640)) xor (int(a mod 640))),0) next
 do     
    for y=0 to 479
        leng=300+(199*cos((y-timer*214)/63))*sin((y+(timer * 263))/(150+150*sin(timer*.00002)))
        intr = (640/leng)
        strt = 0
        fact=0.001
        if intr <=0 then intr=1
        for x=0 to 640
            if x>=320- (leng/2) and x<= 320 + (leng/2) then buffer((y*640)+x) = ((buffer2((y*640)+int(strt)))*fact) else buffer((y*640)+x)=colours(y shr 2)
            if x>=320- (leng/2) and x<= 320 + (leng/2) then strt=strt+intr
            if x>=320- (leng/2) and x<= 320 + (leng/2) then if x<320 then fact=fact+.002 else if x>320 then fact=fact-.002 end if next next
 ptc_update@buffer(0)  loop until inkey$<>""
Title: Re: SHort intro challenge Textured Lava blob
Post by: Clyde on June 17, 2006
Well smart, nice one dude.
Title: Re: SHort intro challenge Textured Lava blob
Post by: Rattrapmax6 on June 17, 2006
Pretty cool..  ;)
Title: Re: SHort intro challenge Textured Lava blob
Post by: Tetra on June 17, 2006
quite nice, looks like sound waves ;D
Title: Re: SHort intro challenge Textured Lava blob
Post by: benny! on June 17, 2006
Indeed, looks pretty cool !!!
Title: Re: SHort intro challenge Textured Lava blob
Post by: Shockwave on June 17, 2006
I think that the second version of this technique was my favourite one to program out of all that I made. I'd always wanted to code the effect but never had a reason to do it :)
Title: Re: SHort intro challenge Textured Lava blob
Post by: Clyde on June 17, 2006
Nifty Shockie, welldone/
Title: Re: SHort intro challenge Textured Lava blob
Post by: Optimus on June 18, 2006
Heh, I really like this one!
Title: Re: SHort intro challenge Textured Lava blob
Post by: Shockwave on June 18, 2006
It's similar to yours Optimus, sorry for borrowing the texture generation idea but that xor texture is handy as it takes only a few instructions to make it. I've never used it in a prod of any kind before , normally I just use it for testing texture mapping routines when I can't be bothered to load a texture.
Title: Re: SHort intro challenge Textured Lava blob
Post by: Optimus on June 18, 2006
Yep, XOR texture is what you do (why do I call it a XOR texture when I usually use AND for it? ;)) when you want something fast with few instruction or simply don't have inspiration for an alternative texture generation algorithm. I have overused it in all my tiny intro codes ;P
Title: Re: SHort intro challenge Textured Lava blob
Post by: relsoft on June 19, 2006
Cool!!!! Looks like an intestine!
Title: Re: SHort intro challenge Textured Lava blob
Post by: Shockwave on June 19, 2006
Ewww! I hope my intestines look different :)