Revised version of Follow Me (alias Atan Egg) with 3d shading effect.
$ filename "t.exe"
'#include "../../inc/RTL32.inc"
'#include "../../inc/RTL64.inc"
include "win64.inc"
Window "Follow Me",640,480,2
sys_mode=4
Function Min(single a, b) as single
iF a <= b
Return a
Else
Return b
End iF
End Function
Function Max(single a, b) as single
iF a >= b
Return a
Else
Return b
End iF
End Function
declare Polygon lib "GDI32.dll" (sys hdc,int *lpPoints, nCount) as bool
sub rotranz(int *p,rd,px,py)
single r=hypot(p[0],p[1])
single a=atan(p[1],p[0])
a+=rad(rd)
p[0]=cos(a)*r+px
p[1]=sin(a)*r+py
end sub
sub oval2(int px,py,rx,ry,r,g,b,rd,rs)
static int p[6]
static single a1,a2
static sys c,i,iBrush,iPen
c=b*0x10000+g*0x100+r
iBrush = CreateSolidBrush c
iPen=CreatePen -1,-1,c
SelectObject bHdc, iBrush
SelectObject bHdc, iPen
a1=0
for i=0 to <360 step rs
a2=rad(i+rs)
p[0]=px
p[1]=py
p[2]=cos(a1)*rx
p[3]=sin(a1)*ry
p[4]=cos(a2)*rx
p[5]=sin(a2)*ry
rotranZ p[2],rd,px,py
rotranZ p[4],rd,px,py
polygon bHdc,p,3
a1=a2
next
DeleteObject iBrush
DeleteObject iPen
end sub
sub crystal(int px,py,rx,ry,r,g,b,rd,rs)
static int p[6]
static single a1,a2
static sys c,d,e,i,iBrush,iPen,li
a1=rad(rd)
p[0]=px
e=rd+360
for i=rd to <e step rs
d=i+rs
if d>=360 then d-=360
a2=rad(d)
li=127*sin((a1+a2)*.5)
li=127*sin(a1)
if li<0 then li=0
p[2]=sin(a1)*rx+px
p[3]=py
p[4]=sin(a2)*rx+px
p[5]=py
if not (d>180) and (d<270) then
c=(b+li)*0x10000 or (g+li)*0x100 or r+li 'directional shading
iBrush = CreateSolidBrush c
iPen=CreatePen -1,-1,c
SelectObject bHdc, iBrush
SelectObject bHdc, iPen
p[1]=py-ry
polygon bHdc,p,3
DeleteObject iBrush
DeleteObject iPen
p[1]=py+ry
c=(b+li)*0x10000 + (g+li)*0x100 + ((r+li)*.75) 'lower shaded
iBrush = CreateSolidBrush c
iPen=CreatePen -1,-1,c
SelectObject bHdc, iBrush
SelectObject bHdc, iPen
polygon bHdc,p,3
DeleteObject iBrush
DeleteObject iPen
end if
a1=a2
next
end sub
single x, y, rot, vel, tx, ty
single dx, dy, angle, dist, da
sys spin
While WinExit=0
if key(27) then exit do
ClsColor 0xcf,0x8c,0xc8
tx = xMouse
ty = yMouse
dx = tx-x
dy = ty-y
dist = Sqr(dx*dx+dy*dy)
angle = ATan (ty-y, tx-x)
da = angle-rot
da = ATan(Sin(da),Cos(da))
vel = Min (1, dist/100.0)
Rot=rot + da *vel *.1
x=x + Cos(rot) *vel *5
y=y + Sin(rot) *vel *5
'
'Oval x-5, y-5, 20, 30, 255,0,0
'Oval2 x-5, y-5, 40, 60, 255,0,0,spin,15
Crystal x-5, y-5, 60, 60, 127, 60, 100, spin, 20
'
spin+=1 : if spin>360 then spin-=360
Events
FlipBuffer
WaitFor 60
Wend
WinEnd
Charles