I made an updated version with a menu and stuff. =)
(This is my first post on the forums and my second day using DB.. nice to meet everyone..)
Rem Project: pong
Rem Created: 9/27/2006 10:29:33 PM
Rem ***** Main Source File *****
rem SET THE BACKGROUND TO BLACK AND LIMIT THE SYNC RATE TO 40
color backdrop rgb(0,0,0):sync on:sync rate 40
rem MAKE THE PADDLES, BALL AND FLOOR
make object box 1,1,1,3:color object 1,rgb(255,255,255)
make object box 2,1,1,3:color object 2,rgb(255,255,255)
make object sphere 3,1:color object 3,rgb(255,2555,255)
make object box 4,30,2,0.1:position object 4,0,0,10
make object box 5,30,2,0.1:position object 5,0,0,-10
make object box 6,0.1,2,20:position object 6,15,0,0
make object box 7,0.1,2,20:position object 7,-15,0,0
print " Programmed by Link777"
print " =) Have fun with it!"
sync
wait 5000
menu:
rem HIDE ALL OBJECTS
hide object 1:hide object 2:hide object 3:hide object 4:hide object 5:hide object 6:hide object 7
cls
sync
show mouse
do
if Button(250,55,"New Game")=1 then goto new_game
if Button(250,85,"Exit")=1 then end
sync
loop
new_game:
rem RESET THE SCORES
player1score#=0
player2score#=0
rem RESET PLAYER POSITIONS
player1pos#=0
player2pos#=0
rem SET THE INK COLOR
ink rgb(255,255,255),rgb(0,0,0)
rem HIDE THE MOUSE
hide mouse
rem SHOW ALL OBJECTS
show object 1:show object 2:show object 3:show object 4:show object 5:show object 6:show object 7
rem SET THE BALL SPEED
speed#=0.3
rem SET THE BALL ANGLE TO 90 DEGREES
balla#=90
rem START THE MAIN LOOP
sync on:do
rem SCORING
if ballx#>14
player1score#=player1score#+1:ballx#=0:ballz#=0:balla#=270
speed#=0.3
endif
if ballx#<-14
player2score#=player2score#+1:ballx#=0:ballz#=0:balla#=90
speed#=0.3
endif
set cursor 300,20:print player1score#
set cursor 320,20:print "-"
set cursor 340,20:print player2score#
rem BALL MOVEMENT
ballx#=newxvalue(ballx#,balla#,speed#):ballz#=newzvalue(ballz#,balla#,speed#)
if player2score#>9 and player1score#<player2score#-1
cls
set cursor 270,30:print "Player two wins!"
sync
wait 3000
goto menu
endif
if player1score#>9 and player2score#<player1score#-1
cls
set cursor 270,30:print "Player one wins!"
sync
wait 3000
goto menu
endif
rem PLAYER 1 PADDLE MOVEMENT
IF upkey()=1 and player2pos#<8.5 then player2pos#=player2pos#+0.5
IF downkey()=1 and player2pos#>-8.5 then player2pos#=player2pos#-0.5
if upkey()=1 and ballx#>12 and ballx#<12.5 then balla#=balla#+16
if downkey()=1 and ballx#>12 and ballx#<12.5 then balla#=balla#-16
rem PLAYER 2 PADDLE MOVEMENT
IF keystate(17)=1 and player1pos#<8.5 then player1pos#=player1pos#+0.5
IF keystate(31)=1 and player1pos#>-8.5 then player1pos#=player1pos#-0.5
if keystate(17)=1 and ballx#<-12 and ballx#>-12.5 then balla#=balla#+16
if keystate(31)=1 and ballx#<-12 and ballx#>-12.5 then balla#=balla#-16
rem BOUNCING
if ballx#>12 and ballx#<12.5 and ABS(player2pos#-ballz#)<2
balla#=360-balla#
if speed#<0.9
speed#=speed#+0.05
endif
endif
if ballx#<-12 and ballx#>-12.5 and ABS(player1pos#-ballz#)<2
balla#=360-balla#
if speed#<0.9
speed#=speed#+0.05
endif
endif
if ballz#>9 or ballz#<-9 then balla#=180-balla#
rem MAKE SURE balla# IS LESS THAN 360 AND MORE THAN 0
balla#=wrapvalue(balla#)
rem POSITION OBJECTS
position object 1,13,0,player2pos#:position object 2,-13,0,player1pos#
position object 3,ballx#,0,ballz#:yrotate object 3,balla#
rem START THE ORIGINAL CAMERA POSITION
position camera 0,22,-15:point camera 0,0,0
sync
loop
function Button(x1,y1,WORDS$)
Pressed=0
x2=Text Width(WORDS$)
y2=Text Height(WORDS$)
if mousex()>x1 and mousex()<x1+x2
if mousey()>y1-y2 and mousey()<y1+y2
Pressed=1
endif
endif
if pressed=1 then ink rgb(255,0,0),0 else ink rgb(255,255,255),0
if pressed=1
Pressed=Mouseclick()
else
pressed = 0
endif
text x1,y1,WORDS$
endfunction pressed
Tell me what you think, please. :o