Ying Yang Version1
'
'Ying Yang w Mouse Acc.sdlbas 2015-05-17 MGA translated from
'ying yang.bas - SmallBasic started 2015-05-14 MGA/B+
'we need a rad/degree conversion functions
function rad(degrees)
'pi = rad(180)
return 3.14159265*degrees/180
end function
sub circ2BW(xc,yc,rc,i)
x1=xc+rc*sin(rad(i))
y1=yc+rc*cos(rad(i))
ink(rgb(255,255,255))
fillcircle(x1,y1,rc)
ink(rgb(0,0,0))
fillcircle(x1,y1,rc/3)
x2=xc+rc*sin(rad(i+180))
y2=yc+rc*cos(rad(i+180))
fillcircle(x2,y2,rc)
ink(rgb(255,255,255))
fillcircle(x2,y2,rc/3)
end sub
sub circ2(x,y,r)
ly=0
for cx=r to 0 step -1
cy=int(sqr(r*r-cx*cx)) 'without int this gets filled with holes too! try it
for dy=ly to cy
dot(x+cx,y+dy)
dot(x+cx,y-dy)
dot(x-cx,y-dy)
dot(x-cx,y+dy)
next
ly=cy
next
end sub
'=========================main
sq=700
SetDisplay(sq,sq,32,2)
autoback(-2)
ink(rgb(0,0,255))
bar(0,0,sq,sq)
ink(rgb(255,255,255))
text(0,0,32,"WARNING: EXTREME Flashing and Spinning")
text(0,62,24,"Slowly move your mouse down the screen,")
text(0,92,24,"as your eyes and stomach adjust.")
text(0,122,24,"press ecs, when you had enough.")
text(32,602,32,"Ying Yang with mouse accelerator, MGA")
i=0 'i is like the clock watching the time
acc=10 'degrees change in advancing 2 circles
while key(27)=0
circ2BW(sq/2,sq/2,sq/8,i)
for j=1 to 5 'to trim up gaps at lower speeds, after a certain acceleration it's not worth the effort
ink(rgb(0,0,255))
circ2(sq/2,sq/2,sq/4+2-j)
next
screenswap
my=mousey
acc=my/sq*60
i=i+acc
if i>360 then
i=i-360
end if
wend
' YING YANG
' version 2
' ying yang2.txt for Naalaa 2015-05-19 MGA/B+
' translated from SmallBasic started 2015-05-14 MGA/B+
' translated to SdlBasic 2015-05-27 by Rick3137
' move mouse slowly up or down screen to adjust speed of swirl, esc to quit
i = 0
function YY(xc,yc,rc)
fr=rc
x1=xc+fr*sin( i)
y1=yc+fr*cos( i )
ink( rgb(0,255,0) )
fillcircle (x1,y1,rc)
ink( rgb(255,0,0) )
fillcircle (x1,y1,rc/3)
x2=xc+ fr * sin( i+180)
y2=yc+ fr * cos( i+180)
fillcircle (x2,y2,rc)
ink( rgb(0,255,0) )
fillcircle( x2,y2,rc/3-2)
end function
' =========================main
setDisplay (800,700,32,1)
autoback(-2)
sq=800
ink( rgb(0,0,255) )
rectangle( 0,0,800,700,true)
i = 0
a =.01
while not key( k_esc )
ink( rgb(20,20,60) )
rectangle( 0,0,800,700,true)
YY (sq/2,sq/2.3,sq/5)
screenswap
i = i + a
if i > 6.28 then
i = i - 6.28
end if
f= mousey()
f=f-50
a = f * .005
wend
end
Version 3
'Ying Yang v3.sdlbas 2015-06-03 MGA
' as per Rick's example:
' loose the radians conversion, loose the text, loose the trimming
' add color and go backwards and forwards
'
' as per Mark's new twist
' add color transition while spinning
' acc equally backwards or forwards
'=========================main
sq=700
rc= sq/4
xc=sq/2
yc=sq/2
SetDisplay(sq,sq,32,1)
autoback(-2)
ink(rgb(0,0,255))
bar(0,0,sq,sq)
nc=1
d=1
i=0 'i is like the clock watching the time
acc=.017 'radians
while key(27)=0
x1=xc+rc*sin(i)
y1=yc+rc*cos(i)
if nc>254 then :d=-1*d:end if
if nc<1 then :d=-1*d:end if
nc=nc+d
ink(rgb(nc,0,0))
fillcircle(x1,y1,rc)
ink(rgb(0,255-nc,0))
fillcircle(x1,y1,rc/3)
x2=xc+rc*sin(i+3.1415)
y2=yc+rc*cos(i+3.1415)
fillcircle(x2,y2,rc)
ink(rgb(nc,0,0))
fillcircle(x2,y2,rc/3)
screenswap
my=mousey
acc=(my-sq/2)/sq*.1963
i=i+acc
if i>6.283 then
i=i-6.283
elseif i<-6.283 then
i=i+6.283
end if
wend