Ok, don't take offense. The code is a mess and I don't have time to correct it, but, I have a fully function 3d pong game that deals with all of the issues you need, so I am posting the entire code here. I suggest you use it to restructure/rewrite you code. Hope this helps you.
Rem Project: Pong
Rem Created: 10/24/2003 09:25:25
Rem Programmer: James B. (Cattle Rustler)
Rem ***** Main Source File *****
`\Global Variables
intScore1 as integer
intScore2 as integer
fltPaddleSpeed as float = .07
fltBallX as float = .05
fltBallY as float
gosub _InitScreen
gosub _InitGameData
gosub _UpdateDisplay
gosub _EndGame
fltBallY=GetRandomY()
`\MAIN LOOP --------------------------------------------------------------------------------
MAIN:
DO
`\Player movement
`\Left Player (1)
if keystate(30)=1 and object position y(2) < 3.25
position object 2, object position x(2),object position y(2)+fltPaddleSpeed,object position z(2)
endif
if keystate(44)=1 and object position y(2) > -3.25
position object 2, object position x(2),object position y(2)-fltPaddleSpeed,object position z(2)
endif
`\Right Player (2)
if upkey() = 1 and object position y(3) < 3.25
position object 3, object position x(3),object position y(3)+fltPaddleSpeed,object position z(3)
endif
if downkey() = 1 and object position y(3) > -3.25
position object 3, object position x(3),object position y(3)-fltPaddleSpeed,object position z(3)
endif
`\Ball Movement
position object 1, object position x(1)+fltBallX,object position y(1)+fltBallY,object position z(1)
`\Detect Paddle collisions (obj 2-3)
if object collision(1,0) > 1 and object collision(1,0) < 4
play sound 1
fltBallX=fltBallX * -1
fltBallY=GetRandomY()
endif
`\detect wall collisions (obj 4-5)
if object collision(1,0) >= 4 and object collision(1,0) < 6
fltBallY=fltBallY * -1
endif
`\SCORING
`\ball gets past left player
if object position x(1) < object position x(2)
hide object 1 : sync
inc intScore2
gosub _UpdateDisplay
gosub _Flip
fltBallY=GetRandomY()
endif
`\ball gets past right player
if object position x(1) > object position x(3)
hide object 1 : sync
inc intScore1
gosub _UpdateDisplay
gosub _Flip
fltBallY=GetRandomY()
endif
`\check if winner exists
if intScore1=11 or intScore2=11 then gosub _EndGame
`\poll for Quit game
if escapekey() = 1 then end
`\pause
if controlkey()=1 then wait key
`\refresh display and restart main loop
gosub _UpdateDisplay
sync
LOOP
RETURN
`\END MAIN LOOP------------------------------------------------------------------------------
`\SUBS & FUNCTIONS---------------------------------------------------------------------------
Function GetRandomY()
`\return numbers between -.05 and +.05 in increments of .01 (including 0)
local intTemp as integer
local fltRNDY as float
randomize timer()
intTemp=rnd(10)-5
fltRNDY=intTemp/100.0
EndFunction fltRNDY
_EndGame:
`\ask for new game or quit
gosub _StartMessage
wait key
if spacekey()=1
intScore1=0
intScore2=0
gosub _CenterPlayers
gosub _UpdateDisplay
gosub MAIN
else
end
endif
Return
_CenterPlayers:
`\
position object 2,-4.5,0,0
position object 3,4.5,0,0
Return
_Flip:
`\ball got past a player, pause, reset ball, continue game
position object 1,0,0,0
gosub _CenterPlayers
show object 1 : sync
gosub _UpdateDisplay
wait 100
sync
gosub _UpdateDisplay
wait 1900
Return
_UpdateDisplay:
`\update scores on screen
set cursor (screen width()/2)-18, 0
print str$(intScore1);" - ";str$(intScore2)
RETURN
_StartMessage:
`\wait for user to play again or quit
set cursor (screen width()/2)-120,400
print "Spacebar to start, Any key to Quit"
sync
RETURN
_InitScreen:
`\initialize screen & window
set window size 1024,768
set window title "PONG - By CattleRustler (James B.)"
set window on
maximize window
hide mouse
sync off
color backdrop 0,0
autocam off
Return
_InitGameData:
`\ball
make object box 1,.2,.2,.01
position object 1,0,0,0
`\player objects
make object box 2,.2,1,.01
make object box 3,.2,1,.01
gosub _CenterPlayers
`\wall objects
`\upper
make object box 4,9,.02,.01
position object 4,0,3.8,0
`\lower
make object box 5,9,.02,.01
position object 5,0,-3.8,0
`\middle divider
make object box 6,.02,7.65,.01
position object 6,0,0,.05
`\camera
position camera 0,0,-7
`\sync settings
sync on
sync rate 100
sync
`\text settings
set text size 20
set text to bold
`\audio objects
load sound "paddle.wav",1
`\Setup Collision
set object collision on 1
set object collision on 2
set object collision on 3
set object collision on 4
set object collision on 5
Return
`\End SUBS & FUNCTIONS ------------------------------------------------------------------------------
Edit: you can paste this code into a dbp project and run it, just rem out references to PLAY SOUND, LOAD SOUND
-RUST-
"What the... Mooooooooooo!"