Dark Bit Factory & Gravity

PROGRAMMING => Freebasic => Topic started by: Shockwave on July 22, 2006

Title: Plasma thing
Post by: Shockwave on July 22, 2006
Here's a rough draft of a tidier thing I made that may be used in a forthcoming DBF prod. Here's the source to the half working version.
Code: [Select]
'
' RGB PLASMA BY SHOCKWAVE^DBF
' ===========================
'--------------------------------------------------------------------------

            OPTION STATIC
            OPTION EXPLICIT
            print "PRE-CALCULATING PLEASE WAIT"


'-------------------------------------------------------------------------
'Please ditch the defs below, they are for the shit fps counter.
'Benchmark reading when nothing is happening is;
'1876 ++ on my comp.
'
'During runtime it's;
'
'998 - 1038
'-------------------------------------------------------------------------

        declare sub millisecs()
        DIM SHARED AS DOUBLE oldtime,newtime
        dim shared ticks,t as integer


'-------------------------------------------------------------------------
' Colour tables for plasmas!
'-------------------------------------------------------------------------
   
    dim shared ctabler(1024*1096) as ubyte
    dim shared ctableg(1024*1096) as ubyte
    dim shared ctableb(1024*1096) as ubyte
    dim shared as integer pmr,pmg,pmb,pmm
    declare sub plasma_palette ()
    plasma_palette()   
    declare sub plasmoid()   
   

'-------------------------------------------------------------------------
' Includes.
'-------------------------------------------------------------------------
            '#define PTC_WIN
            #Include Once "tinyptc.bi"

'-------------------------------------------------------------------------
' Open Screen;
'-------------------------------------------------------------------------

        If( ptc_open( "FAST RGB PLASMA BY SHOCKWAVE^DBF", 640, 480 ) = 0 ) Then
        End -1
        End If
   
        Dim Shared As uInteger Buffer( 640 * 480 ):' Screen Buffer.

'-------------------------------------------------------------------------
' Main Loop;
'-------------------------------------------------------------------------

    DO
    plasmoid()
    millisecs()
    ptc_update@buffer(0)
   
    ticks=ticks+1 :' <-- Ditch this (FPS Counter)
   
    LOOP UNTIL INKEY$ = CHR$(27)
   

'-------------------------------------------------------------------------
' Renders the plasma onto the screen buffer!
'-------------------------------------------------------------------------

sub plasmoid()
     DIM CC,DD AS UINTEGER
    dim as uinteger a2,a,x,y , pmry,pmgy,pmby     
   
    pmm=pmm+1   
   
    pmr=140+139*sin(pmm/93)
    pmg=140+139*sin(pmm/87)
    pmb=140+139*sin(pmm/79)   
   
    pmry=100+99*sin(pmm/91)
    pmry=(pmry*1024)+pmr   
    pmgy=100+99*sin(pmm/101)
    pmgy=(pmgy*1024)+pmg   
    pmby=100+99*sin(pmm/111)
    pmby=(pmby*1024)+pmb
   
    for y=0 to 479
        CC=640*Y
        DD=1024*Y
        for x=0 to 639                 
        a=CC+x 
        a2=DD+X
        buffer(a)=rgb(ctabler((a2)+pmry),ctableg((a2)+pmgy),ctableb((a2)+pmby))       
        next
    next
end sub

'-------------------------------------------------------------------------
' Shit FPS Counter, discard.
'-------------------------------------------------------------------------

SUB Millisecs()
    dim as double t   
    t=timer
if  t-oldtime >=1 then
    newtime = ticks
    ticks=0
    oldtime=timer
    print "PLASMA ON SPEED FPS:"+str( (newtime) )               
end if   
end sub

'-------------------------------------------------------------------------
' Precalculate some plasma patterns!
'-------------------------------------------------------------------------

sub plasma_palette()
   
    dim as integer l , x , y,cnut   
    for y = 0 to 1096
        cnut=30+29*sin(y/91)
    for x = 0 to 1024
        L=(1024*Y)+X
        ctabler(l)=int(125+(60*sin(((x+y)/33)))+(cnut*cos((y/15))))
        ctableg(l)=int(125+(cnut*sin((x/58)))+(64*cos((y/49))))
        ctableb(l)=int(125+(60*cos((x/27)))+(64*cos(((y-x)/19))))
    next         
    next
end sub
Title: Re: Plasma thing
Post by: Clyde on October 14, 2007
Thats a pretty neat effect Shockwave dude.
Title: Re: Plasma thing
Post by: Shockwave on October 19, 2007
Thanks :) It's old old, don't think it was ever used.
Title: Re: Plasma thing
Post by: DrewPee on November 01, 2007
Yeah I agree with Clyde - nice effect. Nice n fast n colourful!

Drew

ps. Im still here just not producing at the mo - I have several things in the pipeline and struggling with all of them! lol! :whack: Be back soon with something!
Title: Re: Plasma thing
Post by: DrewPee on November 01, 2007
slightly off topic - just noticed that the time on here is wrong - it's an hour fast! Im probably not the first to notice this but hey ho - thought I would say something!!

Drew

ps - do I win a prize! lol!
Title: Re: Plasma thing
Post by: Shockwave on November 01, 2007
Hi Drew :)

Because we have people from all over the world in many different time zones I do not bother altering the clocks on the forum when the clocks go forward/back.

However....

If it bugs you, everyone can change the time offset individually, check your profile and you will find time offset in look and layout preferences :)
Title: Re: Plasma thing
Post by: DrewPee on November 01, 2007
Thanks Shockwave - I wasn't moaning (honest!)

Cheers Drew
Title: Re: Plasma thing
Post by: Jim on November 02, 2007
I didn't touch anything and the forum has the right time already.  GMT+10 Sydney seems to have worked it our for itself...
Jim
Title: Re: Plasma thing
Post by: Shockwave on November 02, 2007
Thanks Shockwave - I wasn't moaning (honest!)

Cheers Drew

No problem , I didn't think you were moaning anyway :)

I didn't touch anything and the forum has the right time already.  GMT+10 Sydney seems to have worked it our for itself...
Jim

Yay! An accidental success!!
Title: Re: Plasma thing
Post by: va!n on November 24, 2007
is there any executable for non fb users available? ^^ thx
Title: Re: Plasma thing
Post by: Shockwave on November 25, 2007
Here, it's really bad though.