Well since no one has choose to help, I pulled out the duct tape and taped my head and pulled a couple of late nighters...
So to all of you who read this thread and choose to ignore my plea,,,
Thanks
you've made me a better programmer.
Here is what I have so far. Works OK (at least the ball stays inside the cube. Also have a paddle to move around with the arrow keys. I intend on adding some scoring goals and some other tid bits to make this something more then it is.
If you have any comments: Keep them to yourself...I will only ignore them anyway.
Only kidding. Any comments would be nice. I've included a link to the media and source files if anyone is interested. Just follow the link below:
Rem Project: 3D Pong Game
Rem Created: 2/6/2005 11:12:44 AM
Rem ***** Main Source File *****
`basic game setup
sync on
sync rate 100
autocam off
hide mouse
` Variables to make changes to the game set up
cubeSize = 200 `quick way to change the size of the playing field
ballSize = 20 `quick way to change the size of the ball
` Variables to contol the direction of the ball
` These flags will be used to add to or subtract from the x,y,z position of the ball
` ie: if the flag is set to 1 add to the direction,
` if flag = 0 then subtract from the direction
directionX = 0
directionZ = 0
directionY = 0
` Make the game objects
load object "Media\Rooms\Room_1.x",1 `Loads the Room Cube choose from 4
scale object 1,cubeSize,cubeSize,cubeSize `Scale the Room Cube
position object 1,0,0,0 `Positions the Room Cube
set object collision to boxes 1 `Turns on collision detection
roomXsize = object size x(1) `Get the witdth of Room
roomYsize = object size y(1) `Get the height of Room
roomZsize = object size z(1) `Get depth of Room
make object sphere 100,ballSize `Makes the ball that will bounce around
position object 100,roomXsize/2,roomYsize/2,roomZsize/2
load image "Media\camo2.jpg",10
texture object 100,10
set object collision to spheres 100
load object "Media\Paddles\Paddle_1.x",2 `makes the player 1 paddle
scale object 2,150,150,25 `Scales the player 1 paddle
set object collision to boxes 2
position object 2,500,100,70
ghost object on 2,0
` Position the camera
set camera range .01,5000
`position camera 0,roomXsize-200,roomYsize/2,roomZsize/2 `This sets the camera high in the middle of the side wall
`main loop
do
`------------------------------------------------------------------------******remove*****
`Reset if the ball goes out of playing field
if inkey$() = "b"
x# = roomXsize/2
y# = roomYsize/2
z# = roomZsize/2
position object 100,x#,y#,z#
endif
if inkey$() = "p" then position object 2,500,100,150 `reset the paddle
`these are for testing only 3 stops the ball
`controls for X Movement
if inkey$() = "w" then directionX = 1
if inkey$() = "s" then directionX = 0
if inkey$() = "x" then directionX = 3
`controls for Z Movement
if inkey$() = "q" then directionZ = 1
if inkey$() = "a" then directionZ = 0
if inkey$() = "z" then directionZ = 3
`controls for Y Movement
if inkey$() = "e" then directionY = 1
if inkey$() = "d" then directionY = 0
if inkey$() = "c" then directionY = 3
`----------------------------------------------------------------******remove******
gosub _moveBall `move the ball
gosub _movePaddle_1 `move the paddle
gosub _moveCamera `move the camera
`--------------------------------------------------------------
`these are used for testing
set cursor 0,0
print "FPS: ";screen fps()
print "ball position: "; x#; ","; y#; ","; z#
`---------------------------------------------------------------
sync `update the screen
loop `end main loop
_moveBall:
` get the current positon of the ball
ox# = object position x(100)
oy# = object position y(100)
oz# = object position z(100)
`used to move the ball
`will need to write a structured ball movement routine
` may use newxvalue,newyvalue,newzvalue, these specify angle and not relitive position
if directionX = 1 then x# = x#+2:xro# = xro+2:xrotate object 100,xro#
if directionX = 0 then x# = x#-3:xro# = xro#-3:xrotate object 100,xro#
if directionY = 1 then y# = y#+3:yro# = yro#+3:yrotate object 100,yro#
if directionY = 0 then y# = y#-2:yro# = yro#-2:yrotate object 100,yro#
if directionZ = 1 then z# = z#+3:zro# = zro#+3:zrotate object 100,zro#
if directionZ = 0 then z# = z#-4:zro# = zro#-4:zrotate object 100,zro#
gosub _ballCollision1
position object 100,x#,y#,z# `moves the ball
return
_ballCollision1:
`sets the new position for the intersect object command for the walls and paddle
` and keeps the ball from going too far into wall before reversing
if directionX = 1 then nx# = x#+8 else nx# = x#-8
if directionZ = 1 then nz# = z#+8 else nz# = z#-8
if directionY = 1 then ny# = y#+8 else ny# = y#-8
`this code reverses the direct of the ball and sets the ball back to the old position
`if it hits a wall in any of the three directions
for obj=1 to 2
ballHitX = intersect object(obj,ox#,oy#,oz#,nx#,oy#,oz#)
if ballHitX => 1
x# = ox#
if directionX=1 then directionX = 0 else directionX = 1
endif
ballHitZ = intersect object(obj,ox#,oy#,oz#,ox#,oy#,nz#)
ballHitY = intersect object(obj,ox#,oy#,oz#,ox#,ny#,oz#)
if ballHitY => 1
y# = oy#
if directionY = 1 then directionY = 0 else directionY = 1
endif
if ballHitZ => 1
z# = oz#
if directionZ = 1 then directionZ = 0 else directionZ = 1
endif
next obj
return
_movePaddle_1:
opx# = object position x (2)
opy# = object position y (2)
opz# = object position z (2)
`controls for Player Paddle
if upkey()=1
paddleStopUD = 32+20
move object up 2,5
endif
if downkey()=1
paddleStopUD = -1
move object down 2,5
endif
if rightkey()=1
paddleStopLR = 64+50
move object right 2,5
endif
if leftkey()=1
paddleStopLR = -64
move object left 2,5
endif
`these will control the rotation of the paddle
if controlkey()=1
ra=ra+1
rotate object 2,ra,0,0
endif
if shiftkey() = 1
ra=ra-1
rotate object 2,ra,0,0
endif
gosub _paddle_1_Collision
return
_paddle_1_Collision:
`this will need to be move into the paddle move command
` so that the paddle will not into move into the wall area's
`will also need to look at moving the paddle move into a section of the loop
`where the paddle to ball collision check is done so that the ball does not
`move through paddle when the paddle is in motion.
npx# = object position x (2)
npy# = object position y (2)
npz# = object position z (2)
paddleHitX = intersect object(1,px#,opy#,opz#,npx#+paddleStopLR,opy#,opz#)
if paddleHitX =>1 then npx# = opx#
paddleHitY = intersect object(1,opx#,opy#,opz#,opx#,npy#+paddleStopUD,opz#)
if paddleHitY =>1 then npy# = opy#
paddleHitZ = intersect object(1,opx#,opy#,opz#,opx#,opy#,npz#)
if paddleHitZ =>1 then npz# = opz#
position object 2,npx#,npy#,npz#
return
_moveCamera:
cox# = object position x(2)
coy# = object position y(2)
coz# = object position z(2)
position camera 0,cox#+32,coy#+32,coz#-50
point camera 0, x#,y#,z#
return
http://home.comcast.net/~johnnybolt/3D_Pong_Media.zip