'Star Vortex.sdlbas [B+=MGA] 2017-04-19
'Inspired by Andy Amaya's Neon Vortex
' do this with StarMaker adding spin and plasma to Vortex
' ++++++++++++ Instructions ! +++++++++++++
' Press Spacebar to change Plasma Coloring Setting
' Press Number keys 3 to 9 for that many pointed stars
'++++++++++++++++++++++++++++++++++++
option qbasic
const pi = acos(-1)
const radians = pi/180 'to convert an angle measured in degrees to and angle measure in radians, just mutiply by this
const xmax = 1200
const ymax = 700
const cx = xmax/2
const cy = ymax/2
common plasmaR, plasmaG, plasmaB, colorNumber
colorNumber = 0
setdisplay(xmax, ymax, 32, 1)
setcaption("Star Vortex: press spacebar to change Plasma Color Scheme, press number key (3-9) for star Points")
autoback(-2)
function rrn(real) ' sometimes you want a real number not just integer
rrn = real * (rnd(10001) -1)/10000
end function
function rdir()
if rnd(3)-1 then
rdir = 1
else
rdir = -1
end if
end function
function rand(lo, hi)
rand = rnd(hi - lo + 2) + lo - 1
end function
sub Star(x, y, rInner, rOuter, nPoints, angleOffset, TFfill)
' x, y are same as for circle,
' rInner is center circle radius
' rOuter is the outer most point of star
' nPoints is the number of points,
' angleOffset = angle offset IN DEGREES, it will be converted to radians in sub
' this is to allow us to spin the polygon of n sides
' TFfill filled True or False (1 or 0)
pAngle = radians * (360 / nPoints)
radAngleOffset = radians * angleOffset
x1 = x + rInner * cos(radAngleOffset)
y1 = y + rInner * sin(radAngleOffset)
for i = 0 to nPoints - 1
x2 = x + rOuter * cos(i * pAngle + radAngleOffset + .5 * pAngle)
y2 = y + rOuter * sin(i * pAngle + radAngleOffset + .5 * pAngle)
x3 = x + rInner * cos((i + 1) * pAngle + radAngleOffset)
y3 = y + rInner * sin((i + 1) * pAngle + radAngleOffset)
if TFfill then
triangle(x1, y1, x2, y2, x3, y3)
else
line(x1, y1, x2, y2)
line(x2, y2, x3, y3)
end if
x1 = x3 : y1 = y3
next
if TFfill then
fillcircle(x, y, rInner)
end if
end sub
sub resetPlasma 'to work without palette array
plasmaR = rrn(1) ^ 3 : plasmaG = rrn(1) ^ 3: plasmaB = rrn(1) ^ 3
end sub
sub setPlasma()
'common colorNumber, plasmaR, plasmaG, plasmaB
colorNumber = colorNumber + .75
ink(rgb(127 + 127 * sin(plasmaR * colorNumber), 127 + 127 * sin(plasmaG * colorNumber), 127 + 127 * sin(plasmaB * colorNumber )))
end sub
'================================================= main
nP = 5 : ao = 0
resetPlasma
while 1
cls
if key(32) then : resetPlasma : end if
if key(k_3) then : nP = 3 :end if
if key(k_4) then : nP = 4 :end if
if key(k_5) then : nP = 5 :end if
if key(k_6) then : nP = 6 :end if
if key(k_7) then : nP = 7 :end if
if key(k_8) then : nP = 8 :end if
if key(k_9) then : nP = 9 :end if
for i = 150 to 10 step -10
setPlasma
Star(cx, cy, i, 3 * i, nP, i + ao, 1)
next
screenswap
'wait(80)
ao = ao + 3.5
wend