Looks like it should be easy - DB is a BASIC language, so most of the commands work already.
Few things to note - DBC does not support types, you're only allowed integer, real, and String variables. Constants are unsupported, you'd have to define that either as a variable
, or as a global variable/array
Dim Rad(0) : Rad(0) = 300
Most importantly, DBC needs a main program loop - it isn't based around procedures, though your Private Sub declarations look like DB subroutines. So you need:
Sync On
Do
rem YOUR COMMANDS GO HERE
If Mouseclick() = 1 : rem Leftmouse button pressed
Balls = Balls + 1
Xp(Balls) = x
Yp(Balls) = Y
Clr(Balls) = Rnd * vbWhite
endif
rem Don't understand this bit, not sure what triggers it
rem I assume you update every (say) 1000ms
If timerVar + 1000 < Timer()
GoSub Timer1_Timer
timervar = Timer()
endif
Sync
Loop
rem your Timer1 Subroutine
Timer1_Timer:
For x = 0 To Balls
Yp(x) = Yp(x) + 45
If Yp(x) > ScaleHeight - Rad Then Yp(x) = ScaleHeight - Rad
If Xp(x) < Rad Then Xp(x) = Rad
If Xp(x) > ScaleWidth - Rad Then Xp(x) = ScaleWidth - Rad
For Y = 0 To Balls
If Y <> x Then
If ((Xp(x) - Xp(Y)) ^ 2 + (Yp(x) - Yp(Y)) ^ 2) < (2 * Rad) ^ 2 Then
Ang = ATan2(Yp(x) - Yp(Y), Xp(x) - Xp(Y))
Cx = (Xp(x) + Xp(Y)) / 2
Cy = (Yp(x) + Yp(Y)) / 2
Xp(x) = Cx + (Rad * Cos(Ang))
Yp(x) = Cy - (Rad * Sin(Ang))
Xp(Y) = Cx - (Rad * Cos(Ang))
Yp(Y) = Cy + (Rad * Sin(Ang))
End If
End If
Next Y
Next x
GoSub Draw
return
rem Your Draw subroutine
Draw:
Cls
For x = 0 To Balls
Circle Xp(x), Yp(x)), Rad, Clr(x)
Next x
return
Bits of this won't work directly, I can't follow all your code (don't know the first thing about VB!) but this conversion to DBC has taken me about 5 minutes to type. Hope this helps!
"I wish I was a spaceman, the fastest guy alive. I'd fly you round the universe, in Fireball XL5..."