include "window.inc"
Window "Soft Scroll",320,240,2
Font 10,12,0,"times"

sys i,yGraph,xGraph,xScr,yScr,x,y,bx,ax,cx,dx,b,s1,s2,zG
Single zV
Dim Map(1200) As Byte

s2 = LoadBmp "images\mine",8

yGraph = 240/16 
xGraph = 320/16 

'Fill Play field with 0 and 1 
For y = 0 To 29
   For x = 0 To 39 
       bx = y*40 + x
       Map(bx) = Rand(0,8)  
   Next 
Next 

'Scrolling here   
while AscKey=0 and WinExit=0
   'SetBmp s1,0,0,320,240,0
   for y=0 to 239
     line 0,y,320,y,25,10,10,240-y
   next
   sys_seed=0x35353535
   for i=0 to 100
      poke rand(0,319),rand(0,239),rand(128,200),rand(128,200),rand(128,200)
   next
   dx = xScr /16 
   cx = yScr /16 
   for y = cx to cx + yGraph
      for x = dx to dx + xGraph
         bx = y*20 + x
         if Map(bx) =1  
            SetBmp s2,x*16-xScr,y*16-yScr,16,16,zG 
         endif
      next 
   next  
   zV = zV + 0.4
   if zV >=1.0
      zV=0
      zG = zG + 1
      if zG=8 then zG=0  
   endif
   
   'Movement here
   if Key(39) then xScr = xScr -2 
   if Key(37) then xScr = xScr +2 
   if Key(40) then yScr = yScr -2 
   if Key(38) then yScr = yScr +2 
   if xScr < 0   then xScr = 0
   if yScr < 0   then yScr = 0 
   if xScr > 320 then xScr = 320 
   if yScr > 240 then yScr = 240 
   Text 0, 0,"X:" + str(xScr),255,255,255  
   Text 64,0,"Y:" + str(yScr),255,255,255
   Events
   FlipBuffer
   WaitFPS 60 
wend
WinEnd