Copy Link
Add to Bookmark
Report
NULL mag Issue 09 28 Plasma demo textmod
another demo for text mode... this time a plasma effect... not very good. at least not so amazing like the fire effect one.. but still counts :)
program plasma;
uses fastcrt;
const
width = 80;
Var
XAnswer,YAnswer,
ToAdd,
X,Y : Integer;
SinArray : Array [0..width] Of Integer;
Function Rad(Angle : Real): Real;
Begin
Rad := Angle*PI/180;
End;
Begin
{set 80x50 mode to have a better resolution ;) }
asm
mov ax, 1112h
xor bl, bl
int 10h
end;
{Now to create our sine array}
For X := 0 to width Do
Begin
SinArray[X] := Trunc(Sin(Rad(X))*1024);
End;
ToAdd := 0;
While Not Keypressed Do
Begin
wait_retrace;
ToAdd := ToAdd + 1;
{Here we add our small amount to our dynamic variable}
For X := 0 to 80 Do
Begin
XAnswer := 20 * SinArray[((X * 4 ) + (ToAdd )) Mod width]+
30 * SinArray[((X ) + (ToAdd * 4 )) Mod width]+
50 * SinArray[((X Div 4) + (ToAdd Div 4)) Mod width];
{This is our first answer for our X coordinate of the square}
For Y := 0 to 50 Do
Begin
YAnswer := 40 * SinArray[((Y * 6 ) + (ToAdd )) Mod width]+
40 * SinArray[((Y ) + (ToAdd * 6 )) Mod width]+
20 * SinArray[((Y ) + (ToAdd Div 6)) Mod width];
{This is our second answer for our Y coordinate of the square}
{This function writes the "pixel" on the screen. You can use any funtion}
{you want to display a char on the screen}
fastout(x,y,chr(219),(XAnswer+YAnswer) Shr 10);
End;
End;
End;
{back to 80x25 mode}
xsetmode(3);
End.