Autocam Off
hide mouse
sync on 
sync rate 50
 
 
cls
text 100,100,"3D PONG"
wait 3000
cls
text 40,200,"Its fun, bounce off the walls"
wait 3000
cls
wait 1000
text 100,100,"Much thanks to Skyler Goodell for giving a good example."
wait 3000
cls
text 100,100,"I modded the program with all the things i know how to do so far."
wait 3000
cls
text 100,300,"Instructions:"
wait 1500
cls
text 100,100,"Its pong, you know the rules, lol. First to three wins. Have fun!"
wait 2000
cls
 
`Make The Side Walls
   Make Object Cube 10,50
   Position Object 10,-100,-10,45
   color object 10,rgb(200,0,0)
 
   Make Object Cube 11,50
   Position Object 11,-100,-10,95
   color object 11,rgb(20,0,20)
 
   Make Object Cube 12,50
   Position Object 12,-100,-10,145
   color object 12,rgb(0,200,0)
 
   Make Object Cube 13,50
   Position Object 13,-100,-10,195
   color object 13,rgb(0,0,200)
 
   Make Object Cube 14,50
   Position Object 14,-100,-10,245
   color object 14,rgb(0,20,40)
 
   Make Object Cube 15,50
   Position Object 15,-100,-10,295
   color object 15,rgb(20,40,0)
 
   Make Object Cube 20,50
   Position Object 20,100,-10,45
   color object 20,rgb(20,0,20)
 
   Make Object Cube 21,50
   Position Object 21,100,-10,95
   color object 21,rgb(200,100,0)
 
   Make Object Cube 22,50
   Position Object 22,100,-10,145
   color object 22,rgb(0,200,0)
 
   Make Object Cube 23,50
   Position Object 23,100,-10,195
   color object 23,rgb(100,0,0)
 
   Make Object Cube 24,50
   Position Object 24,100,-10,245
   color object 24,rgb(0,20,60)
 
   Make Object Cube 25,50
   Position Object 25,100,-10,295
   color object 25,rgb(20,50,0)
 
`Make the Paddles
   Make Object cone 1,20
   position object 1,0,-10,20
   color object 1,rgb(200,0,0)
   make object collision box 1,-10,-11,-11,11,10,10,0
 
   Make Object cone 2,20
   Position Object 2,-85,-10,270
   color object 2,rgb(200,0,0)
   make object collision box 2,-10,-11,-11,11,10,10,0
 
`Make Ball
   Make Object Sphere 3,10
   Position Object 3,0,-10,10
   color object 3,rgb(0,200,0)
   make object collision box 3,-5,-5,-5,5,5,5,0
   position camera 0,30,-80
 
`Start the Movement
   `h_speed#=Rnd(3)+.2
   `z_speed#=3
   set object collision on 3
   `side#=0
   `COMside#=-10
   `z#=50
 
 
`Main Game Loop
main:
   h_speed#=Rnd(3)+.2
   z_speed#=3
   side#=0
   COMside#=-10
   z#=50
 
Do
 
   position camera 0,30,-80
 
`Move Paddles and Ball
   inc x#,h_speed#
   inc z#,z_speed#
 
   position object 3,x#,-10,z#
 
   position object 1,side#,-10,20
   position object 2,COMside#,-10,295
 
`Bouncing Math
   if object collision(3,1)>0
      z_speed#=3
      if speed#=3 or speed#=-3
      h_speed#=h_speed#+speed#
   endif
   endif
 
   if object collision(3,2)>0
      z_speed#=-3
   if speed#=3 or speed#=-3
      h_speed#=h_speed#+speed#
   endif
   endif
 
   if x#<-60 or x#>60
      h_speed#=h_speed#*-1
      endif
 
 
 
`Mis.
set cursor 200,30:print names$
set cursor 300,50:print player2score#
set cursor 320,50:print "-"
set cursor 340,50:print player1score#
set cursor 355,30:print name$
 
 
`Paddle Movement
   if rightkey()=1
   side#=side#+3
   speed#=3
   else
   speed#=0
   endif
 
   if leftkey()=1
   side#=side#-3
   speed#=-3
   else
   speed#=0
   endif
 
   if side#<-55 then side#=-55
   if side#>55 then side#=55
 
   if COMside#<-55 then COMside#=-55
   if COMside#>55 then COMside#=55
 
 
 
`Paddle Movement
   if rightkey()=1
   side#=side#+3
   speed#=3
   else
   speed#=0
   endif
 
   if leftkey()=1
   side#=side#-3
   speed#=-3
   else
   speed#=0
   endif
 
   if side#<-55 then side#=-55
   if side#>55 then side#=55
 
   if COMside#<-55 then COMside#=-55
   if COMside#>55 then COMside#=55
 
`COM AI
      if COMside#<x#
      if z#>120
      COMside#=COMside#+2.2
      endif
      endif
 
   if COMside#>x#
   if z#>120
   COMside#=COMside#-2.2
   endif
   endif
 
rem score routine
   if object position z(3) > 300
      player1score#=player1score#+1
      gosub main
   endif
 
   if object position z(3) < 0
      player2score#=player2score#+1
      gosub main
   endif
 
if player1score#=(3)
x#=0
y#=0
z#=0
 
text 100,100,"YOU WIN!!!"
text 300,100,"Thanks for playing!"
endif
 
if player2score#=(3)
x#=0
y#=0
z#=0
 
text 100,100,"Computer Wins! PHTTTTT!!!!!"
text 300,100,"Thanks for playing!"
endif
 
 
sync
   loop