Alrighty, I've gotten some very basic "AI" it is not beatable yet, I'm still working on that, but I noticed that now my collision does not work. I have no clue why either. anyways, here's the code.
*edit*
I've slowed down the paddle so I think its beatable, but still, seeing as how the collision isn't working. (still can't figure it out
) I don't know for sure if its beatable.
rem Pong, coded by: Aarrowh
rem followed tutorial made by: Chris K
rem turn on sync
sync on
sync rate 40
rem make paddles and position and color them
make object box 1,1,1,3
color object 1, rgb (0,0,250)
make object box 2,1,1,3
color object 2, rgb (250,0,0)
rem make ball
make object sphere 3,1
color object 3, rgb (0,250,0)
rem make floor
make object box 4,10,0.1,10:position object 4,0,-0.55,0
color object 4, rgb (250,250,250)
balla#=-90
do
rem SCORING
if ballx#>6 then player2score#=player2score#+1:ballx#=0:ballz#=0:balla#=270
if ballx#<-6 then player1score#=player1score#+1:ballx#=0:ballz#=0:balla#=90
set cursor 300,50:print player2score#
set cursor 320,50:print "-"
set cursor 340,50:print player1score#
if player1score#=10 or player2score#=10 then end
position object 1,-5,0,p1pos#
position object 2,5,0,ballz#-0.5
rem camera position
position camera 0,10,-10
point camera 0,0,0
rem make player 2 able to move
if upkey()=1 and p2pos#<3.5 then p2pos#=p2pos#+0.5
if downkey()=1 and p2pos#>-3.5 then p2pos#=p1pos#-0.5
if upkey()=1 and ballx#>4 and ballx#<4.5 then balla#=balla#-8
if downkey()=1 and ballx#>4 and ballx#<4.5 then balla#=balla#+8
rem make player 1 able to move
IF keystate(17)=1 and p1pos#<5 then p1pos#=p1pos#+0.5
IF keystate(31)=1 and p1pos#>-5 then p1pos#=p1pos#-0.5
if keystate(17)=1 and ballx#<-4 and ballx#>-4.5 then balla#=balla#-8
if keystate(31)=1 and ballx#<-4 and ballx#>-4.5 then balla#=balla#+8
rem make ball move
position object 3,ballx#,0,ballz#
yrotate object 3,balla#
ballx#=newxvalue(ballx#,balla#,0.3)
ballz#=newzvalue(ballz#,balla#,0.3)
bally#=newyvalue(bally#,balla#,0.3)
if ballx#>4 and ballx#<4.5 and ABS(p2pos#-ballz#)<1.5 then balla#=335-balla#
if ballx#<-4 and ballx#>-4.5 and ABS(p1pos#-ballz#)<1.5 then balla#=335-balla#
if ballz#>4 or ballz#<-4 then balla#=180-balla#
rem MAKE SURE balla# IS LESS THAN 360 AND MORE THAN 0
balla#=wrapvalue(balla#)
sync
loop
SOMEDAY, I will have coding skillz... :p