### Author Topic: Plasma Effect  (Read 1685 times)

0 Members and 1 Guest are viewing this topic.

#### Clyde

• A Little Fuzzy Wuzzy
• Posts: 7248
• Karma: 71
##### Plasma Effect
« on: January 08, 2007 »

Here's an experiment with Cobra, which is the plasma routine adapted and featured in the Gravity Dimenisons series. Thanks go to Alan MacDonald for the inspiration with the method.

Code: [Select]
`//// Plasma Effect.// By Clyde January '07//program uses pure2d,keysetConst      XRES=640      YRES=480Var      cs:Array[ 3000 ] Of Integer      sn:Array[ 3000 ] Of Integer            a,c:RealProcedure InitializePlasma()  Var a    Begin          For a=0 To 3000     CS[ a ] = Cos( a )*85     SN[ a ] = Sin( a )*85    Next      EndProcedure UpdatePlasma()  var    d,b    red,grn,blu,col    x,y    // // Update the plasma movement. //  Begin       a = a + 1   c = c - 2   If a <   0 Then a=a+360   If a > 360 Then a=a-360   If c <   0 Then c=c+360  If c > 360 Then c=c-360   d = a   b = c    //   // Draw the plasma effect on the texture.   //    For y = 0 To YRES-1         d = d + 4   b = b + 2         For x = 0 To XRES-1 //Step 2   Red = Abs(CS[d+x] + SN[y+x] + CS[b])*2   Grn = Abs(CS[d+x] + SN[y+x] + CS[b])*1   Blu = Abs(CS[d+x] + SN[y+x] + CS[b])*3              If Red>255 then Red=255        If Grn>255 then Grn=255        If blu>255 then Blu=255        Col = ( Red Shl 16) Or ( Grn Shl 8 ) Or ( Blu )         PixelFast(x,y, Col )    Next       Next  End//EndProcedure RunPlasma()    Begin    OpenScreen(XRES,YRES)        While Not KeyDown(VK_Escape)    Cls          UpdatePlasma()        Flip    Wend        End//EndBegin  InitializePlasma()  RunPlasma()End`
I can't judge what the overal speed is with these snippets, as I am using a demo version - which runs in a window, and seems to have debug mode turned on; so it makes for really slow visuals my end. If anyone has the full version of Cobra, I'd be very interested in seeing the results in a full screen application.

Anyhows I hope these prove a bit useful to anyone who is learning ( like myself ), or thinking about looking into Cobra.

Cheers and all the very best,
Clyde.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

#### mike_g

• Amiga 1200
• Posts: 435
• Karma: 34
##### Re: Cobra - Plasma
« Reply #1 on: January 09, 2007 »
Cool  I'll give it a try when I get home. So far I have been lazy with learning Cobra, but I spose leaning C is a bit more of a priority for me at the moment.

#### Shockwave

• good/evil
• Founder Member
• Posts: 17297
• Karma: 489
• evil/good
##### Re: Cobra - Plasma
« Reply #2 on: January 09, 2007 »
Nice one Clyde. I'm going to download the demo of Cobra at some point this week so I can run your listings.

Shockwave ^ Codigos
Challenge Trophies Won:

#### Clyde

• A Little Fuzzy Wuzzy
• Posts: 7248
• Karma: 71
##### Re: Cobra - Plasma
« Reply #3 on: January 09, 2007 »
No worries and thanks. Im going to post more up as and when I do them.

The only draw back to the demo version is that, it runs in a window with debug on so they run a tad slow, and there's limited content in the help. It is quite fun dabbling in, and has a nice IDE.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

#### GrahamK

• Atari ST
• Posts: 118
• Karma: 17
##### Re: Cobra - Plasma
« Reply #4 on: January 10, 2007 »
He he, glad you like it

Full release is very soon....
Anyway, enough plugging, here is another 'plasma' you may find interesting.
Not as pretty as the one above, but may prove a nice starting point for some demo stuff as it uses the paletted bitmap.

Code: [Select]
`programuses pure2d,keysetconst  width=640  height=480var i,x,y : integer col:integer t1,t2:integer;begin     openscreen(width,height)     for i = 0 to 255       palette(i,torgba(sin(i*(359.0/255.0))*127+128,sin((i*2)*(359.0/255.0))*127+128,sin((i*3)*(359.0/255.0))*127+128))     next       for x = 0 to width-1         for y = 0 to height-1           col= ((sin(y+(2*x)))+(sin(x)*4))*127+128           pixelp(x,y,col mod 256)         next       next     while not keydown(vk_escape)       t1 = MILLISECS;       pal2bmp       shiftpalette(1)       t2 = MILLISECS;       text(0,0,'Time:'+(t2-t1))       flip     wend     closescreenend`
interesting thing about paletted mode, is that any image can have one (autocreated first time you write to it using pixelP). So, cheeky demo coders, can use the standard bitmap, and hide values (0-255) behind pixels. Not exactly sure what you could use it for (maybe heightmap info, or maybe 2 4bit offsets for doing warps), but I'm sure people will get creative with it...

#### Clyde

• A Little Fuzzy Wuzzy
• Posts: 7248
• Karma: 71
##### Re: Cobra - Plasma
« Reply #5 on: January 10, 2007 »
Neat dude
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

#### Shockwave

• good/evil
• Founder Member
• Posts: 17297
• Karma: 489
• evil/good
##### Re: Cobra - Plasma
« Reply #6 on: January 10, 2007 »
Thanks for the plasma Graham

Always nice to see demo effects coded in as many languages as possible!
Shockwave ^ Codigos
Challenge Trophies Won:

#### mike_g

• Amiga 1200
• Posts: 435
• Karma: 34
##### Re: Cobra - Plasma
« Reply #7 on: January 10, 2007 »
Just got around to testing these and they both look real nice. Grahams one runs very smoothly too

#### Shockwave

• good/evil
• Founder Member
• Posts: 17297
• Karma: 489
• evil/good
##### Re: Plasma Effect
« Reply #8 on: January 11, 2007 »
Grahams one is using colour cycling, that's why it's so smooth

I can't honestly say what I think though, the ide looks nice, it's a shame that it's in debug mode.. I might be tempted to write something if I could get a decent turn of speed, or maybe I will soon anyway.

The ability to rotate the palette is very nice.
Shockwave ^ Codigos
Challenge Trophies Won:

#### GrahamK

• Atari ST
• Posts: 118
• Karma: 17
##### Re: Plasma Effect
« Reply #9 on: January 11, 2007 »
he he, my miggy/c64 roots showing

Sorry about the debug mode, but with making the demo not timeout, It is one of the ways to get people to buy.
I still feel it's reasonably fast in debug mode, certainly enough to evaluate it (which is what the demo is all about after all), but for people to get an idea of the speed without, I'm going to post some of the examples compiled without debug, so people can compare them.

I've been looking at some of the demo's / techniques on your site, and I'm going to add some features which make some of them easier (eg. resetting the alpha channel of a complete image, allowing HSL->RGB conversion etc)... So, I'd be really interested in what people over here do with Cobra

#### Shockwave

• good/evil
• Founder Member
• Posts: 17297
• Karma: 489
• evil/good
##### Re: Plasma Effect
« Reply #10 on: January 11, 2007 »
Some examples would be great

I'll see if I can make some nice effects in the meantime I can think of at least 30 that can be done with colour cycling!!
Shockwave ^ Codigos
Challenge Trophies Won:

#### GrahamK

• Atari ST
• Posts: 118
• Karma: 17
##### Re: Plasma Effect
« Reply #11 on: January 11, 2007 »
oooh.. can't wait.

I'm hoping to get a final demo (with the new features) out after the weekend, which I'm hoping will be the same time as it going up for sale!
I've got a nice, voxel demo with movement blur running at a decent rate.

I 'think' I have a bit of trouble with paletted mode inside sprites, but as long as you are just doing image stuff they should be fine.