Show
Ignore:
Timestamp:
10/04/08 07:57:29 (3 months ago)
Author:
mokehehe
Message:

スクロールで敵を出すように
ディレクトリ分割

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/haskell/nario/Actor.hs

    r20641 r20661  
    11{-# OPTIONS_GHC -fglasgow-exts #-} 
    22 
    3 module Actor where 
     3module Actor ( 
     4        Actor (..), 
     5        ObjWrapper (..), 
     6        updateActors, 
     7        filterActors, 
     8        renderActors 
     9) where 
    410 
    5 import Multimedia.SDL hiding (Event) 
     11import Multimedia.SDL (Surface) 
    612 
    7 import Const 
    8 import Images 
    9 import Util 
     13import Event 
    1014import AppUtil 
    11 import Event 
    12 import Field 
     15 
    1316 
    1417class Actor a where 
     
    1922 
    2023-- ============================================================================ 
    21 -- AnimBlock 
    22 --      ブロックを叩いたときのバウンド演出 
    23  
    24 data AnimBlock = AnimBlock { 
    25         startcy :: Int, 
    26         x :: Int, 
    27         y :: Int, 
    28         vy :: Int, 
    29         chr :: Cell 
    30         } 
    31  
    32 instance Actor AnimBlock where 
    33         update self 
    34                 | not (bDead self)      = (self', ev') 
    35                 | otherwise                     = (self, []) 
    36  
    37                 where 
    38                         vy' = vy self + gravity 
    39                         y' = y self + vy' 
    40                         self' = self { vy = vy', y = y' } 
    41                         ev' = if (bDead self') 
    42                                 then [EvSetField (cellCrd $ x self) (startcy self) $ chr self] 
    43                                 else [] 
    44  
    45         render self imgres scrx sur = do 
    46                 blitSurface (getImageSurface imgres $ chr2img $ chr self) Nothing sur (pt ((x self) `div` one - scrx) ((y self) `div` one - 8)) 
    47                 return () 
    48  
    49         bDead self = vy self > 0 && y self >= startcy self * chrSize * one 
    50  
    51 newAnimBlock :: Int -> Int -> Cell -> AnimBlock 
    52 newAnimBlock cx cy c = 
    53         AnimBlock { startcy = cy, x = cx * chrSize * one, y = cy * chrSize * one, vy = -3 * one, chr = cc } 
    54         where 
    55                 cc = case c of 
    56                         '?'     -> '#' 
    57                         x       -> x 
    58  
    59  
    60 -- ============================================================================ 
    6124 
    6225---- 
    63 data ObjWrapper = forall a. Actor a => ObjWrapper a     -- ݌^a͈̓͂잃NXDuckɐ 
     26data ObjWrapper = forall a. Actor a => ObjWrapper a     -- 存在型aの動く範囲を型クラスに制限 
    6427 
    6528updateActors :: [ObjWrapper] -> [(ObjWrapper, [Event])]