Hehehe... cool stuff. :) It reminds me of something I made for a game a while back. I had to add in the op overloading & stuff directly in the file... so it's kinda huge for such a simple demo. :p
Code: Select all
#include "fbgfx.bi"
const pi=3.1415926, pi2 = pi*2
type vec2f
x as single
y as single
declare constructor ()
declare constructor ( byval x as single, byval y as single )
declare function distance( byref v as vec2f ) as single
end type
constructor vec2f ()
end constructor
constructor vec2f ( byval x as single, byval y as single )
this.x = x
this.y = y
end constructor
function vec2f.distance( byref v as vec2f ) as single
return sqr((v.x - this.x)^2 + (v.y - this.y)^2)
end function
operator + ( byref lhs as vec2f, byref rhs as vec2f ) as vec2f
return type<vec2f>( lhs.x + rhs.x, lhs.y + rhs.y )
end operator
operator - ( byref lhs as vec2f, byref rhs as vec2f ) as vec2f
return type<vec2f>( lhs.x - rhs.x, lhs.y - rhs.y )
end operator
operator * ( byref lhs as vec2f, byref rhs as single ) as vec2f
return type<vec2f>( lhs.x * rhs, lhs.y * rhs )
end operator
operator / ( byref lhs as vec2f, byref rhs as single ) as vec2f
return type<vec2f>(lhs.x / rhs, lhs.y / rhs)
end operator
screenres 640,480,32,1,FB.GFX_ALPHA_PRIMITIVES
type lstruct
a as single
p as vec2f
end type
dim as single radius = 5
dim as vec2f posit = vec2f(320f,240f)
dim as double this_time
dim as lstruct rpoint(1 to 20, 1 to 10)
do
this_time = timer
screenlock
cls
radius = 150+140*sin(this_time)
for i as integer = 1 to 20
dim as single rangle = rnd*pi2
rpoint(i,1).a = rangle
rpoint(i,1).p = posit + vec2f(radius/5*sin(rangle), radius/5*cos(rangle) )
for r as integer = 2 to 10
dim as single nr = radius/10
rangle = rpoint(i,r-1).a -.75+rnd*1.5
rpoint(i,r).a = rangle
rpoint(i,r).p = rpoint(i,r-1).p + vec2f(nr*sin(rangle), nr*cos(rangle) )
dim as single bcheck = ((rpoint(i,r).p.y - posit.y)^2) + ((rpoint(i,r).p.x - posit.x)^2)
if bcheck>radius^2 or r = 10 then
dim as single dist = rpoint(i,r).p.Distance(posit)
rpoint(i,r).p = posit + ( rpoint(i,r).p - posit ) / dist * radius
end if
next
next
for i as integer = radius to radius/5 step -1
circle(posit.x, posit.y), i, rgb(0,0,255-(255*((i-1)/radius))),,,,f
next
circle(posit.x, posit.y),radius/5,rgb(0,0,0),,,,f
dim as integer c
for i as integer = 1 to 20
for r as integer = 2 to 10
c = 255-(255*(r/10))
line(rpoint(i,r-1).p.x, rpoint(i,r-1).p.y)-(rpoint(i,r).p.x, rpoint(i,r).p.y),rgba(255,255,0,c)
next
next
screensync
screenunlock
sleep 3,1
loop until multikey(fb.sc_escape)
sleep