Changeset 20045 for lang/haskell

Show
Ignore:
Timestamp:
09/27/08 18:15:45 (2 months ago)
Author:
mokehehe
Message:

1-1のマップ作成

Location:
lang/haskell/nario
Files:
6 modified

Legend:

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

    r20026 r20045  
    2828chr2img '@' = ImgBlock1 
    2929chr2img 'O' = ImgBlock2 
     30chr2img 'X' = ImgBlock3 
    3031chr2img '?' = ImgBlock4 
    3132chr2img '_' = ImgMt02 
     
    4849chr2img '|' = ImgDk11 
    4950 
     51chr2img '!' = ImgDk11 
     52chr2img 'o' = ImgDk11 
     53 
    5054 
    5155isBlock :: Cell -> Bool 
    52 isBlock c = c `elem` "@O?[]l|" 
     56isBlock c = c `elem` "@OX?[]l|" 
    5357 
    5458inField :: Field -> Int -> Int -> Bool 
     
    6165 
    6266 
    63 renderField sur imgres scrx fld = sequence_ $ concatMap lineProc $ zip [0..] fld 
     67renderField sur imgres scrx fld = 
     68        sequence_ $ concatMap lineProc $ zip [0..] fld 
    6469        where 
    65                 lineProc (y, ln) = map (cellProc y) $ zip [0..] ln 
    66                 cellProc y (x, c) = do 
    67                         if c == ' ' 
    68                                 then return () 
    69                                 else do 
    70                                         blitSurface (getImageSurface imgres $ chr2img c) Nothing sur $ pt (x*16 - scrx) (y*16) 
    71                                         return () 
     70                lineProc (y, ln) = map (cellProc y) $ zip [0..] $ window ln 
     71                cellProc _ (_, ' ') = return () 
     72                cellProc y (x, c) = putchr x y c >> return () 
     73                putchr x y c = blitSurface (getImageSurface imgres $ chr2img c) Nothing sur $ pt (x*chrSize - rx) (y*chrSize) 
    7274 
     75                -- 表示される部分だけ取り出す 
     76                window = take w . drop qx 
     77                qx = scrx `div` chrSize 
     78                rx = scrx `mod` chrSize 
     79                w = 256 `div` chrSize + 1 
  • lang/haskell/nario/Main.hs

    r20026 r20045  
    2323wndSize  = sz 256 240 
    2424 
     25frameRate = 60 
     26 
    2527-- 背景色 
    2628backColor = 0x2891ff            -- 青 
     
    3638        imgres <- loadImageResource 
    3739 
    38         et <- elapseTime 60 
     40        et <- elapseTime frameRate 
    3941        loop et gs onProcess (onDraw sur imgres) [] 
    4042 
     
    4547                modifyIORef gs $ op $ keyProc bef ks 
    4648                st <- readIORef gs 
    47                 (fps,draw) <- et 
     49                (fps, draw) <- et 
    4850                when draw $ od st 
    4951                loop et gs op od ks 
     
    5759                        | ks == SDLK_F4 && (KMOD_LALT `elem` km || 
    5860                                                                KMOD_RALT `elem` km) -> return True 
    59                 Nothing                 -> return False 
    60                 _                               -> checkEvent 
    61  
     61                Nothing -> return False 
     62                _               -> checkEvent 
    6263 
    6364sdlStart fs title (Size w h) p = do 
    6465        True <- sdlInit fs 
    6566        setCaption title title 
    66         sur  <- setVideoMode w h 32 [HWSURFACE,DOUBLEBUF,ANYFORMAT] 
     67        sur <- setVideoMode w h 32 [HWSURFACE, DOUBLEBUF, ANYFORMAT] 
    6768        p sur 
    6869        sdlQuit 
     70 
    6971 
    7072-- ゲームの状態 
  • lang/haskell/nario/Player.hs

    r20025 r20045  
    3838 
    3939newPlayer = Player { 
    40         x = 1 * chrSize * one, 
    41         y = 1 * chrSize * one, 
     40        x = 3 * chrSize * one, 
     41        y = 13 * chrSize * one, 
    4242        vx = 0, 
    4343        vy = 0, 
     
    6060        [ImgNario10, ImgNario11, ImgNario12, ImgNario13, ImgNario14] 
    6161        ] 
     62 
     63 
     64cellCrd :: Int -> Int 
     65cellCrd x = x `div` (chrSize * one) 
    6266 
    6367 
     
    101105 
    102106 
    103 cellCrd :: Int -> Int 
    104 cellCrd x = x `div` (chrSize * one) 
    105  
    106  
    107107-- ジャンプ中 
    108108jump :: Field -> Player -> Player 
     
    143143                yground y = (cellCrd y) * (chrSize * one) 
    144144 
    145  
     145-- 更新処理 
    146146updatePlayer :: KeyProc -> Field -> Player -> Player 
    147147updatePlayer kp fld player = 
     
    152152                        | otherwise                     = jump fld 
    153153 
    154  
     154-- スクロール位置取得 
    155155getScrollPos :: Player -> Int 
    156156getScrollPos player = (scrx player) `div` one 
    157157 
     158-- 描画 
    158159renderPlayer sur imgres scrx player = do 
    159160        blitSurface (getImageSurface imgres imgtype) Nothing sur pos 
  • lang/haskell/nario/README.txt

    r20026 r20045  
    1313                �㉺���E 
    1414 
    15         �X�y�[�X�L�[ 
     15        �X�y�[�X�L�[, z 
    1616                A�{�^�� 
    1717 
     
    3030                �摜�f�[�^ 
    3131 
     32 
     33 
     34 
     35 
     36 
     37���Q�l 
     38        Super Nario GC 
     39        http://d.hatena.ne.jp/authorNari/20080422/1208880928 
     40 
     41        1-1 �}�b�v 
     42        http://www.geocities.co.jp/SiliconValley-Sunnyvale/6160/newtech/m11.htm 
     43 
  • lang/haskell/nario/Util.hs

    r20026 r20045  
    5858mapPhyKey PadL = [SDLK_LEFT, SDLK_j] 
    5959mapPhyKey PadR = [SDLK_RIGHT, SDLK_l] 
    60 mapPhyKey PadA = [SDLK_SPACE] 
     60mapPhyKey PadA = [SDLK_SPACE, SDLK_z] 
    6161mapPhyKey PadB = [SDLK_LSHIFT, SDLK_RSHIFT] 
    6262 
  • lang/haskell/nario/data/stage0.map

    r20026 r20045  
    1                                                  
    2                   123               1223         
    3         123       456      12223    4556         
    4         456                45556                 
    5                                                  
    6                       ?                          
    7                                                  
    8                                                  
    9                                                  
    10    _            ?   O?O?O                     [] 
    11   /,\                                 []      l| 
    12  /,.,\           _          []        l|      l| 
    13 /.....\    78889/,\    789  l|        l| 7889 l| 
    14 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 
    15 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 
     1                                                                                                                                                                                                                 
     2                  123               1223                           123              1223                                                                                                              o          
     3        123       456      12223    4556                123        456     12223    4556                           123              1223                           123              1223              | 123      
     4        456                45556                        456                45556                        123        456     12223    4556                123        456     12223    4556              ! 456      
     5                                                                                                        456                45556                        456                45556                      !          
     6                      ?                                                         OOOOOOOO   OOO?              ?           OOO    O??O                                                        XX        !          
     7                                                                                                                                                                                           XXX        !          
     8                                                                                                                                                                                          XXXX        !          
     9                                                                                                                                                                                         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    _   !          
     12 /,\             _          []        l|      l| /,\     l|      _                               /,\             _                     XXX  XXX  /,\ XXXX  XXX   _ []              [] XXXXXXXX   /,\  !   OO OO  
     13/,.,\      78889/,\    789  l|        l| 7889 l|/,.,\    l|78889/,\    789                      /,.,\      78889/,\    789            XXXX  XXXX/,.,XXXXX  XXXX9/,\l|  789         l|XXXXXXXXX  /,.,\ X   OO OO9 
     14@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@  @@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@  @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 
     15@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@  @@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@  @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@