Now you should have this code:
sync on
make object box 1,1,1,3
color object 1,rgb(255,0,0)
make object box 2,1,1,3
color object 2,rgb(0,255,0)
make object sphere 3,1
color object 3,rgb(0,0,50)
do
IF upkey()=1 and player1pos#<5 then player1pos#=player1pos#+0.5
IF downkey()=1 and player1pos#>-5 then player1pos#=player1pos#-0.5
IF keystate(17)=1 and player2pos#<5 then player2pos#=player2pos#+0.5
IF keystate(31)=1 and player2pos#>-5 then player2pos#=player2pos#-0.5
position object 1,5,0,player1pos#
position object 2,-5,0,player2pos#
position camera 0,10,-10
point camera 0,0,0
sync
loop
You should be able to smoothly move each paddle independantly.
Before we continue, it would be good to tidy up the code a bit.
A colon (===> : ) can be used to put two pieces of code on the same line to save space.
make object box 1,1,1,3
color object 1,rgb(255,0,0)
make object box 2,1,1,3
color object 2,rgb(0,255,0)
make object sphere 3,1
color object 3,rgb(0,0,50)
becomes:
make object box 1,1,1,3:color object 1,rgb(255,0,0)
make object box 2,1,1,3:color object 2,rgb(0,255,0)
make object sphere 3,1:color object 3,rgb(0,0,50)
We know that this piece of code works, and we don't need to change it, so we can compress it up so that it doesn't confuse us.
Do this with the rest of the code and you may get something like this:-
hide mouse
make object box 1,1,1,3:color object 1,rgb(255,0,0)
make object box 2,1,1,3:color object 2,rgb(0,255,0)
make object sphere 3,1:color object 3,rgb(0,0,50)
sync on:do
IF upkey()=1 and player1pos#<5 then player1pos#=player1pos#+0.5
IF downkey()=1 and player1pos#>-5 then player1pos#=player1pos#-0.5
IF keystate(17)=1 and player2pos#<5 then player2pos#=player2pos#+0.5
IF keystate(31)=1 and player2pos#>-5 then player2pos#=player2pos#-0.5
position object 1,5,0,player1pos#:position object 2,-5,0,player2pos#
position camera 0,10,-10:point camera 0,0,0
sync:loop
It will still run exactly the same as the spaced out code. I have moved the
sync on to just infront of the main loop. I have also added
hide mouse at the beginning.
REMEMBER:
You can't have two IF....THEN commands on the same line