' pong game in o2
$ filename "Pong.exe"
'include "rtl32.inc"
include "window.inc"
! Beep lib "Kernel32.dll"

Window "Pong in o2 by Peter Wirbelauer",320, 240, 1
 
'SetFPS 10
waitfor 10
int x,y,x2,y2,pspeed,xadj,yadj,delay,score
x = 50
y = 50
x2 = 130
y2 = 160
pspeed = 1
xadj = 1
yadj = 1
delay = 1
score = 0
 
'haha = "wav/haha.wav"
'pong = "wav/pong.wav"
 
WHILE Key(27) = 0
  ClsColor (200, 200, 247)
  Circle   (x, y, 8, 0, 0, 255)
  FillBox  (x2, y2, 30, 4, 255, 255, 255)
  Box      (20, 20, 280, 160, 4,255, 255, 0)
  Text     (10, 0, "SCORE:" & score, 255, 0, 0)
  IF y <= 20
    yadj = 1
    'PlayWav pong
    beep 400,100
  END IF
  IF y >= 180
    yadj = -1
   ' PlayWav pong
   beep 400,100
  END IF
  IF x >= 300
    xadj = -1
   ' PlayWav pong
   beep 400,100
  END IF
  IF x <= 20
    xadj = 1
   ' PlayWav pong
   beep 400,100
  END IF
  IF Key(37) AND x2 > 18  :  x2 = x2 - pspeed : end if
  IF Key(39) AND x2 < 270 :  x2 = x2 + pspeed : end if
  x = x + xadj
  y = y + yadj
  IF y > y2 - 7 AND y2 < y2 + 2 AND x < x2 + 30 AND x > x2
    yadj = -1
    score = score + 1
  END IF
  IF y > y2 + 10
    'Text( sys x, y, string txt, sys r,g,b)
    Text (100, 200, "GAME OVER!", 0, 160, 55)
    'Playwav haha
    beep 800,100
    Waitkey(27)
    score = 0
    x = 5
    y = 5
    x2 = 130
    y2 = 150
  END IF
  FlipBuffer()
  'SetFps 40
  waitfor 40
WEND
WinEnd

 