Nice set of smiles here indeed...lol
Umm...I dont use Screensync cause...its falable...so I came up with a simple algo, you might want it for future reference if you just hate those flickers...not kidding works so much better than Screensync...even included a target FPS support...you can take that out easily if you wish:
'Needs at least 2 Virtual Screen pages
'Set Screen here
'FPS
Const FPS = 30
'Timei is TIMER var
Dim As Double Timei, SecondsPerFrame
'How long each frame should take to be rendered
SecondsPerFrame = 1 / FPS
'Set up virtual vars
Dim As Integer Viewpage = 0, Workpage = 1
Screenset Workpage, Viewpage
Do
Timei = Timer
DrawScene
ProcessInput
UpdateScene
Flip Workpage, Viewpage
Do: Sleep 1: Loop While Timer - Timei <= SecondsPerFrame
EraseScene
Loop Until SomeCondition
If you dont want the target FPS support then just take out the "Do: Sleep 1: Loop while Timer - Timei <= SecondsPerFrame" line
You can see it in action here with a small demo I made, just unREM the lines in the main loop if you wish to have it targetting the FPS again:
'Needs at least 2 Virtual Screen pages
Screen 19, 32, 2
DefInt A-Z
Option Explicit
Randomize Timer
'FPS
Const FPS = 30
Const SCRX = 800
Const SCRY = 600
Type Col_Type
RR As Integer
GG As Integer
BB As Integer
End Type
Type _2DVector_Type
x As Integer
y As Integer
End Type
Type Ball_Type
x As Integer
y As Integer
OldX As Integer
OldY As Integer
R As Integer
Col As Col_Type
Vector As _2DVector_Type
End Type
Declare Function RandomInt(High As Integer, Low As Integer)
'Note this is a basic example, I was gonna do stuff more complex, but decided not, so please dont pick at my inefficencys ;-)
ReDim Shared As Ball_Type Balls(0)
'Set Up First Ball
Balls(0).R = RandomInt(50,10)
Balls(0).x = RandomInt((SCRX - Balls(0).R), Balls(0).R)
Balls(0).y = RandomInt((SCRY - Balls(0).R), Balls(0).R)
Balls(0).Col.RR = RandomInt(255,30)
Balls(0).Col.GG = RandomInt(255,30)
Balls(0).Col.BB = RandomInt(255,30)
Balls(0).Vector.x = RandomInt(3, -3)
Balls(0).Vector.y = RandomInt(3, -3)
If Balls(0).Vector.x = 0 And Balls(0).Vector.y = 0 Then Balls(0).Vector.x = 2: Balls(0).Vector.y = RandomInt(3, -3)
'Timei is TIMER var
Dim As Double Timei, SecondsPerFrame
'How long each frame should take to be rendered
SecondsPerFrame = 1 / FPS
'Set up virtual vars
Dim As Integer Viewpage = 0, Workpage = 1
Declare Function DrawScene()
Declare Function ProcessInput()
Declare Function UpdateScene()
Declare Function EraseScene()
Declare Function AddBall()
'Calc FPS
Dim FrameCount As Integer
Dim FPSTimei As Double
FrameCount = 0
Screenset Workpage, Viewpage
FPSTimei = Timer
Do
'Timei = Timer
DrawScene
ProcessInput
UpdateScene
Flip Workpage, Viewpage
'Do: Sleep 1: Loop While Timer - Timei <= SecondsPerFrame
EraseScene
'FrameCount += 1
'If Timer - FPSTimei >= 1 Then FPSTimei = Timer: WindowTitle "FPS: " & FrameCount: FrameCount = 1
Loop While Not Multikey(&h1)
Function ProcessInput()
Dim As Integer MX, MY, MB
GetMouse MX, MY, ,MB
If MB And 1 Then AddBall()
End Function
Function UpdateScene()
Dim AS Integer i
For i = LBound(Balls) To UBound(Balls)
Balls(i).x += Balls(i).Vector.x
Balls(i).y += Balls(i).Vector.y
If Balls(i).x + Balls(i).R >= SCRX Then Balls(i).x = SCRX - Balls(i).R: Balls(i).Vector.x *= -1
If Balls(i).y + Balls(i).R >= SCRY Then Balls(i).y = SCRY - Balls(i).R: Balls(i).Vector.y *= -1
If Balls(i).x - Balls(i).R <= 0 Then Balls(i).x = Balls(i).R: Balls(i).Vector.x *= -1
If Balls(i).y - Balls(i).R <= 0 Then Balls(i).y = Balls(i).R: Balls(i).Vector.y *= -1
Next i
End Function
Function DrawScene()
Dim As Integer i
For i = LBound(Balls) To UBound(Balls)
Circle(Balls(i).x, Balls(i).y), Balls(i).R, RGB(Balls(i).Col.RR, Balls(i).Col.GG, Balls(i).Col.BB),,,,F
Balls(i).OldX = Balls(i).X
Balls(i).OldY = Balls(i).Y
Next i
End Function
Function EraseScene()
Dim As Integer i
For i = LBound(Balls) To UBound(Balls)
Circle(Balls(i).OldX, Balls(i).OldY), Balls(i).R, RGB(0,0,0),,,,F
Next i
End Function
Function AddBall()
Dim As Integer i
'Preserve
ReDim Temp_Balls(LBound(Balls) To UBound(Balls)) As Ball_Type
For i = LBound(Balls) To Ubound(Balls)
Temp_Balls(i) = Balls(i)
Next i
ReDim Balls(LBound(Temp_Balls) To (Ubound(Temp_Balls) + 1)) As Ball_Type
For i = LBound(Temp_Balls) To UBound(Temp_Balls)
Balls(i) = Temp_Balls(i)
Next i
Balls(UBound(Balls)).R = RandomInt(50,10)
Balls(UBound(Balls)).x = RandomInt((SCRX - Balls(UBound(Balls)).R), Balls(UBound(Balls)).R)
Balls(UBound(Balls)).y = RandomInt((SCRY - Balls(UBound(Balls)).R), Balls(UBound(Balls)).R)
Balls(UBound(Balls)).Col.RR = RandomInt(255,30)
Balls(UBound(Balls)).Col.GG = RandomInt(255,30)
Balls(UBound(Balls)).Col.BB = RandomInt(255,30)
Balls(UBound(Balls)).Vector.x = RandomInt(3, -3)
Balls(UBound(Balls)).Vector.y = RandomInt(3, -3)
If Balls(UBound(Balls)).Vector.x = 0 And Balls(UBound(Balls)).Vector.y = 0 Then Balls(UBound(Balls)).Vector.x = 2: Balls(UBound(Balls)).Vector.y = RandomInt(3, -3)
End Function
Function RandomInt(High As Integer, Low As Integer)
RandomInt = Int(Rnd * (High - Low + 1) + Low)
End Function
Well, thats all, Happy coding,
Matt