time=0
points=0
xpost=ran(640)+50
if xpost>620 xpost=620
dim along(5)
dim scr(5)
for b=1 to 5
 scr(b)=ran(512)
 along(b)=ran(640)
next b
go=0
open window 640,512
window origin "lb"

label loop
 gosub buffer
 gosub snow
 gosub keys
 gosub chap
 side=0
 gosub obs
 gosub posts
 gosub title
 if go=1 time=time+1
goto loop

label title
 if go=0 then
  setrgb 1,250,250,0
  fill rect 0,0 to 640,150
  setrgb 1,0,0,0
  line 0,150 to 640,150
  setrgb 1,255,0,0
  rect 235,110 to 407,135
  setrgb 1,25,0,200
  text 240,120,"S K I B A S I C"
  setrgb 1,50,50,50
  text 239,121,"S K I B A S I C"
  setrgb 1,100,100,100
  text 241,119,"S K I B A S I C"
  setrgb 1,0,0,100
  text 259,90,"BY JO MORROW"
  text 10,50," AVOID THE TREES AND TRY TO GO THROUGH THE RED GATES."
  text 10,30," check out yabasic.co.uk for more games"
  text 10,10," PRESS X TO BEGIN"
 endif
 if peek("port1")=16384 then
  go=1
 endif
return

label buffer
 setdrawbuf dw
 dw=1-dw
 setdispbuf dw
 clear window
return

label keys
 c=peek("port1")
 if (and(c,128)<>0) fx=fx-3
 if (and(c,128)<>0) side=1
 if fx<-290 fx=-290
 if (and(c,32)<>0) fx=fx+3
 if (and(c,32)<>0) side=2
 if fx>280 fx=280
return

label chap
 setrgb 1,25,0,250
 text fx+283,495,"PLAYER 1"
 setrgb 1,150,150,200
 if side=0 then
  fill rect fx+314,440 to fx+318,458
  fill rect fx+327,440 to fx+323,458
  line fx+302,458 to fx+302,478
  line fx+338,458 to fx+338,478
 endif
 if side=1 then
  fill triangle fx+309,440 to fx+318,458 to fx+313,440
  fill triangle fx+323,458 to fx+318,458 to fx+313,440
  line fx+302,458 to fx+308,478
  line fx+338,458 to fx+343,478
  fill triangle fx+318,440 to fx+327,458 to fx+324,440
  fill triangle fx+330,458 to fx+327,458 to fx+324,440
 endif
 if side=2 then
  line fx+302,458 to fx+297,478
  line fx+338,458 to fx+333,478
  fill triangle fx+318,440 to fx+316,458 to fx+323,440
  fill triangle fx+318,440 to fx+316,458 to fx+311,458
  fill triangle fx+328,440 to fx+316,478 to fx+332,440
  fill triangle fx+328,440 to fx+316,478 to fx+307,478
 endif
 setrgb 1,0,0,0
 fill circle fx+320,480,11
 fill rect fx+310,468 to fx+330,458
 line fx+310,468 to fx+302,458
 line fx+330,468 to fx+338,458
 setrgb 1,200,200,200
 fill triangle fx+310,468 to fx+310,458 to fx+314,458
 fill triangle fx+330,468 to fx+330,458 to fx+326,458
 setrgb 1,0,0,0
 line fx+314,458 to fx+316,450
 line fx+326,458 to fx+324,450
return

label snow
 setrgb 1,250,250,250
 fill rect 0,0 to 640,512
return

label obs
 setrgb 1,0,100,0
 for a=0 to 5
  fill triangle along(a),scr(a) to along(a)-10,scr(a)-30 to along(a)+10,scr(a)-30
  setrgb 1,100,100,100
  fill rect along(a)-3,scr(a)-30 to along(a)+3,scr(a)-40
  setrgb 1,0,100,0
  if go=1 then
   scr(a)=scr(a)+(time/200)
  endif
 next a
 for c=0 to 5
  if scr(c)-40>512 then
   scr(c)=0
   along(c)=ran(640)
  endif
 next c
 for c=0 to 5
  if fx+320<along(c)+10 and fx+320>along(c)-10 and scr(c)>440 then
   gosub die
  endif
 next c
return

label posts
 xpost=xpost
 setrgb 1,255,0,0
 fill rect xpost,ypost to xpost+30,ypost+5
 if go=1 then
  ypost=ypost+(time/200)
 endif
 if ypost>640 then
  xpost=ran(640)+50
  if xpost>600 xpost=600
  ypost=0
 endif
 if fx+320<xpost+20 and fx+320>xpost-20 and ypost>440 then
  points=points+1
 endif
 setrgb 1,255,255,0
 fill rectangle 0,0 to 640,30
 setrgb 1,0,0,0
 text 220,10,"YOU HAVE "+str$(points)+" points."
return

label die
 close window
 open window 640,512
 window origin "lb"
 setrgb 1,255,250,0
 text 150,256,"YOU CRASHED, YOU LOST, YOU LOSE!"
 text 220,10," You got "+str$(points)+" points"
 setrgb 1,200,100,100
 text 120,216,"check out yabasic.co.uk for more games"
20
goto 20



