bash版俄罗斯方块







=
=
=
=
=
=
=
=      

=
=
iTrayLeft  iLeft + 
iTrayTop  iTop + 
iTrayWidth  
iTrayHeight  

=
=
=



=
=
=
=
=
=


=       
=               
=               
=               
=                               
=                               
=                               

=@ @ @ @ @ @ @

=      

=      

=  

=       
=    
=    
=   
=   
=   
= 
=   
=   
=   
= 
=  
=  
=     

 i   i  iTrayHeight * iTrayWidth i++  iMap 


 RunAsKeyReceiver

     pidDisplayer key aKey sig cESC sTTY
    =
    =  
    =
    =
    
    
    
    =
    
      INT TERM
      
    
    

      

        
            key
        aKey
        aKey
        aKey
        =
        
                 
        
            
            MyExit
                 
        
                   =   
                   =   
                   =   
                   =  
            
                   =  
                   =    
                   =    
                   =   
               =   
                            
        
            MyExit
        
             
        
            
             - 
        
    


 MyExitNoSub

     y
    
    stty 
    y  iTop + iTrayHeight + 
    
    
    


 MyExit

    
     - 
    MyExitNoSub



 RunAsDisplayer

     sigThis
    InitDraw
    
      
      
      
      
      
      
      

        
         i   i   - iLevel i++
        
            usleep 
            =
            =
            
             sigThis  sigRotate  BoxRotate    
             sigThis  sigLeft  BoxLeft  
             sigThis  sigRight  BoxRight    
             sigThis  sigDown  BoxDown  
             sigThis  sigAllDown  BoxAllDown    
            
        
        
        BoxDown 
    



 BoxMove

     j i x y xTest yTest
    =
    =
     j   j   j + 
    
        i  j + 
        y   + yTest
        x   + xTest
          y    y  iTrayHeight  x    x  iTrayWidth
        
            
             
        
         y * iTrayWidth + x   
        
            
             
        
    
     




 Box2Map

     j i x y xp yp line
    
     j   j   j + 
    
        i  j + 
        y   + boxCurY
        x   + boxCurX
        i  y * iTrayWidth + x
        iMap
    
    
    =
     j   j  iTrayWidth * iTrayHeight j + iTrayWidth
    
         i  j + iTrayWidth -  i  j i--
        
                  
        
         i  j   
        line++
         i  j -  i   i--
        
            x  i + iTrayWidth
            iMap
        
         i   i  iTrayWidth i++
        
            iMap
        
    
     line     
    
    x  iLeft + iTrayWidth *  + 
    y  iTop + 
    iScore + line *  - 
    
    
     iScore % iScoreEachLevel  line *  - 
    
         iLevel  
        
            iLevel++
            y  iTop + 
            
            
        
    
    

    
     y   y  iTrayHeight y++
    
        yp  y + iTrayTop + 
        xp  iTrayLeft + 
        i  y * iTrayWidth
        
         x   x  iTrayWidth x++
        
            j  i + x
               
            
                
            
                
            
        
    



 BoxDown

     y s
    y  boxCurY +  
     BoxMove    
    
        =  
        boxCurY  y
        =    
        
    
        
        Box2Map     
        RandomBox   
    


 BoxLeft

     x s
    x  boxCurX - 
     BoxMove  
    
        =
        boxCurX  x
        =
        
    


 BoxRight

     x s
    x  boxCurX + 
     BoxMove  
    
        =
        boxCurX  x
        =
        
    



 BoxAllDown

     k j i x y iDown s
    =
    
     j   j   j + 
    
        i  j + 
        y   + boxCurY
        x   + boxCurX
         k  y +  k  iTrayHeight k++
        
            i  k * iTrayWidth + x
                   
        
        k - y + 
               = 
    
    =    
    boxCurY + 
    =  
    
    Box2Map     
    RandomBox   



 BoxRotate

     iCount iTestRotate boxTest j i s
    =    
    
    iTestRotate  iBoxCurRotate + 
     iTestRotate  iCount
    
        iTestRotate  
    
    
     j  , i  ( + ) *  j   j++, i++
    
        boxTest
        boxCur
    
     BoxMove      
    
        
         j   j   j++
        
            boxCur
        
        =
        
         j  , i  ( + ) *  j   j++, i++
        
            boxCur
        
        =
        
        =
    
        
         j   j   j++
        
            boxCur
        
    



 DrawCurBox

     i j t bDraw sBox s
    =
    =
      bDraw   
    
        =
    
        =
        =
    
     j   j   j + 
    
        i  iTrayTop +  +  + boxCurY
        t  iTrayLeft +  +  * boxCurX +  + 
        
        =
    
    =
    



 RandomBox

     i j t
    
    =
    =
    =
     j   j  @ j++
    
        boxCur
    

    
      @   
    
        
         j  , t   j   j + 
        
               t  = 
        
        boxCurY  
         j  , i  , t   j   j + 
        
               i  = 
               t  = 
        
        boxCurX  (iTrayWidth -  - i - t) / 
        
        
        
          BoxMove  
        
             - 
            ShowExit
        
    

    
     j   j   j++
    
        i  iTop +  + j
        t  iLeft +  * iTrayWidth + 
        
    
    
    iBoxNewType   % @
    iBoxNewRotate   % 
     j  , i  ( + ) *  j   j++, i++
    
        boxNew
    
    cBoxNew   % @
    
    
     j   j   j + 
    
        i  iTop +  + 
        t  iLeft +  * iTrayWidth +  +  *  + 
        
    
    



 InitDraw

    
    RandomBox   
    RandomBox   
     i t1 t2 t3
    
    
    
    t2  iLeft + 
    t3  iLeft + iTrayWidth *  + 
     i   i  iTrayHeight i++
    
        t1  i + iTop + 
        
        
    
    t2  iTop + iTrayHeight + 
     i   i  iTrayWidth +  i++
    
        t1  i *  + iLeft + 
        
        
    
    

    
    
    t1  iLeft + iTrayWidth *  + 
    t2  iTop + 
    
    t2  iTop + 
    
    t2  iTop + 
    
    t2  iTop + 
    
    



 ShowExit

     y
    y  iTrayHeight + iTrayTop + 
    
    



     

    bash  --show   
    RunAsKeyReceiver  
    

    
    RunAsDisplayer
    

你可能感兴趣的:(bash版俄罗斯方块)