rem === BASIC EXAMPLE: PONG === dim paddle1y dim paddle2y dim ballx dim bally dim balldx dim balldy dim score1 dim score2 rem ******* INITIALISE VARS ******* player1y=10 paddle2y=playery ballx= 8 bally= 12 balldx =1 balldy =-1 score1=0 score2=0 rem ======================== MAIN LOOP ======================== mainloop: waitsync rem *** draw players & ball *** resetbeam moveto -100, paddle1y gosub drawpaddle resetbeam moveto 100, paddle2y gosub drawpaddle resetbeam moveto ballx, bally gosub drawball rem *** draw scores *** resetbeam moveto -100, -100 print "BASICPONG" resetbeam moveto -112, 100 print score1 resetbeam moveto 80, 100 print score2 gosub handleball gosub handleopponent gosub handleinput goto mainloop rem ========================= SUBROUTINES ========================= sub drawpaddle line 8, 0 line 0, -20 line -8, 0 line 0, 20 end sub sub drawball line 8, 0 line 0, -8 line -8, 0 line 0, 8 end sub sub handleinput if joystick1_y>0 then inc paddle1y endif if joystick1_y<0 then dec paddle1y endif if joystick1_button1>0 then inc paddle2y endif if joystick1_button2>0 then dec paddle2y endif end sub sub handleball if balldx=1 then inc ballx inc ballx else dec ballx dec ballx endif if balldy=1 then inc bally else dec bally endif if ballx>120 then balldx = -1 inc score1 endif if ballx<-120 then rem ballx = 0 rem bally = 0 balldx = 1 inc score2 endif if bally>120 then balldy = -1 endif if bally<-120 then balldy = 1 endif end sub sub handleopponent if ballx>64 then if paddle2ybally then dec paddle2y endif endif end sub end: