12-23-2004, 03:26 AM
For certain reasons, i've decided to make a text-based pong in basic (using just print and locate :o ). I've written up most of it, but im stuck at the part where the ball should bounce off the paddle, any ideas on how to add in this 'collision' info to my paddles?
Also, I know the PaddleRow looks like it needs an array, but i thought this would slow down the paddles even more than they already are...
This is really my first attempt at writing a simple game and useful program in basic, so any help would be greatly appreciated!
Also, I know the PaddleRow looks like it needs an array, but i thought this would slow down the paddles even more than they already are...
This is really my first attempt at writing a simple game and useful program in basic, so any help would be greatly appreciated!
Code:
cls
print "***Program by: RJ***"
print "Play some pong!!!"
input "Hit anykey to continue.";p
cls
let PaddleRow1=5:PaddleRow2=6:PaddleRow3=7:PaddleRow4=8
let LeftColumn=3:RightColumn=78
let x=10:y=10
let xadj=1:yadj=1
do
'game
'top outline
let r= 1
let c= 1
for c = 1 to 80
locate r,c
print Chr$(177)
next c
'bottom outline
let r= 22
let c=1
for c = 1 to 80
locate r,c
print Chr$(177)
next c
'left outline
let c=1
let r=1
for r=1 to 22
locate r,c
print Chr$(177)
next r
'right outline
let c=80
let r=1
for r = 1 to 22
locate r,c
print Chr$(177)
next r
'black to erase ball because cls sux
locate x,y
print Chr$(255)
'bouncy ball
IF y <= 2 THEN yadj = 1
IF y >= 79 THEN yadj = -1
IF x >= 21 THEN xadj = -1
IF x <= 2 THEN xadj = 1
x = x + xadj
y = y + yadj
locate x,y
print Chr$(2)
'paddle
key$=inkey$
if key$<>"" then
'use black to erase paddle
locate PaddleRow1,LeftColumn
print Chr$(255)
locate PaddleRow2,LeftColumn
print Chr$(255)
locate PaddleRow3,LeftColumn
print Chr$(255)
locate PaddleRow4,LeftColumn
print Chr$(255)
locate PaddleRow1,RightColumn
print Chr$(255)
locate PaddleRow2,RightColumn
print Chr$(255)
locate PaddleRow3,RightColumn
print Chr$(255)
locate PaddleRow4,RightColumn
print Chr$(255)
'paddle
if PaddleRow4< 21 then if key$="s" then let PaddleRow1=PaddleRow1+1:PaddleRow2=PaddleRow2+1:PaddleRow3=PaddleRow3+1:PaddleRow4=PaddleRow4+1
if PaddleRow1> 2 then if key$="w" then let PaddleRow1=PaddleRow1-1:PaddleRow2=PaddleRow2-1:PaddleRow3=PaddleRow3-1:PaddleRow4=PaddleRow4-1
locate PaddleRow1,LeftColumn
print Chr$(186)
locate PaddleRow2,LeftColumn
print Chr$(186)
locate PaddleRow3,LeftColumn
print Chr$(186)
locate PaddleRow4,LeftColumn
print Chr$(186)
locate PaddleRow1,RightColumn
print Chr$(186)
locate PaddleRow2,RightColumn
print Chr$(186)
locate PaddleRow3,RightColumn
print Chr$(186)
locate PaddleRow4,RightColumn
print Chr$(186)
end if
loop