I added the link as it really helped me with understanding your translation to SpiderBasic. I have come from a BASIC that is far away and I thought the link may help other newcomers. This is a really fascinating and flexible language.
I haven't had any problems with your code on 1.3 Free - it has been very interesting to play with SpiderBasic. Just to begin to understand it more I have changed lots of the code but it has exactly the same core elements. It would be interesting to hear if this runs on your system. Please understand that this is my first attempt at SpiderBasic coding and so it may not be very elegant! With all the Random elements the display could take a little time to become as interesting as the original..
Code: Select all
;*****************************************************************************
;*
;* Name : Dots
;* Author : Petr Vavrin (peterb)
;* Date : 15.06.09
;* Notes : http://www.purebasic.fr/english/viewtopic.php?f=12&t=37609&start=64
;*
;* Adaptation SpiderBasic Comtois , le 28/02/16
;* Adaptation SpiderBasic ChrisM , on 31/03/16 1.3 Free Win10 Firefox 45.0.1
;*****************************************************************************
Enumeration Sprites
#sBox
#sDot
EndEnumeration
Macro SinCos(a,b)
(Sin(a)+Cos(b))
EndMacro
Global Dim x(20)
Global Dim y(20)
Global Dim v.f(20)
Global Dim w(20)
Global WinX =600
Global WinY =600
Global SpriteX =WinX/10
Global SpriteY =WinY/10
Global SpriteR =SpriteX/2
Global Sprite
Global SpriteNo =1
Global TrailCount =20
Global Fade =255/(TrailCount-1)
Global Angle =(360/SpriteNo)
Global Speed =5
Global Gap.f =Speed*0.00025
Global Radians.f =#PI/180
InitSprite()
EnableJS
document.title = "Boxes & Dots"
DisableJS
OpenWindow(0,0,0,WinX,WinY,"Boxes & Dots",#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0),0,0,WinX,WinY,1,0,0,#PB_Screen_WaitSynchronization)
ClearScreen(RGB(255, 0, 0))
CreateSprite(#sBox,SpriteX,SpriteY,#PB_Sprite_AlphaBlending) ;Draw Box Sprite
StartDrawing(SpriteOutput(#sBox))
Box(0,0,SpriteX,SpriteY, RGB(255,255,255)) ; white outline
Box(1,1,SpriteX-2,SpriteY-2, RGB(255,0,0)) ; red square
StopDrawing()
CreateSprite(#sDot,SpriteX,SpriteY,#PB_Sprite_AlphaBlending) ;Draw Dot Sprite
StartDrawing(SpriteOutput(#sDot))
Circle(SpriteR,SpriteR,SpriteR, RGB(255,255,255)) ; white outline
Circle(SpriteR,SpriteR,SpriteR-1, RGB(255,0,0)) ; white circle
StopDrawing()
FlipBuffers() ; start the rendering
Procedure RenderFrame()
Static.f a,b,c,e,f,Rotation,i
Static h=99,k=99,s.f=20
Static RandomSprite=#sBox
Select Random(2000) ; random change of background colour
Case 10
ClearScreen(RGB(248, 248, 248))
Case 20
ClearScreen(RGB(255, 0, 0))
EndSelect
If h=k
Select Random(1,10) ; random change of drawing parameters
Case 1,7
e=Random(k):f=Random(k):Rotation=Random(k)
Case 2
e=90:f=40:Rotation=40
Case 3
e=10:f=40:Rotation=60
Case 4
e=70:f=70:Rotation=70
Case 5
e=120:f=90:Rotation=30
Case 6
e=30:f=10:Rotation=10
EndSelect
If Random(1)=1 ; random change to reverse the rotation
Rotation=-Rotation
EndIf
i=s-Random((WinX+WinY)/6)
h=0
EndIf
h+1
a+Gap*e
b+Gap*f
c+Gap*Rotation
s-i/k
x(0)=(WinX-SpriteX)/4.5+SinCos(a,b)*60
y(0)=(WinY-SpriteY)/2+SinCos(b,a)*60
v(0)=c
w(0)=s
For Layer=TrailCount To 0 Step -1
x(Layer)=x(Layer-1)
y(Layer)=y(Layer-1)
v(Layer)=v(Layer-1)
w(Layer)=w(Layer-1)
If Random(20000)=1 And SpriteNo<9 ;increase sprites up to 8 total
SpriteNo+1
EndIf
If Random(20000)=1 And SpriteNo>1 ;decrease sprites down to 1 minimum
SpriteNo-1
EndIf
If Random(10000)=1 And RandomSprite=#sBox ;change Sprite to render
RandomSprite=#sDot
EndIf
If Random(10000)=1 And RandomSprite=#sDot
RandomSprite=#sBox
EndIf
Angle=(360/SpriteNo)
For Sprite=1 To SpriteNo
t.f=Sprite*Angle*Radians+v(Layer)
u.f=Radians-v
DisplayTransparentSprite(RandomSprite,x(Layer)+SinCos(t,u)*w(Layer),y(Layer)+SinCos(u,t)*w(Layer),255-(Layer*Fade))
Next Sprite
Next Layer
FlipBuffers() ; continue the rendering
EndProcedure
BindEvent(#PB_Event_RenderFrame, @RenderFrame())