Board index » delphi » I'm a nebie and can't do a plasma

I'm a nebie and can't do a plasma

Hello,

I have a problem. I don't knwo how to do a plasma.
I know it should be simple, but i'm still kind of a newbie.
Could anybody explain how to do a plasma.

Thanks in advance.

Ferdi

---------------------------------------------------------
Please visit The Sacred Site at:
http://www.worldonline.nl/~feransja
---------------------------------------------------------

 

Re:I'm a nebie and can't do a plasma


Meijerink <feran...@worldonline.nl> wrote

Quote
> Hello,

> I have a problem. I don't know how to do a plasma.
> I know it should be simple, but i'm still kind of a newbie.
> Could anybody explain how to do a plasma.

> Thanks in advance.

> Ferdi

I wouldn't call a plasma a newbee problem. A true plasma requiers good
knowledge in how to use sinuscurvature and palettehandling. There is a
easier way to do a "palette-cycling plasma" but that doesn't look even the
closest to good... To make a palettecycling plasma, you need to start by
either render or draw a picture where you have lines with colors next to
each other in the palette (we're talking standard VGA-mode now, thats
320*200 256 colors) close to each other. Then you put it on the screen and
rotate the palette, sources shouldt be hard to find... When you've done
that, you can e-mail me and I'll tell you how to do a REAL plasma, no
palettecycling whatsoever.
mail me at mailto:joke_...@geocities.com

The real ones look good. Look in the background of jack jazzrabit, the
options screen i think, they have one there.

see ya, Joke/dST

Re:I'm a nebie and can't do a plasma


Quote
Meijerink wrote:

> Hello,

> I have a problem. I don't knwo how to do a plasma.

boy, you really are a newbie...
hehe, just kiddin

Quote
> I know it should be simple, but i'm still kind of a newbie.
> Could anybody explain how to do a plasma.

A proper newsgroup would prob be comp.graphics.algorithms, but what the
heck :)

Ok, now, the lousy theoretical part:

You take several sinewaves with diffrent frequency, and kinda add them
together...
Great explanation, not...

Well, some code:

uses
    crt;

const
     add1: integer = -1;
     add2: integer = 2;
     add3: integer = 3;
{ try changing these consts }

var
   x, y, v, tx, ty, adr: word;
   sintable: array[0..255] of integer; { this is the whole plasma :) a
sine lookup table }
   r, rt: single;
   a1, a2, a3: word;
   l: word;
   adj: single;

begin
     asm
        mov ax, 13h
        int 10h
     end;

     rt:= (359 * 3.14) / (255 * 180);
{    since we will use 255 as a full circle, we need to do some tricks }
{    basic math }

     for x:= 0 to 255 do
     begin
          r:= x * rt;
     {    angle -> radian conversion }
          sintable[x]:= trunc(sin(r) * 127) + 128; { and here we make the sine table }
     end;

     a1:= 0;
     a2:= 0;    

     repeat
           adr:= 0
           maxx:= 159;
           maxy:= 99;

           for y:= 0 to maxy do
           begin
                for x:= 0 to maxx do
                begin
                     ty:= byte(sintable[byte(x+a1+a3)] + sintable[byte(y-x)]);
                     tx:= byte(sintable[byte(y-a1-a2)] - sintable[byte(x+a3)]);
                {    basically, just do something that would produce a "random" frequency,
                     try messing around with this }
                     l:= (ty + tx)

                     ty:= byte(sintable[byte(x-a1+a3)] + sintable[byte(y-x+a3)]);
                     tx:= byte(sintable[byte(y+a1)] - sintable[byte(x-a1+a3)]);

                     l:= (l + (ty + tx));
                     l:= byte(l);
                     if l > 127 then l:= 127 - (l and 127); { i use a 127 colored palette, so... }

                     mem[$a000:adr]:= l;

                     adr:= adr + 1;
                end;
                adr:= adr + 160; { since we're not doing full screen }
           end;
           a1:= (a1 + add1) and 255;
           a2:= (a2 + add2) and 255;
           if ((a1 and 1) = 0) and ((a2 and 1) = 0) then
              a3:= (a3 + add3) and 255;

      {   do some fancy stuff to update the frequency modifiers }
      {   you migth want to change the a3 part, since i used it somewhat diffrent }

     until KeyPressed;
     asm
        mov ax, 3
        int 10h
     end;
end.

Uhm, yeah, pretty :) well, it works...

This is one way to do it, but the "hart" of it is the sine lookup table,
and a handfull of
frequency modifiers

--
- Asbj?rn / Lord Crc

http://home.sn.no/~bheid/
lord...@hotmail.com

Other Threads