home *** CD-ROM | disk | FTP | other *** search
/ 17 Bit Software 1: Collection A / 17Bit_Collection_A.iso / files / 133.dms / 133.adf / Á / Slider < prev    next >
Text File  |  1988-07-25  |  4KB  |  83 lines

  1. '****************************
  2. '* Slider game by Don Moore *
  3. '* P.O. Box 1405            *     Last Rev: Oct 16, 1986
  4. '* Coconut Grove, Fl 33133  *
  5. '****************************
  6.  
  7. 'CLS : SCREEN 2,320,200,1,1           'hide houskeeping
  8.  
  9. DIM a%(46),b%(46,100),c%(10*46),r(100)                     ' ***************
  10. LINE(24,22)-(46,32),1,bf:LINE(26,23)-(44,31),3,bf          '
  11. GET(24,22)-(46,32),a%   :LOCATE 4   : COLOR 2,0            '
  12.                                                            
  13. RANDOMIZE TIMER                                            '
  14.                                             
  15. n = INT(RND(1)*8)+3 :  m = n * n      'change n to change matrix size    '
  16.                                                            
  17.  FOR i = 1 TO m                      '***********          '
  18.    find: t = INT( RND(1) * m + 1 )   ' mix up              '  setup graphics
  19.    IF r(t) THEN find ELSE r(t) = i   ' numbers             '    and make
  20.  NEXT                                '***********          '    gameboard
  21.                                                            
  22.  b= r(m)                             'blank space          '
  23.                                                            
  24.  FOR i = 1 TO m-1                    '***********          '
  25.   LINE(24,22)-(46,33),0,bf           '                     '
  26.   PRINT PTAB(20-(i<10)*4);i;         'make tiles           '          
  27.   PUT(24,22),a%                      '                     '
  28.   GET(24,22)-(46,32),b%(0,r(i))      '                     ' 
  29.  NEXT                                '***********          '
  30.                                                            '   
  31. WINDOW 1,"N-Slider",(0,0)-(26*n-4,12*n-2),26,-1              '
  32.                                                            '
  33.  CLS                                                       '
  34.                                                            '
  35.  FOR i = 0 TO n-1                   ' **************       '
  36.   FOR k = 0 TO n-1                  '                      '
  37.    PUT(26*i,12*k),b%(0,i+1+k*n)     ' draw gameboard       '
  38.   NEXT                              '                      '
  39.  NEXT                               ' **************       '************** 
  40.  
  41.  SCREEN CLOSE 2                     ' show board, housekeeping done
  42.                               
  43.  
  44. WHILE 1              '*** main ***
  45. WHILE MOUSE(0) <> 0
  46.  x = INT(MOUSE(3)/26)        :y = INT(MOUSE(4)/12)
  47.  c = (x*ABS(x<n)+n*y*ABS(y<n)+1)*ABS(x<n)*ABS(y<n)        ' c = mousechoice
  48.  
  49.   IF c > 0 THEN                                           ' within bounds?
  50.     cr = INT((c - 1) / n)      :cc = c - cr * n -1        ' choicerow & col
  51.     br = INT((b - 1) / n)      :bc = b - br * n -1        ' blankrow  & col
  52.     
  53.     ON ABS((br=cr)+(bc=cc)*2)+1 GOTO illegal,leftright,updown,illegal
  54.   
  55.     leftright: ON ABS((bc>cc)+(bc<cc)*2) GOTO right,left
  56.     
  57.     updown:    ON ABS((br>cr)+(br<cr)*2) GOTO down,up
  58.     
  59.     right:     GET(cc*26,cr*12)-((bc-1)*26+24,cr*12+10),c%:PUT(cc*26,cr*12),c%
  60.       FOR i = 1 TO 26 STEP 8: PUT(cc*26+i,cr*12),c%: PUT(cc*26+i,cr*12),c%:NEXT
  61.        PUT(cc*26+i-7,cr*12),c%  :GOTO done
  62.        
  63.     left:      GET((bc+1)*26,cr*12)-(cc*26+24,cr*12+10),c%:PUT((bc+1)*26,cr*12),c%
  64.       FOR i = 26 TO 1 STEP -8:PUT(bc*26+i,cr*12),c%:PUT(bc*26+i,cr*12),c%:NEXT 
  65.       :PUT(bc*26,cr*12),c%     :GOTO done
  66.       
  67.     down:      GET(cc*26,cr*12)-(cc*26+24,(br-1)*12+10),c%:PUT(cc*26,cr*12),c%
  68.       FOR i = 1 TO 12 STEP 4: PUT(cc*26,cr*12+i),c% : PUT(cc*26,cr*12+i),c%:NEXT
  69.       PUT(cc*26,cr*12+i-1),c%    :GOTO done
  70.       
  71.     up:        GET(cc*26,(br+1)*12)-(cc*26+24,cr*12+10),c%:PUT(cc*26,(br+1)*12),c%
  72.       FOR i = 12 TO 1 STEP -4:PUT(cc*26,br*12+i),c%:PUT(cc*26,br*12+i),c%:NEXT
  73.       PUT(cc*26,br*12),c%
  74.         
  75.     done:     b = c                           'choice becomes the blank
  76.     illegal:                                  'a good place to bail out
  77.  
  78.   END IF
  79.   
  80. WEND
  81. WEND
  82.  
  83.