View Full Version: Pong example

Wee Basic > Code Samples > Pong example


Title: Pong example


axipher - October 25, 2007 02:28 AM (GMT)
Just thought I'd post the pong example as well, I had to download the alpha 1 release to get it, but here it is:

CODE
lab 100:
cls
let l=100
let w=50 let f=10
let p=20
print "Wee Basic - Pong demo"
for j=1 to 16
print ""
next
line 3,f,3,w,1
line l,f,l,w,2
line 3,f,l,f,3
line 3,w,l,w,4
print "Press any key to start"
let m=0
while m=0
let m=key()
wend
let X = p
let Y = f+4
let Z = y+1
let d=-1
let k=1
let a=l-1
let b= f+5
let s=1
plot X,Y,1 plot X, Z,1 plot a,b,1

lab begin:
let T= key()
IF T = 206 AND Y < > f+1
 PLOT X,Y,0 PLOT X,Z,0
 let Y = Y - 1 let Z = Z -1
 PLOT X,Y,1 PLOT X,Z,1
 let T = key()
endif
IF T = 207 AND Z < > w-1
 PLOT X,Y,0 PLOT X,Z,0
 let Y = Y + 1 let Z = Z + 1
 PLOT X,Y,1 PLOT X,Z,1
endif

IF a = l-1 let d=-1
endif

IF b >= w-1 let s=-1
endif
if b<=f+1 let s=1
endif

PLOT a,b,0
let a = a + d let b = b + s
PLOT a,b,1

if a=2 goto lose:
endif

IF X + 1 = a AND (Y = b or z=b)
 let k=1
 PLOT a, b,0
 let d = 1
 let a = a + d let b = b + s
 PLOT a,b,1
endif

goto begin:


lab lose:
lab lose:
print ""
PRINT "You Lose"
PRINT "Press A to Play Again...."
print "or any other key to exit"
let m=0
while m=0
let m=key()
wend
IF m=202 cls PLOT a,b,0  PLOT X,Y,0 PLOT X,Z,0 goto 100:
endif
END

marovada - October 25, 2007 07:46 PM (GMT)
thanks axipher




* Hosted for free by InvisionFree