KenshinHimura
Programmer
I'm trying to get a plasma graphic affect in qbasic. Does ne1 know how to do this?
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
for (i=0; i<256; i++)
{
vga->SetColour(
i,
(unsigned char)(32 + 31 * cos( i * PI / 128 + (double)currentTime/74 )),
(unsigned char)(32 + 31 * sin( i * PI / 128 + (double)currentTime/63 )),
(unsigned char)(32 - 31 * cos( i * PI / 128 + (double)currentTime/81 ))
);
};
void VGA::SetColour( unsigned char i, unsigned char r, unsigned char g, unsigned char b )
{
// output the index of the colour
outp( 0x3c8, i );
// and it's RGB components
outp( 0x3c9, r );
outp( 0x3c9, g );
outp( 0x3c9, b );
};
For i = 0 to 255
' output the index of the colour
OUT &H3C8, i
' and it's RGB components
OUT &H3C9, Int(32 + 31 * Cos( i * PI / 128 + Timer))
OUT &H3C9, Int(32 + 31 * Sin( i * PI / 128 + Timer))
OUT &H3C9, Int(32 - 31 * Cos( i * PI / 128 + Timer))
Next
Sub FLIPPAL(Speed%)
currentTime = Timer * Speed%
For I% = 1 To 255
CR = Int(32 + 31 * Cos(I% * PI / 128 + currentTime / 74))
CG = Int(32 + 31 * Sin(I% * PI / 128 + currentTime / 63))
CB = Int(32 - 31 * Cos(I% * PI / 128 + currentTime / 81))
If GREY% Then
CG = CR: CB = CR
End If
OUT &H3C8, I%
OUT &H3C9, Int(CR)
OUT &H3C9, Int(CG)
OUT &H3C9, Int(CB)
Next
End Sub
'*** Set the screen mode ***
Screen 13
'*** Set The Palette First ;-)... Here is a grey scale Palette ***
For I% = 0 To 255
OUT &H3C8, I%
C% = I% \ 4
OUT &H3C9, C%: OUT &H3C9, C%: OUT &H3C9, C%
Next
'*** Draw the plasma (this may take a while) ***
Def Seg = &HA000
For Y% = 0 to 199
For X% = 0 to 319
C1% = 64 + 63 * sin(((100 - x)^2 +(160 - y)^2)^.5 / 16))
C2% = 64 + 63 * sin(x / (19 + 7 * cos(y / 37))) * cos(y / (15 + 5 * sin(x / 29))))
Poke CLng(Y% * 320& + X%), C1% + C2%
Next
Next
'*** Then loop through the Palette Cycle until a key is pressed***
K% = Inp(96)
Speed% = 2
Do
currentTime = Timer * Speed%
For I% = 1 To 255
OUT &H3C8, I%
OUT &H3C9, Int(32 + 31 * Cos(I% * PI / 128 + currentTime / 74))
OUT &H3C9, Int(32 + 31 * Sin(I% * PI / 128 + currentTime / 63))
OUT &H3C9, Int(32 - 31 * Cos(I% * PI / 128 + currentTime / 81))
Next
Loop until Inp(96) <> K%
'*** Restore Palette and End ***
Palette
End