Timthepig,
Again, I say that the
FOR NEXT loop is creating a non smooth motion, due to the screen not being refreshed after each loop within it. The way you have your program set up above, the ball motion will be very fast and very jerky, and could possibly be what is making the program to run slow. Also, you have included a
WAIT command in the midst of the
FOR NEXT loop for a reason that I do not understand. This will make your program to seem as if it is running slow, because it literally keeps
ANY code from being processed for the time specified.
Let's say that the
FOR NEXT is to loop five times upon each execution of it. Let's also say that your ball is supposed to move 1.50 units each loop. The total movement of the ball, at the ending of the
FOR NEXT loop, would be 7.50 units.
Since you are not using the
SYNC command within the
FOR NEXT loop to update your screen each loop, you will see the ball to move 7.50 units each program loop. Let me clarify, by saying that at screen refresh
A, your ball could be at 0 units. At screen refresh
B, your ball will be 7.50 units away from where it originally was at the last screen refresh.
In the code below, let's say that #max(which should be
max# because it is not processed as a
real number variable until the pound sign is placed after it;same goes for #ballkick) = 5 and #ballkick = 1.50.
Do
If spacekey()=1
For kick=0 to #max
wait (1),
move object 10, #ballkick
next kick
EndIf
Sync
Loop
Let's say that object 10 is at 0 units, initially. When the screen is refreshed, which in this code it is not within the
FOR NEXT loop, object 10 will be 7.50 units away from where it was. At one moment you will see the object at 0 units, and the next moment it will be 7.50 units away from 0. This is where your jerky movement is coming from. That every time you press the spacekey, your ball is
translated 7.50 units away from where it was before you pressed the spacekey. In this, you are not seeing it move 1.50 by 1.50 units each time the screen refreshes.
If you wish to keep the
FOR NEXT loop, then simply place the
SYNC command inside the
FOR NEXT loop at the end of the code it loops.
Do
If spacekey()=1
For kick=0 to #max
wait (1),
move object 10, #ballkick
sync
next kick
EndIf
Sync
Loop
I believe I answered your question correctly. However, you did not understand what I explained.
+NanoBrain+