Show
Ignore:
Timestamp:
09/27/08 09:31:17 (3 months ago)
Author:
mokehehe
Message:

ソースの文字コードを utf-8 に変更

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/haskell/tetris/Player.hs

    r20002 r20003  
    1111-- constant definition 
    1212 
    13 -- �t���[�����[�g 
     13-- フレームレート 
    1414frameRate = 40 
    1515 
    16 -- �Z���̕\���T�C�Y 
     16-- セルの表示サイズ 
    1717cellWidth  = 16 
    1818cellHeight = 16 
    1919 
    20 -- �f�t�H���g�̗������x 
     20-- デフォルトの落下速度 
    2121defaultFallSpeed = 1 
    2222 
    23 -- �������E���^ 
     23-- 落ちるカウンタ 
    2424blockFallCount = 40 
    2525 
    26 -- �u���b�N�����n���Ă����肳���܂ł̎���fixedTimer = frameRate `div` 2 
     26-- ブロックが着地してから固定されるまでの時間 
     27fixedTimer = frameRate `div` 2 
    2728 
    2829-------------------------------- 
     
    3940scaleColor s (r,g,b) = (s*r, s*g, s*b) 
    4041 
    41 -- ���̈����Ԃ� 
     42-- 矩形領域塗りつぶし 
    4243fill x y w h (r,g,b) = do 
    4344        color3i r g b 
     
    5354                iy2 = fromInteger $ toInteger $ y + h 
    5455 
    55 -- �Z������i���Â��� 
     56-- セルを描く(明暗あり) 
    5657renderCell col@(r,g,b) ix iy = do 
    5758        fill x y (cellWidth-1) (cellHeight-1) col 
     
    7374                y = iy * cellHeight 
    7475 
    75 -- �t�B�[���h�`��enderBoard board = mapM_ lineProc $ zip [0..] board 
     76-- フィールド描画 
     77renderBoard board = mapM_ lineProc $ zip [0..] board 
    7678        where 
    7779                lineProc (iy, line) = mapM_ (cellProc iy) $ zip [0..] line 
     
    7981                cellProc iy (ix, cell)  = renderCell (cellColor cell) ix iy 
    8082 
    81 -- �u���b�N��‚��ŕ`��enderBlockTypeCol col blktype ix iy rot = do 
     83-- ブロックを色つきで描画 
     84renderBlockTypeCol col blktype ix iy rot = do 
    8285        sequence_ $ concat $ idxmap2 proc pat 
    8386        where 
     
    112115} 
    113116 
    114 -- �u���b�N��b�h�ňړ� 
     117-- ブロックをパッドで移動 
    115118updateBlock :: Board -> Pad -> Block -> Block 
    116119updateBlock board pad block = 
     
    164167                oldycnt = ycnt block 
    165168 
    166 -- �u���b�N���n�ʂɂ‚��ČŒ肳�ꂽ���H 
     169-- ブロックが地面について固定されたか? 
    167170isBlockFixed block = (fixedcnt block) > fixedTimer 
    168171 
    169 -- ���쒆�̃u���b�N�`��enderBlock block = 
     172-- 操作中のブロック描画 
     173renderBlock block = 
    170174        renderBlockType (blktype_of block) (x block) (y block) (rot block) 
    171175 
    172 -- �S�[�X�g�u���b�N�`��enderGhostBlock board block = 
     176-- ゴーストブロック描画 
     177renderGhostBlock board block = 
    173178        renderBlockTypeCol col (blktype_of block) (x block) landY (rot block) 
    174179        where 
     
    220225        } 
    221226 
    222 -- �ʏ펞 
     227-- 通常時 
    223228updatePlayerNormal pad player 
    224         -- �ʏ�| not (isBlockFixed block)        = return $ player { block_of = block' } 
    225         -- �ڒn�����Ƃ��F�t�B�[���h�Ɋi�[���Ď��̃u���b�N��� 
     229        -- 通常 
     230        | not (isBlockFixed block)      = return $ player { block_of = block' } 
     231        -- 接地したとき:フィールドに格納して次のブロックを出す 
    226232        | otherwise     = do 
    227233                if null filled 
     
    239245                filled = getFilledLines storedBoard 
    240246 
    241 -- ���������C������������ԑ҂� 
     247-- そろったラインを消した後の時間待ち 
    242248updatePlayerErase filled pad player = 
    243249        if (not $ null filled) && (cnt player) < (frameRate `div` 2) 
     
    248254                score' = (score player) + 10 * square (length filled) 
    249255 
    250 -- ���������C������ĉ��ɋl�߂������ԑ҂� 
     256-- そろったラインを消して下に詰めた後の時間待ち 
    251257updatePlayerErase2 pad player = 
    252258        if (cnt player) < (frameRate `div` 2) 
     
    254260                else    setupNextBlock player 
    255261 
    256 -- ���S 
     262-- 死亡 
    257263updatePlayerDead pad player = return player 
    258264 
    259 -- ���̃u���b�N��� 
     265-- 次のブロックを出す 
    260266setupNextBlock player = do 
    261267        if canMove board nxtblk (x nxtBlock) (y nxtBlock) (rot nxtBlock) 
    262                 then do         -- �o������             nxt' <- randBlockType           -- ���̎��̃u���b�N�𗐐��őI��                       return $ player { block_of = nxtBlock, nxtblktype = nxt', stat = PlNormal, updater = updatePlayerNormal } 
    263                 else do         -- �l�܂�Ă����S 
     268                then do         -- 登場できる 
     269                        nxt' <- randBlockType           -- 次の次のブロックを乱数で選ぶ 
     270                        return $ player { block_of = nxtBlock, nxtblktype = nxt', stat = PlNormal, updater = updatePlayerNormal } 
     271                else do         -- 詰まってる:死亡 
    264272                        let storedBoard = storeBlock board nxtblk (x nxtBlock) (y nxtBlock) (rot nxtBlock) 
    265273                        return $ player { board_of = storedBoard, stat = PlDead, updater = updatePlayerDead } 
    266274        where 
    267                 nxtblk = nxtblktype player              -- ���̃u���b�N�̎� 
     275                nxtblk = nxtblktype player              -- 次のブロックの種類 
    268276                nxtBlock = newBlock nxtblk nxtFallSpd 
    269277                nxtFallSpd = if curFallSpd < blockFallCount then curFallSpd + 1 else defaultFallSpeed 
     
    272280 
    273281 
    274 -- �X�V 
     282-- 更新 
    275283updatePlayer :: Pad -> Player -> IO Player 
    276284updatePlayer pad player = (updater player) pad player