set text font "Terminal" : set text size 72
 
 
`~~~~~~~~~~~~~~~
`~~~~~~~~~~~~~~~
`~~~~~~~~~~~~~~~
`GOLBALS
`~~~~~~~~~~~~~~~
`~~~~~~~~~~~~~~~
`~~~~~~~~~~~~~~~
`whdts/heights
 
screenwidth = screen width()
screenheight = screen height()
screenwidth10 = (screen width() / 10)
screenheight10 = (screen height() / 10)
screenwidth10 = (screen width() / 10)
screenheight10 = (screen height() / 10)
screenmin10 = (screen width() - 10)
screenmin20 = (screen width() - 20)
screenwidthhalf = (screen width() / 2)
 
fieldsize = (screenwidth / 2)
`your object
global plankobject = 2
global plankx = 10
global planky
global plankwith = (10)
global plankheight =  (100)
global planknewxpos = screenheight
global planknewypos
 
 
`evil object
global evilobject = 3
global evilx = screenmin20
global evily = screenheight10
global evilwith = (screenwidth100)
global evilheight = (screenheight10)
global evilnewx
global evilnewy
global evilspeed = 2
 
global dosomething = 0
global doright = 0
 
`AI
global randomAI
global AIdiff
global AIdiffmax
 
`ball
global ballx = fieldsize
global bally = fieldsize
global ballwith = 10
global ballheight = 10
 
`--- changed 2 lines here ---
global ballxspeed = 3
global ballyspeed = 3
global ballobject = 1
global ballnewx
global ballnewy
 
 
`points
global yourpoints
global evilpoints
 
`sides
global upsidex = 1
global upsidey = 1
global upsidewith = screenwidth
 
global downsidex  = 1
global downsidey = screenheight
global downsidewith = screenwidth
global fieldwith = screenwidth
 
`~~~~~~~~~~~~~~~
`~~~~~~~~~~~~~~~
`~~~~~~~~~~~~~~~
`SETUP
`~~~~~~~~~~~~~~~
`~~~~~~~~~~~~~~~
`~~~~~~~~~~~~~~~
 
 
`create ball
ink rgb(255,255,255),1
box 0,0,ballwith,ballheight
get image 1,0,0,ballwith, ballheight,0
 
 
`create plank and evil
 
ink rgb(255,255,255),1
box 0,0,plankwith,plankheight
get image 2,0,0,plankwith, plankheight,0
 
 
cls
 
 
cls
 
   ` Player score
   text 200, 30, str$(yourpoints)
 
   ` Cpu score
   text 400, 30, str$(evilpoints)
 
get image 4,0,0,500,40
 
`~~~~~~~~~~~~~~~
`~~~~~~~~~~~~~~~
`~~~~~~~~~~~~~~~
`~~~~~~~~~~~~~~~
`MAIN
`~~~~~~~~~~~~~~~
`~~~~~~~~~~~~~~~
`~~~~~~~~~~~~~~~
`~~~~~~~~~~~~~~~
`plank
Sprite plankobject, planknewxpos, planknewypos, 2
`evil
Sprite evilobject, evilnewx, evilnewy, 2
`ball
Sprite ballobject, ballnewx, ballnewy, 1
 
 
do
 
 
 
`#######
`take this out to try
    `ballcollision
    remstart if ballx < (plankx + plankwith) and (ballx + ballwith) > plankx
        `hits plankx
        if baly < (planky + plankheight) and (bally + ballheight) > planky
            `hits plank full
            ballxspeed = ballxspeed * -1
        endif
    endif remend
`ballcollision on side
    if (bally + ballheight) > downsidey then ballyspeed = ballyspeed * -1
    if bally < upsidey then ballyspeed = ballyspeed * -1
`evilcollision
remstart    if ballx < (evilx + evilwith) and (ballx + ballwith) > evilx
        `hits evilx
        if baly < (evily + evilheight) and (bally + ballheight) > evily
            `hits evil full
            ballxspeed = ballxspeed * -1
        endif
    endifremend
 
 
 
`#######
 
`new to trie
 
`ballcollision
 
if sprite collision( 1, 2) then ballxspeed = ballxspeed *-1
if sprite collision( 1, 3) then ballxspeed = ballxspeed *-1
 
 
`move your plank
    `planknewxpos = mousex()
    planknewxpos = 10
    planknewypos = mousey()
    if planknewypos < upsidey then plankypos = upsidey
    if (planknewypos + plankheight) > downsidey then planky = (downsidey - plankheight)
 
`AI
    `if ballx > fieldsize
      remstart  if dosomething = 0
            randomAI = rnd(AIdiffmax)
            if randomAI < AIdiff then doright = 1
            dosomething = 1
        endif
        if doright = 1 `goes to the good side remend
            if bally <= evily then evilnewy = (evily - evilspeed)
            if bally  >= evily then evilnewy = (evily + evilspeed)
        `endif
    `endif 
     remstart if ballx < fieldsize
        dosomething = 0
        doright = 0
        randomAI = 0
    endif remend
evilnewx = screenmin20
`update ball
ballnewx = ballx + ballxspeed
ballnewy = bally + ballyspeed
 
`--- added 2 lines here ----
ballx=ballnewx
bally=ballnewy
 
evilx = evilnewx
`evily = evilnewy
 
 
 
`!!!!!!!
`REPOSITIONING
`!!!!!!!
 
`plank
Sprite plankobject, planknewxpos, planknewypos, 2
`evil
Sprite evilobject, evilnewx, evilnewy, 2
`ball
Sprite ballobject, ballnewx, ballnewy, 1
`score
   ` Player score
   text 200, 30, str$(yourpoints)
 
   ` Cpu score
   text 400, 30, str$(evilpoints)
 
`show score
 
 
` Draw each player's score
DrawScore:
  ` ink rgb(200, 200, 200), 0
remstart
   ` Player score
   text 200, 30, str$(yourscore)
 
   ` Cpu score
   text 400, 30, str$(evilscore)
remend 
 
`--- added 5 lines here ---
`set cursor 1,1
remstart print "ballx=";ballx
print "bally=";bally
print "ballxspeed";ballxspeed
print "ballyspeed";ballyspeed
remend
evily = evilnewy
    sync
 
 
 
 
`scoring
 
if ballx < 0 
    ballxspeed = ballxspeed * -1 :
     score(1)
     endif
if ballx > screenwidth 
    ballxspeed = ballxspeed * -1 
     score(0)
    endif
loop
 
 
 
 
function score(whoscored)
if whoscored = 0 then yourpoints = yourpoints + 1
if whoscored = 1 then evilpoints = evilpoints + 1
 
 
   ` Player score
   text 200, 30, str$(yourpoints)
 
   ` Cpu score
   text 400, 30, str$(evilpoints)
 
sleep 3000
 
`kick off
ballx = fieldsize
ballnewy = fieldsize
ballnewx = fieldsize
bally = fieldsize
 
endfunction