Okay i have made some progress on the program.
But I have yet another issue.
For some reason the ball isnt coliding with the top or bottum of the table it just goes right through!
This is the code
Rem Project: PONG
Rem Created: 12/7/2006 6:08:50 PM
Rem ***** Main Source File *****
Gosub SETUP
`Main Program Loop
Do : `Start of main loop
CLS
If new_window=1 then Gosub menu
Gosub ShowStats
Gosub ShowMedia
Gosub Player1_Move
Gosub ObjectCoords
Gosub Player2_Move
Gosub Ball_Move
Gosub Collision_Check
Gosub Scores
sync
Loop : `End of main loop
`***********************************************
`~~**************-[Procedures]-*****************
`***********************************************
ShowMedia:
ink rgb(255,255,255),0 : box 70,70,570,410 : `Create Table white spot
ink rgb(0,0,0),0 : box 71,71,569,409 : `Create Black spot to turn table into line
Return
ObjectCoords:
ink rgb(255,255,255),0
box plr1x1#,plr1y1#,plr1x2#,plr1y2#
box plr2x1#,plr2y1#,plr2x2#,plr2y2#
circle ballx#,bally#,6
return
Player1_Move:
if keystate(17)=1 and plr1y1#>73: `Move Up
plr1y1#=plr1y1#-.07
plr1y2#=plr1y2#-.07
endif
if keystate(31)=1 and plr1y2#<408: `Move down
plr1y1#=plr1y1#+.07
plr1y2#=plr1y2#+.07
endif
Return
Player2_Move:
if upkey()=1 and plr2y1#>73 and startgame2player=1: `Move Up player 2 (person)
plr2y1#=plr2y1#-.07
plr2y2#=plr2y2#-.07
endif
if downkey()=1 and plr2y2#<408 and startgame2player=1: `Move down player 2 (person)
plr2y1#=plr2y1#+.07
plr2y2#=plr2y2#+.07
endif
Return
Ball_Move:
ballx#=newxvalue(ballx#,balla#,0.05):bally#=newyvalue(bally#,balla2#,0.05)
`if ballx#>70 and ballx#<570 then balla#=360-balla#
if ballx#<70 or ballx#>570 then balla#=360-balla#
if bally#<70 or bally#>410 then balla#=180-balla#
Return
Collision_Check:
Return
Scores:
Return
ShowStats:
set cursor 0,0 : print "FPS ";screen fps() : print "Plr 1x1: ";plr1x1#;" Plr 1y1: ";plr1y1#
print "Plr 1x2: ";plr1x2# ; " Plr 1y2: ";plr1y2#
print "Ball X: ";ballx# ; " Ball Y: ";bally#
Return
`***********************************************
`~~***********-[START_PROCEDURES]-**************
`***********************************************
Menu:
repeat
if Button(oneplayerx1,oneplayery1,"1 Player")=1 then CLS : new_window=0 : ink rgb(255,255,255),0 : startgame1player=1
if Button(twoplayerx1,twoplayery1,"2 Player")=1 then CLS : new_window=0 : ink rgb(255,255,255),0 : startgame2player=1
until startgame1player=1 or startgame2player=1
return
Setup:
set text font "Courier" : Set text size 16 : `Font commands
`Variables, Floats, and Strings
SinglePlayerNew$="Single Player"
MultiplayerNew$="Multiplayer"
oneplayerx1=280 : oneplayery1=180
twoplayerx1=282 : twoplayery1=216
multiplayerx1=285 : multiplayery1=240
Plr1X1#=72 : Plr1Y1#=210 : Plr1x2#=85 : plr1y2#=260
Plr2X1#=553 : Plr2Y1#=210 : plr2x2#=568 : plr2y2#=260
ballx#=315 : bally#=240 : balla#=90 : balla2#=rnd(360)
ExitGame$="Exit"
SinglePressed=0 : Multipressed=0
new_window=1
Return
`***********************************************
`~~**************-[Functions]-******************
`***********************************************
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
Thanks in advance,
-inverted
Opposites are different, not wrong