It seems adequate to simply rotate it on the Z axis. I made a few edits:
REM Project: pong 3d
REM Created: 16/04/2008 7:21:19 PM
REM
REM ***** Main Source File *****
REM
start:
gosub setup
gosub quickmatch
wait key
end
` setup objects/images/sounds
setup:
`set screen
set display mode 1280,1024,32
set text size 30
`warn about loading
set cursor 200,200:print "L O A D I N G . . . P L E A S E W A I T . . .":SYNC
color backdrop 0
backdrop on
sync on
sync rate 0
`images
`textures
ground=1
load image "images/ground.jpg",ground
ballpic=2
load image "images/ball.jpg",ballpic
border=3
load image "images/border.jpg",border
paddles=4
load image "images/paddle.jpg",paddles
goals=5
load image "images/goal.jpg",goals
`sounds
`objects
`paddles
plr1=1
plr2=2
make object box plr1,5,20,15
make object box plr2,5,20,15
`ball
ball=3
make object sphere ball,5
okay = 0
repeat
direction = rnd(7)+1
if direction<>1 and direction<>5 then okay = 1
until okay = 1
gosub MoveBall
`acrossbars
bar1=4
bar2=5
make object box bar1,150,5,15
make object box bar2,150,5,15
`sidebars
bar3=6
bar4=7
make object box bar3,5,100,15
make object box bar4,5,100,15
`base/floor/plain
base=8
make object plain base,150,100
`placement of objects
`paddles
position object plr1,-70,0,0
position object plr2,70,0,0
`bars
position object ball,0,0,5
position object bar1,0,50,0
position object bar2,0,-50,0
position object bar3,75,0,0
position object bar4,-75,0,0
`base
position object base,0,0,8
`texture the objects
texture object base,ground
texture object ball,ballpic
texture object plr1,paddles
texture object plr2,paddles
texture object bar1,border
texture object bar2,border
texture object bar3,goals
texture object bar4,goals
color object bar3,rgb(255,0,0)
`make light
make light 1
`camera and light positions
`view 1(side veiw)
side1y#=-111.361
side1z#=-87.2952
`view 2(top view)
top2y#=18.3357
top2z#=-143.127
`view 3(end veiw)
end3x#=-130.44
end3y#=-2.55107
end3z#=-52.5722
`hiding the objects
for i=1 to 8
hide object i
next object
cls
`warn loading completed & ready to continue
sync off
set cursor 220,200:print "L O A D I N G D O N E"
print ""
print " p r e s s a n y k e y t o b e g i n":sync
sync on
SYNC rate 50
wait key
return
quickmatch:
`show objects
for i=1 to 8
show object i
next i
`<<<<<<<<<<<<<
`>quickmatch>
`<<<<<<<<<<<<<
`set variables
ballspeed#=0.5
paddlespeed#=0.5
up=1
left=1
type scoring
two as integer
one as integer
endtype
score as scoring
do
gosub control
gosub camera
gosub collisions
`gosub ball
gosub MoveBall
gosub plr2control
gosub scoring
sync
loop
end
`control the plr
control:
if upkey()=1
move object up plr1,paddlespeed#
endif
if downkey()=1
move object down plr1,paddlespeed#
endif
return
`control the camera
camera:
if keystate(2)=1 or view=1
view=0
position camera 0,side1y#,side1z#
position light 1,0,side1y#,side1z#
point camera object position x(base),object position y(base),object position z(base)
endif
if keystate(3)=1 or view=2
view=0
position camera 0,top2y#,top2z#
position light 1,0,top2y#,top2z#
point camera object position x(base),object position y(base),object position z(base)
endif
if keystate(4)=1 or view=3
view=0
position camera end3x#,end3y#,end3z#
position light 1,end3x#,end3y#,end3z#
point camera object position x(base),object position y(base),object position z(base)
roll camera right 90
endif
if keystate(5)=1 or view=4
view=4
position camera object position x(plr1),object position y(plr1),object position z(plr1)
point camera object position x(bar3),object position y(bar3),object position z(bar3)
roll camera right 90
endif
return
`controlling collisions
collisions:
up = 0 : down = 0 : left = 0 : right = 0
if object collision(plr1,bar1)
move object down plr1,paddlespeed#
endif
if object collision(plr1,bar2)
move object up plr1,paddlespeed#
endif
if object collision(plr2,bar1)
move object down plr2,paddlespeed#
endif
if object collision(plr2,bar2)
move object up plr2,paddlespeed#
endif
if object hit(ball,bar1)
if direction = 8 then direction = 6
if direction = 1 then direction = rnd(2)+4
if direction = 2 then direction =4
endif
if object hit(ball,bar2)
if direction = 4 then direction = 2
if direction = 6 then direction = 8
if direction = 5
d = rnd(1000)
direction = 8
if d>900 then direction = 1
if d<450 then direction = 2
endif
endif
if object hit(ball,bar3)
inc score.one
ballspeed#=0.5
if direction = 2 then direction = 8
if direction = 3 then direction = rnd(2) + 6
if direction = 4 then direction = 6
endif
if object hit(ball,bar4)
inc score.two
ballspeed#=0.5
if direction = 8 then direction = 2
if direction = 7 then direction = rnd(2)+2
if direction = 6 then direction = 4
endif
if object hit(plr1,ball)
if direction = 8 then direction = 2
if direction = 7 then direction = rnd(2)+2
if direction = 6 then direction = 4
inc ballspeed#,0.05
endif
if object hit(plr2,ball)
if direction = 2 then direction = 8
if direction = 3 then direction = rnd(2) + 6
if direction = 4 then direction = 6
inc ballspeed#,0.05
endif
return
remstart
`ball movement
ball:
` fix object pivot ball
`capture the angle positions
xangle#=object angle x(ball)
yangle#=object angle y(ball)
if up=1
`rotateing and positioning the ball
move object ball,ballspeed#
` position object ball,object position x(ball),object position y(ball)+ballspeed#,5
endif
if down=1
` position object ball,object position x(ball),object position y(ball)-ballspeed#,5
move object ball,ballspeed#
endif
fix object pivot ball
if left=1
` position object ball,object position x(ball)-ballspeed#,object position y(ball),5
move object ball,ballspeed#
endif
if right=1
` position object ball,object position x(ball)+ballspeed#,object position y(ball),5
move object ball,ballspeed#
endif
` fix object pivot ball
return
remend
`player two control
plr2control:
if object position x(ball)>0
if object position y(ball)>object position y(plr2)
move object up plr2,paddlespeed#
endif
if object position y(ball)<object position y(plr2)
move object down plr2,paddlespeed#
endif
endif
return
scoring:
text 10,10,"1) "+str$(score.one)
text 200,10,"2) "+str$(score.two)
return
MoveBall:
xangle#=object angle x(ball)
yangle#=object angle y(ball)
zangle#=object angle z(ball)
select direction
case 1
` straight up
position object ball,object position x(ball),object position y(ball)+ballspeed#,5
rotate object ball,0.0,0.0,wrapvalue(zangle#-10.0)
endcase
case 2
` up and right
zrotate object ball,wrapvalue(zangle#-10.0)
position object ball,object position x(ball)+ballspeed#,object position y(ball)+ballspeed#,5
endcase
case 3
` straight right
rotate object ball,wrapvalue(xangle#-10.0),0.0,0.0
position object ball,object position x(ball)+ballspeed#,object position y(ball),5
endcase
case 4
` right and down
zrotate object ball,wrapvalue(zangle#-10.0)
position object ball,object position x(ball)+ballspeed#,object position y(ball)-ballspeed#,5
endcase
case 5
` straight down
position object ball,object position x(ball),object position y(ball)-ballspeed#,5
zrotate object ball,wrapvalue(zangle#-10.0)
endcase
case 6
` down and left
position object ball,object position x(ball)-ballspeed#,object position y(ball)-ballspeed#,5
zrotate object ball,wrapvalue(zangle#+10.0)
endcase
case 7
` straight left
rotate object ball,wrapvalue(xangle#+20.0),0.0,0.0
position object ball,object position x(ball)-ballspeed#,object position y(ball),5
endcase
case 8
` left and up
position object ball,object position x(ball)-ballspeed#,object position y(ball)+ballspeed#,5
zrotate object ball,wrapvalue(zangle#+10.0)
endcase
endselect
return
It is easier to see the rotation with a texture that I made up with grey as the background, a red stripe going across and a green stripe going up and down. I hope this is helpful.
LBFN