05-26-2005, 07:28 AM
This wasn't aiming to be impressive, in fact it originally was just a very lame way of filling a circle, however my creativity soon got away with me and the last 2 and a half hours were spent making this. It doesn't require any external lib's just FreeBasic. Basically it makes squares rotating in a eclipsical ( :???: ) pattern whose size is determined by the mouse position. Enjoy... Post any optimizations if you want, my coding has a lot of room for improvement.
Code:
const r2d = 3.14159265359/180
dim r as integer, deg as integer 'radius, degree
dim wt as double 'timer
dim x as double, y as double 'deal with mouse
screen 14, 32
locate 8,16 :print "Fullscreen?"
locate 10, 18: print "Y = Yes"
locate 12, 18: print "N = No"
locate 14, 8: Print "Press 'F' in game to switch"
do
if multikey(21) then 'Y
fullscreen = 1
exit do
elseif multikey(49) then 'N
fullscreen = 0
exit do
end if
loop
screen 20, 32, 2, fullscreen
work.page = 0:show.page = 1
screenset work.page, show.page
for rot = 0 to 25
if rot = 25 then rot = 0
cls
getmouse mx,my
x = mx - 512
x = (x / 256)
y = my - 384
y = (y / 192)
for r = 0 to 300 step 50
for deg = 0 to 360 step 12
line (cos((deg+rot)*r2d)*r*x+502, sin((deg+rot)*r2d)*r*y+379)-(cos((deg+rot)*r2d)*r*x+522, sin((deg+rot)*r2d)*r*y+389),rgb(0,0,255),b
line (cos((360-(deg+rot))*r2d)*(r+25)*x+502, sin((360-(deg+rot))*r2d)*(r+25)*y+379)-(cos((360-(deg+rot))*r2d)*(r+25)*x+522, sin((360-(deg+rot))*r2d)*(r+25)*y+389),rgb(255,0,0),b
next deg
next r
wt = timer + .01
if multikey(33) then 'if 'F' is pressed, then switch fullscreen/windowed
fullscreen = (fullscreen -1) * -1 'if 0 then 1 if 1 then 0
screen 20, 32, 2, fullscreen
end if
swap work.page, show.page
screenset work.page, show.page
do
i$ = inkey$
loop while wt > timer
if multikey(1) then end 'exit on esc
next rot
end