Posts: 7
Threads: 3
Joined: Dec 2004
Code:
SUB ball
FOR a = 350 TO 550 STEP 1
FOR b = 375 TO 283 STEP 1
CIRCLE (a, b), 10, 4
PAINT (a, b), 4, 4
FOR delay = 1 TO 7500
NEXT delay
CIRCLE (a, b), 10, 0
PAINT (a, b), 0, 0
NEXT b
NEXT a
END SUB
I've never been able to figure this out. How can I make these for nexts work like they are? I want a ball to be shot and go though a hoop and and have curve so I thought this would work (but it didn't)
Posts: 121
Threads: 20
Joined: Sep 2004
The b FOR-NEXT needs to be STEP -1 as it's going down.
8% of the teenage population smokes or has smoked pot. If you're one of the 2% who hasn't, copy and paste this in your signature.
Posts: 7
Threads: 3
Joined: Dec 2004
The code doesn't work for me. Nothing happens. It will run but you can't see anything. When I REM out the b part it will move straight across the screen. When I REM out the a part, nothing happens...
Posts: 121
Threads: 20
Joined: Sep 2004
as I said, FOR b = 375 TO 283 STEP 1 needs to be FOR b = 375 TO 283 STEP -1
otherwise qbasic just skips the for-next as it has an invalid step.
However, after testing your program I noticed it won't do what you want anyway. it'll rise up, then go down and move along a pixel then rise up again. You'll need some sort of formula to get the curve (or two for-next loops).
8% of the teenage population smokes or has smoked pot. If you're one of the 2% who hasn't, copy and paste this in your signature.