|
Post by badger on Jan 23, 2024 21:01:31 GMT
Hello
i am getting a syntax error in line 111 i cant see it. I am hope someone here can.
thanks in advance
SCREEN 12 ' Set graphics mode (VGA 640x480)
CONST NUM_PICKS = 6
CONST MAX_NUMBER = 80
TYPE Ball
x AS INTEGER
y AS INTEGER
radius AS INTEGER
color AS INTEGER
velocity AS INTEGER
number AS INTEGER
END TYPE
DIM SHARED balls(NUM_PICKS) AS Ball
RANDOMIZE TIMER
' Initialize balls with unique numbers
DIM pickedNumbers(MAX_NUMBER + 1) AS INTEGER
FOR i = 1 TO NUM_PICKS
DO
balls(i).number = INT(RND * (MAX_NUMBER + 1))
LOOP UNTIL pickedNumbers(balls(i).number) = 0
pickedNumbers(balls(i).number) = 1
balls(i).x = INT(RND * (640 - 2 * balls(i).radius)) + balls(i).radius
balls(i).y = INT(RND * (480 - 2 * balls(i).radius)) + balls(i).radius
balls(i).radius = 20
balls(i).color = INT(RND * 15) + 1
balls(i).velocity = 1
NEXT i
' Main game loop
DO
CLS
' Draw and move balls
FOR i = 1 TO NUM_PICKS
DRAWBALL balls(i)
MOVEBALL balls(i)
' Check if ball is out of screen and reset its position
IF balls(i).y > 480 - balls(i).radius OR balls(i).y < balls(i).radius THEN
balls(i).y = INT(RND * (480 - 2 * balls(i).radius)) + balls(i).radius
END IF
NEXT i
SLEEP 16
LOOP UNTIL INKEY$ <> ""
SCREEN 0 ' Return to text mode
SUB DRAWBALL (ball AS Ball)
CIRCLE (ball.x, ball.y), ball.radius, ball.color, , , , FILL
PRINT USING "###"; ball.number; (ball.x - 10, ball.y - 10)
END SUB
SUB MOVEBALL (ball AS Ball)
ball.y = ball.y + ball.velocity
END SUB
|
|
dbox
Junior Member
Posts: 84
|
Post by dbox on Jan 23, 2024 21:13:17 GMT
Looks like there are too many arguments that you are trying to pass to the Circle command. QB64 does not have a native filled circle option.
You might consider using _Limit instead of sleep to control the speed of your loop:
SCREEN 12 ' Set graphics mode (VGA 640x480)
CONST NUM_PICKS = 6 CONST MAX_NUMBER = 80
TYPE Ball x AS INTEGER y AS INTEGER radius AS INTEGER color AS INTEGER velocity AS INTEGER number AS INTEGER END TYPE
DIM SHARED balls(NUM_PICKS) AS Ball
RANDOMIZE TIMER
' Initialize balls with unique numbers DIM pickedNumbers(MAX_NUMBER + 1) AS INTEGER FOR i = 1 TO NUM_PICKS DO balls(i).number = INT(RND * (MAX_NUMBER + 1)) LOOP UNTIL pickedNumbers(balls(i).number) = 0 pickedNumbers(balls(i).number) = 1
balls(i).x = INT(RND * (640 - 2 * balls(i).radius)) + balls(i).radius balls(i).y = INT(RND * (480 - 2 * balls(i).radius)) + balls(i).radius balls(i).radius = 20 balls(i).color = INT(RND * 15) + 1 balls(i).velocity = 1 NEXT i
' Main game loop DO CLS
' Draw and move balls FOR i = 1 TO NUM_PICKS DRAWBALL balls(i) MOVEBALL balls(i)
' Check if ball is out of screen and reset its position IF balls(i).y > 480 - balls(i).radius OR balls(i).y < balls(i).radius THEN balls(i).y = INT(RND * (480 - 2 * balls(i).radius)) + balls(i).radius END IF NEXT i
'SLEEP 16 _Limit 60
LOOP UNTIL INKEY$ <> ""
SCREEN 0 ' Return to text mode
SUB DRAWBALL (ball AS Ball) CIRCLE (ball.x, ball.y), ball.radius, ball.color', , , , FILL 'PRINT USING "###"; ball.number; (ball.x - 10, ball.y - 10) END SUB
SUB MOVEBALL (ball AS Ball) ball.y = ball.y + ball.velocity END SUB
(Also, if you paste your code in on the BBCode tab when you are editing your post, it won't add those additional spaces to your code.)
|
|
|
Post by bplus on Jan 23, 2024 22:16:11 GMT
Here is my mod: shows how to fill a circle, draw a proper label without the back color, make the bouncing balls a little more interesting.
Screen 12 ' Set graphics mode (VGA 640x480) Randomize Timer _PrintMode _KeepBackground ' so numbers don't look label maker made
Const NUM_PICKS = 6
Const MAX_NUMBER = 80
Type Ball
x As Integer
y As Integer
radius As Integer
color As Integer
velocity As Integer
number As Integer
End Type
Dim Shared balls(NUM_PICKS) As Ball
Randomize Timer
' Initialize balls with unique numbers
Dim pickedNumbers(MAX_NUMBER + 1) As Integer
For i = 1 To NUM_PICKS
Do
balls(i).number = Int(Rnd * (MAX_NUMBER + 1))
Loop Until pickedNumbers(balls(i).number) = 0
pickedNumbers(balls(i).number) = 1
balls(i).x = Int(Rnd * (640 - 2 * balls(i).radius)) + balls(i).radius
balls(i).y = Int(Rnd * (480 - 2 * balls(i).radius)) + balls(i).radius
balls(i).radius = 20
balls(i).color = Int(Rnd * 7) + 1
balls(i).velocity = Rnd * 3 + .5
Next i
' Main game loop
Do
Cls
' Draw and move balls
For i = 1 To NUM_PICKS
DRAWBALL balls(i)
MOVEBALL balls(i)
' Check if ball is out of screen and reset its position
If balls(i).y > 480 - balls(i).radius Or balls(i).y < balls(i).radius Then
balls(i).velocity = -balls(i).velocity If balls(i).y + balls(i).radius > 480 Then balls(i).y = 479 - balls(i).radius If balls(i).y - balls(i).radius < 0 Then balls(i).y = balls(i).radius End If
Next i
_Display _Limit 60 'Sleep 16 Yikes!
Loop Until InKey$ <> ""
Screen 0 ' Return to text mode
Sub DRAWBALL (ball As Ball) For r = 1 To ball.radius Step .25 Circle (ball.x, ball.y), r, ball.color Next _PrintString (ball.x - 16, ball.y - 8), Right$(" " + _Trim$(Str$(ball.number)), 3)
End Sub
Sub MOVEBALL (ball As Ball)
ball.y = ball.y + ball.velocity
End Sub
|
|
|
Post by badger on Feb 16, 2024 0:14:42 GMT
Hello
thanks for your reply. Soor for the lag in communications i had back surgery and still not getting around like i should.
Badger
|
|