Changeset 20670

Show
Ignore:
Timestamp:
10/04/08 13:02:36 (3 months ago)
Author:
mokehehe
Message:

きのこ追加

Location:
lang/haskell/nario
Files:
2 added
13 modified

Legend:

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

    r20661 r20670  
    22 
    33module Actor ( 
    4         Actor (..), 
    5         ObjWrapper (..), 
     4        Actor(..), 
     5        ObjWrapper(..), 
    66        updateActors, 
    77        filterActors, 
     
    1313import Event 
    1414import AppUtil 
     15import Field  
    1516 
    1617 
    1718class Actor a where 
    18         update :: a -> (a, [Event]) 
     19        update :: Field -> a -> (a, [Event]) 
    1920        render :: a -> ImageResource -> Int -> Surface -> IO () 
    2021        bDead :: a -> Bool 
    21  
     22        bDead _ = False 
    2223 
    2324-- ============================================================================ 
     
    2627data ObjWrapper = forall a. Actor a => ObjWrapper a     -- 存在型aの動く範囲を型クラスに制限 
    2728 
    28 updateActors :: [ObjWrapper] -> [(ObjWrapper, [Event])] 
    29 updateActors = map (\(ObjWrapper x) -> let (x', ev') = update x in (ObjWrapper x', ev')) 
     29updateActors :: Field -> [ObjWrapper] -> [(ObjWrapper, [Event])] 
     30updateActors fld = map (\(ObjWrapper x) -> let (x', ev') = update fld x in (ObjWrapper x', ev')) 
    3031 
    3132filterActors :: [ObjWrapper] -> [ObjWrapper] 
  • lang/haskell/nario/Actor/AnimBlock.hs

    r20661 r20670  
    77import Multimedia.SDL hiding (Event) 
    88 
    9 import Actor 
     9import Actor (Actor(..)) 
    1010import Const 
    1111import AppUtil 
     
    2727 
    2828instance Actor AnimBlock where 
    29         update self 
     29        update fld self 
    3030                | not (bDead self)      = (self', ev') 
    3131                | otherwise                     = (self, []) 
     
    5151                cc = case c of 
    5252                        '?'     -> '#' 
     53                        'K'     -> '#' 
    5354                        x       -> x 
  • lang/haskell/nario/Actor/Kuribo.hs

    r20661 r20670  
     1-- クリボー 
     2 
    13module Actor.Kuribo ( 
    24        newKuribo 
     
    57import Multimedia.SDL hiding (Event) 
    68 
    7 import Actor 
     9import Actor (Actor(..)) 
    810import Const 
    911import AppUtil 
    1012import Images 
    1113 
    12  
    13 -- ============================================================================ 
    14 -- Kuribo 
    15 --      クリボー 
    1614 
    1715data Kuribo = Kuribo { 
     
    2422 
    2523instance Actor Kuribo where 
    26         update self = (self { x = x self + vx self, cnt = cnt self + 1 }, []) 
     24        update fld self = (self { x = x self + vx self, cnt = cnt self + 1 }, []) 
    2725 
    2826        render self imgres scrx sur = do 
     
    3230                        imgtype = [ImgKuri0, ImgKuri1] !! (cnt self `mod` 16 `div` 8) 
    3331 
    34         bDead self = False 
    35  
    3632newKuribo :: Int -> Int -> Kuribo 
    3733newKuribo cx cy = 
  • lang/haskell/nario/Const.hs

    r20397 r20670  
    11module Const where 
     2 
     3-- ウィンドウ周り 
     4wndTitle = "NARIO in Haskell" 
     5screenWidth = 256 :: Int 
     6screenHeight = 224 :: Int 
     7wndBpp = 32 :: Int 
     8 
     9frameRate = 60 :: Int 
    210 
    311 
     
    513one = 256 :: Int 
    614 
    7 -- 1キャラのサイズ 
     15-- キャラのサイズ 
    816chrSize = 16 :: Int 
    917 
    1018-- 重力 
    1119gravity = one `div` 2 
    12 gravity2 = one `div` 4 
    13  
    14 {- 
    15 -- 画像 
    16 data ImageType = 
    17           ImgNarioLStand | ImgNarioLWalk1 | ImgNarioLWalk2 | ImgNarioLWalk3 | ImgNarioLJump | ImgNarioLSlip 
    18         | ImgNarioRStand | ImgNarioRWalk1 | ImgNarioRWalk2 | ImgNarioRWalk3 | ImgNarioRJump | ImgNarioRSlip 
    19         | ImgBlock1 | ImgBlock2 | ImgBlock3 | ImgBlock4 | ImgBlock5 
    20         | ImgMt02 | ImgMt11 | ImgMt12 | ImgMt13 | ImgMt22 
    21         | ImgCloud00 | ImgCloud01 | ImgCloud02 | ImgCloud10 | ImgCloud11 | ImgCloud12 
    22         | ImgDk00 | ImgDk01 | ImgDk10 | ImgDk11 
    23         | ImgGrass0 | ImgGrass1 | ImgGrass2 
    24         | ImgPole0 | ImgPole1 
    25         | ImgFont 
    26         | ImgTitle 
    27         deriving Eq 
    28  
    29  
    30 imageFn ImgNarioLStand = "narioLStand.bmp" 
    31 imageFn ImgNarioLWalk1 = "narioLWalk1.bmp" 
    32 imageFn ImgNarioLWalk2 = "narioLWalk2.bmp" 
    33 imageFn ImgNarioLWalk3 = "narioLWalk3.bmp" 
    34 imageFn ImgNarioLJump = "narioLJump.bmp" 
    35 imageFn ImgNarioLSlip = "narioLSlip.bmp" 
    36 imageFn ImgNarioRStand = "narioRStand.bmp" 
    37 imageFn ImgNarioRWalk1 = "narioRWalk1.bmp" 
    38 imageFn ImgNarioRWalk2 = "narioRWalk2.bmp" 
    39 imageFn ImgNarioRWalk3 = "narioRWalk3.bmp" 
    40 imageFn ImgNarioRJump = "narioRJump.bmp" 
    41 imageFn ImgNarioRSlip = "narioRSlip.bmp" 
    42 imageFn ImgBlock1 = "block1.bmp" 
    43 imageFn ImgBlock2 = "block2.bmp" 
    44 imageFn ImgBlock3 = "block3.bmp" 
    45 imageFn ImgBlock4 = "block4.bmp" 
    46 imageFn ImgBlock5 = "block5.bmp" 
    47 imageFn ImgMt02 = "mt02.bmp" 
    48 imageFn ImgMt11 = "mt11.bmp" 
    49 imageFn ImgMt12 = "mt12.bmp" 
    50 imageFn ImgMt13 = "mt13.bmp" 
    51 imageFn ImgMt22 = "mt22.bmp" 
    52 imageFn ImgCloud00 = "cloud00.bmp" 
    53 imageFn ImgCloud01 = "cloud01.bmp" 
    54 imageFn ImgCloud02 = "cloud02.bmp" 
    55 imageFn ImgCloud10 = "cloud10.bmp" 
    56 imageFn ImgCloud11 = "cloud11.bmp" 
    57 imageFn ImgCloud12 = "cloud12.bmp" 
    58 imageFn ImgDk00 = "dk00.bmp" 
    59 imageFn ImgDk01 = "dk01.bmp" 
    60 imageFn ImgDk10 = "dk10.bmp" 
    61 imageFn ImgDk11 = "dk11.bmp" 
    62 imageFn ImgGrass0 = "grass0.bmp" 
    63 imageFn ImgGrass1 = "grass1.bmp" 
    64 imageFn ImgGrass2 = "grass2.bmp" 
    65 imageFn ImgPole0 = "pole0.bmp" 
    66 imageFn ImgPole1 = "pole1.bmp" 
    67 imageFn ImgFont = "font.bmp" 
    68 imageFn ImgTitle = "title.bmp" 
    69  
    70 images = [ 
    71         ImgNarioLStand, ImgNarioLWalk1, ImgNarioLWalk2, ImgNarioLWalk3, ImgNarioLJump, ImgNarioLSlip, 
    72         ImgNarioRStand, ImgNarioRWalk1, ImgNarioRWalk2, ImgNarioRWalk3, ImgNarioRJump, ImgNarioRSlip, 
    73         ImgBlock1, ImgBlock2, ImgBlock3, ImgBlock4, ImgBlock5, 
    74         ImgMt02, ImgMt11, ImgMt12, ImgMt13, ImgMt22, 
    75         ImgCloud00, ImgCloud01, ImgCloud02, ImgCloud10, ImgCloud11, ImgCloud12, 
    76         ImgDk00, ImgDk01, ImgDk10, ImgDk11, 
    77         ImgGrass0, ImgGrass1, ImgGrass2, 
    78         ImgPole0, ImgPole1, 
    79         ImgFont, 
    80         ImgTitle 
    81         ] 
    82 -} 
  • lang/haskell/nario/Event.hs

    r20661 r20670  
    1  
    21module Event where 
    32 
     
    76 
    87data Event = 
     8                -- ブロックをたたいた 
    99                EvHitBlock ImageType Int Int 
     10 
     11                -- フィールドを変更 
    1012        |       EvSetField Int Int Cell 
     13 
     14                -- 敵登場 
    1115        |       EvAppearEnemy Int Int Cell 
  • lang/haskell/nario/Field.hs

    r20641 r20670  
    6464chr2img '!' = ImgPole1 
    6565 
     66chr2img 'K' = ImgBlock4 
    6667 
    6768 
    6869isBlock :: Cell -> Bool 
    69 isBlock = (`elem` "@OX?#[]l|*") 
     70isBlock = (`elem` "@OX?#[]l|*K") 
    7071 
    7172hardBlock :: Cell -> Bool 
  • lang/haskell/nario/Font.hs

    r20175 r20670  
    1313fontXN = 16 
    1414 
     15-- 文字列表示 
    1516fontPut sur imgsur x y str = zipWithM_ (\i c -> fontPutc sur imgsur i y c) [x..] str 
    1617 
     18-- 1文字表示 
    1719fontPutc sur imgsur x y c = do 
    1820        blitSurface imgsur (Just rc) sur pos 
  • lang/haskell/nario/Images.hs

    r20661 r20670  
    11module Images (ImageType(..), imageTypes, imageFn) where 
    22import Maybe (fromJust) 
    3 data ImageType = ImgBlock1 | ImgBlock2 | ImgBlock3 | ImgBlock4 | ImgBlock5 | ImgCloud00 | ImgCloud01 | ImgCloud02 | ImgCloud10 | ImgCloud11 | ImgCloud12 | ImgDk00 | ImgDk01 | ImgDk10 | ImgDk11 | ImgFlag | ImgFont | ImgGrass0 | ImgGrass1 | ImgGrass2 | ImgKuri0 | ImgKuri1 | ImgMt02 | ImgMt11 | ImgMt12 | ImgMt13 | ImgMt22 | ImgNarioDie | ImgNarioLJump | ImgNarioLSlip | ImgNarioLStand | ImgNarioLWalk1 | ImgNarioLWalk2 | ImgNarioLWalk3 | ImgNarioRJump | ImgNarioRSlip | ImgNarioRStand | ImgNarioRWalk1 | ImgNarioRWalk2 | ImgNarioRWalk3 | ImgPole0 | ImgPole1 | ImgTitle deriving (Eq) 
    4 imageTypes = [ImgBlock1, ImgBlock2, ImgBlock3, ImgBlock4, ImgBlock5, ImgCloud00, ImgCloud01, ImgCloud02, ImgCloud10, ImgCloud11, ImgCloud12, ImgDk00, ImgDk01, ImgDk10, ImgDk11, ImgFlag, ImgFont, ImgGrass0, ImgGrass1, ImgGrass2, ImgKuri0, ImgKuri1, ImgMt02, ImgMt11, ImgMt12, ImgMt13, ImgMt22, ImgNarioDie, ImgNarioLJump, ImgNarioLSlip, ImgNarioLStand, ImgNarioLWalk1, ImgNarioLWalk2, ImgNarioLWalk3, ImgNarioRJump, ImgNarioRSlip, ImgNarioRStand, ImgNarioRWalk1, ImgNarioRWalk2, ImgNarioRWalk3, ImgPole0, ImgPole1, ImgTitle] 
    5 imageFilenames = ["block1.bmp", "block2.bmp", "block3.bmp", "block4.bmp", "block5.bmp", "cloud00.bmp", "cloud01.bmp", "cloud02.bmp", "cloud10.bmp", "cloud11.bmp", "cloud12.bmp", "dk00.bmp", "dk01.bmp", "dk10.bmp", "dk11.bmp", "flag.bmp", "font.bmp", "grass0.bmp", "grass1.bmp", "grass2.bmp", "kuri0.bmp", "kuri1.bmp", "mt02.bmp", "mt11.bmp", "mt12.bmp", "mt13.bmp", "mt22.bmp", "narioDie.bmp", "narioLJump.bmp", "narioLSlip.bmp", "narioLStand.bmp", "narioLWalk1.bmp", "narioLWalk2.bmp", "narioLWalk3.bmp", "narioRJump.bmp", "narioRSlip.bmp", "narioRStand.bmp", "narioRWalk1.bmp", "narioRWalk2.bmp", "narioRWalk3.bmp", "pole0.bmp", "pole1.bmp", "title.bmp"] 
     3data ImageType = ImgBlock1 | ImgBlock2 | ImgBlock3 | ImgBlock4 | ImgBlock5 | ImgCloud00 | ImgCloud01 | ImgCloud02 | ImgCloud10 | ImgCloud11 | ImgCloud12 | ImgDk00 | ImgDk01 | ImgDk10 | ImgDk11 | ImgFlag | ImgFont | ImgGrass0 | ImgGrass1 | ImgGrass2 | ImgKinoko | ImgKuri0 | ImgKuri1 | ImgMt02 | ImgMt11 | ImgMt12 | ImgMt13 | ImgMt22 | ImgNarioDie | ImgNarioLJump | ImgNarioLSlip | ImgNarioLStand | ImgNarioLWalk1 | ImgNarioLWalk2 | ImgNarioLWalk3 | ImgNarioRJump | ImgNarioRSlip | ImgNarioRStand | ImgNarioRWalk1 | ImgNarioRWalk2 | ImgNarioRWalk3 | ImgNoko0 | ImgPole0 | ImgPole1 | ImgSnarioLJump | ImgSnarioLStand | ImgSnarioLWalk1 | ImgSnarioLWalk2 | ImgSnarioLWalk3 | ImgSnarioRJump | ImgSnarioRStand | ImgSnarioRWalk1 | ImgSnarioRWalk2 | ImgSnarioRWalk3 | ImgTitle        deriving (Eq) 
     4imageTypes = [ImgBlock1, ImgBlock2, ImgBlock3, ImgBlock4, ImgBlock5, ImgCloud00, ImgCloud01, ImgCloud02, ImgCloud10, ImgCloud11, ImgCloud12, ImgDk00, ImgDk01, ImgDk10, ImgDk11, ImgFlag, ImgFont, ImgGrass0, ImgGrass1, ImgGrass2, ImgKinoko, ImgKuri0, ImgKuri1, ImgMt02, ImgMt11, ImgMt12, ImgMt13, ImgMt22, ImgNarioDie, ImgNarioLJump, ImgNarioLSlip, ImgNarioLStand, ImgNarioLWalk1, ImgNarioLWalk2, ImgNarioLWalk3, ImgNarioRJump, ImgNarioRSlip, ImgNarioRStand, ImgNarioRWalk1, ImgNarioRWalk2, ImgNarioRWalk3, ImgNoko0, ImgPole0, ImgPole1, ImgSnarioLJump, ImgSnarioLStand, ImgSnarioLWalk1, ImgSnarioLWalk2, ImgSnarioLWalk3, ImgSnarioRJump, ImgSnarioRStand, ImgSnarioRWalk1, ImgSnarioRWalk2, ImgSnarioRWalk3, ImgTitle] 
     5imageFilenames = ["block1.bmp", "block2.bmp", "block3.bmp", "block4.bmp", "block5.bmp", "cloud00.bmp", "cloud01.bmp", "cloud02.bmp", "cloud10.bmp", "cloud11.bmp", "cloud12.bmp", "dk00.bmp", "dk01.bmp", "dk10.bmp", "dk11.bmp", "flag.bmp", "font.bmp", "grass0.bmp", "grass1.bmp", "grass2.bmp", "kinoko.bmp", "kuri0.bmp", "kuri1.bmp", "mt02.bmp", "mt11.bmp", "mt12.bmp", "mt13.bmp", "mt22.bmp", "narioDie.bmp", "narioLJump.bmp", "narioLSlip.bmp", "narioLStand.bmp", "narioLWalk1.bmp", "narioLWalk2.bmp", "narioLWalk3.bmp", "narioRJump.bmp", "narioRSlip.bmp", "narioRStand.bmp", "narioRWalk1.bmp", "narioRWalk2.bmp", "narioRWalk3.bmp", "noko0.bmp", "pole0.bmp", "pole1.bmp", "snarioLJump.bmp", "snarioLStand.bmp", "snarioLWalk1.bmp", "snarioLWalk2.bmp", "snarioLWalk3.bmp", "snarioRJump.bmp", "snarioRStand.bmp", "snarioRWalk1.bmp", "snarioRWalk2.bmp", "snarioRWalk3.bmp", "title.bmp"] 
    66imageFn = fromJust . flip lookup (zip imageTypes imageFilenames) 
  • lang/haskell/nario/Main.hs

    r20661 r20670  
    1 {-# OPTIONS_GHC -fglasgow-exts #-} 
    2  
    31-- Nario 
    42 
     
    2220import Actor.AnimBlock 
    2321import Actor.Kuribo 
    24  
    25 wndTitle = "NARIO in Haskell" 
    26 screenWidth = 256 
    27 screenHeight = 224 
    28 wndBpp = 32 
    29  
    30 frameRate = 60 
     22import Actor.Nokonoko 
     23import Actor.Kinoko 
    3124 
    3225-- 背景色 
     
    129122                cols = map (!! cx) fld 
    130123                event cy c 
    131                         | c `elem` "k"  = Just $ EvAppearEnemy cx cy c 
     124                        | c `elem` "kn" = Just $ EvAppearEnemy cx cy c 
    132125                        | otherwise             = Nothing 
    133126 
     
    155148 
    156149                                (pl', plev) = updatePlayer kp fld' (pl gs) 
    157                                 actors_updates = updateActors (actors gs) 
     150                                actors_updates = updateActors (fld gs) (actors gs) 
    158151                                actors' = filterActors $ map fst actors_updates 
    159152                                ev' = concatMap snd actors_updates 
     
    176169                        where 
    177170                                c = fieldRef (fld gs) cx cy 
    178                                 actors' = actors gs ++ [ObjWrapper $ newAnimBlock cx cy $ fieldRef (fld gs) cx cy] 
     171                                items 
     172                                        | c == 'K'      = [ObjWrapper $ newKinoko cx cy] 
     173                                        | otherwise     = [] 
     174                                actors' = actors gs ++ [ObjWrapper $ newAnimBlock cx cy $ fieldRef (fld gs) cx cy] ++ items 
    179175                                fld' = fieldSet (fld gs) cx cy '*' 
    180176                proc gs (EvSetField cx cy c) = gs { fld = fieldSet (fld gs) cx cy c } 
     
    183179                                ene = case c of 
    184180                                        'k'     -> ObjWrapper $ newKuribo cx cy 
     181                                        'n'     -> ObjWrapper $ newNokonoko cx cy 
    185182 
    186183 
  • lang/haskell/nario/Makefile

    r20661 r20670  
    2424imgs: 
    2525        runghc -itool tool/listup-imgs.hs data/img > Images.hs 
     26 
     27count: 
     28        find -name "*.hs" | xargs cat | wc 
  • lang/haskell/nario/Player.hs

    r20420 r20670  
    1  
    21-- プレーヤー 
    32 
     
    3029scrollMinX = 5 * chrSize 
    3130scrollMaxX = 8 * chrSize 
     31gravity2 = one `div` 4          -- Aを長押ししたときの重力 
    3232 
    3333data Player = Player { 
  • lang/haskell/nario/Util.hs

    r20397 r20670  
    11module Util where 
    2  
    32 
    43-- ユーティリティ関数 
  • lang/haskell/nario/data/stage0.map

    r20661 r20670  
    33                  123               1223                           123              1223                           123              1223                           123              1223              o 123      
    44        123       456      12223    4556                123        456     12223    4556                123        456     12223    4556                123        456     12223    4556              ! 456      
    5         456                45556                        456                45556                        456                45556                        456                45556                      !          
     5        456                45556                        456                45556k k                     456                45556                        456                45556                      !          
    66                      ?                                                         OOOOOOOO   OOO?              ?           OOO    O??O                                                        XX        !          
    77                                                                                                                                                                                           XXX        !          
    88                                                                                                                                                                                          XXXX        !          
    99                                                                                                                                                                                         XXXXX        !          
    10                 ?   O?O?O                     []         []                  O?O              O     OO    ?  ?  ?     O          OO      X  X          XX  X            OO?O            XXXXXX        !          
    11   _                                   []      l|  _      l|                                       _                                     XX  XX    _   XXX  XX                          XXXXXXX    _   !          
     10                ?   OKO?O                     []         []                  OKO              O     OO    ?  ?  ?     O          OO      X  X          XX  X            OO?O            XXXXXX        !          
     11  _                                   []      l|  _      l|                                      k_k                                    XX  XX    _   XXX  XX                          XXXXXXX    _   !          
    1212 /,\             _          []        l|      l| /,\     l|      _                               /,\             _                     XXX  XXX  /,\ XXXX  XXX   _ []              [] XXXXXXXX   /,\  !   OO OO  
    13 /,.,\      78889/,\ k  789  l|        l| 7889 l|/,.,\    l|78889/,\    789                      /,.,\      78889/,\    789            XXXX  XXXX/,.,XXXXX  XXXX9/,\l|  789         l|XXXXXXXXX  /,.,\ X   OO OO9 
     13/,.,\      78889/,\ k  789  l|        l|k7889 l|/,.,\k k l|78889/,\    789                      /,.,\     n78889/,\k k 789  k k  k k  XXXX  XXXX/,.,XXXXX  XXXX9/,\l|  789    k k  l|XXXXXXXXX  /,.,\ X   OO OO9 
    1414@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@  @@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@  @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 
    1515@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@  @@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@  @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@