Changeset 20775 for lang/haskell

Show
Ignore:
Timestamp:
10/05/08 16:27:31 (2 months ago)
Author:
mokehehe
Message:

エフェクトオブジェクト(コイン取得、スコア加算、ブロック破壊)追加

Location:
lang/haskell/nario
Files:
3 added
6 modified

Legend:

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

    r20670 r20775  
    1414import Event 
    1515 
    16 -- ============================================================================ 
    17 -- AnimBlock 
    18 --      ブロックを叩いたときのバウンド演出 
    1916 
    2017data AnimBlock = AnimBlock { 
     
    4037 
    4138        render self imgres scrx sur = do 
    42                 blitSurface (getImageSurface imgres $ chr2img $ chr self) Nothing sur (pt ((x self) `div` one - scrx) ((y self) `div` one - 8)) 
     39                blitSurface (getImageSurface imgres $ chr2img $ chr self) Nothing sur (pt (x self `div` one - scrx) (y self `div` one - 8)) 
    4340                return () 
    4441 
  • lang/haskell/nario/Actor/Kinoko.hs

    r20680 r20775  
    1313import Images 
    1414import Field 
    15 import Player (PlayerType(..), getPlayerType, setPlayerType) 
     15import Player (PlayerType(..), getPlayerType, setPlayerType, addScore) 
    1616 
    1717maxVy = one * 6 
     18 
     19pointKinoko = 1000 
    1820 
    1921 
     
    5355                        yy = y self `div` one 
    5456 
    55         onHit pl self = (setPlayerType nt pl, Nothing) 
     57        onHit pl self = (addScore pointKinoko $ setPlayerType nt pl, Nothing) 
    5658                where 
    5759                        nt = case typ of 
  • lang/haskell/nario/Event.hs

    r20680 r20775  
    1414                -- 敵登場 
    1515        |       EvAppearEnemy Int Int Cell 
     16 
     17                -- スコア加算エフェクト 
     18        |       EvScoreAddEfe Int Int ImageType 
  • lang/haskell/nario/Images.hs

    r20691 r20775  
    11module Images (ImageType(..), imageTypes, imageFn) where 
    22import Maybe (fromJust) 
    3 data ImageType = ImgBlock1 | ImgBlock2 | ImgBlock3 | ImgBlock4 | ImgBlock5 | ImgCloud00 | ImgCloud01 | ImgCloud02 | ImgCloud10 | ImgCloud11 | ImgCloud12 | ImgCoin0 | ImgCoin1 | ImgCoin2 | ImgCoin3 | ImgDk00 | ImgDk01 | ImgDk10 | ImgDk11 | ImgFlag | ImgFlower | ImgFNarioLJump | ImgFNarioLShot | ImgFNarioLSit | ImgFNarioLSlip | ImgFNarioLStand | ImgFNarioLWalk1 | ImgFNarioLWalk2 | ImgFNarioLWalk3 | ImgFNarioRJump | ImgFNarioRShot | ImgFNarioRSit | ImgFNarioRSlip | ImgFNarioRStand | ImgFNarioRWalk1 | ImgFNarioRWalk2 | ImgFNarioRWalk3 | ImgFont | ImgGrass0 | ImgGrass1 | ImgGrass2 | ImgKinoko | ImgKuri0 | ImgKuri1 | ImgKuriDead | ImgMt02 | ImgMt11 | ImgMt12 | ImgMt13 | ImgMt22 | ImgNarioDead | ImgNarioLJump | ImgNarioLSlip | ImgNarioLStand | ImgNarioLWalk1 | ImgNarioLWalk2 | ImgNarioLWalk3 | ImgNarioRJump | ImgNarioRSlip | ImgNarioRStand | ImgNarioRWalk1 | ImgNarioRWalk2 | ImgNarioRWalk3 | ImgNoko0 | ImgNoko1 | ImgPole0 | ImgPole1 | ImgSNarioLJump | ImgSNarioLSit | ImgSNarioLSlip | ImgSNarioLStand | ImgSNarioLWalk1 | ImgSNarioLWalk2 | ImgSNarioLWalk3 | ImgSNarioRJump | ImgSNarioRSit | ImgSNarioRSlip | ImgSNarioRStand | ImgSNarioRWalk1 | ImgSNarioRWalk2 | ImgSNarioRWalk3 | ImgTitle      deriving (Eq) 
    4 imageTypes = [ImgBlock1, ImgBlock2, ImgBlock3, ImgBlock4, ImgBlock5, ImgCloud00, ImgCloud01, ImgCloud02, ImgCloud10, ImgCloud11, ImgCloud12, ImgCoin0, ImgCoin1, ImgCoin2, ImgCoin3, ImgDk00, ImgDk01, ImgDk10, ImgDk11, ImgFlag, ImgFlower, ImgFNarioLJump, ImgFNarioLShot, ImgFNarioLSit, ImgFNarioLSlip, ImgFNarioLStand, ImgFNarioLWalk1, ImgFNarioLWalk2, ImgFNarioLWalk3, ImgFNarioRJump, ImgFNarioRShot, ImgFNarioRSit, ImgFNarioRSlip, ImgFNarioRStand, ImgFNarioRWalk1, ImgFNarioRWalk2, ImgFNarioRWalk3, ImgFont, ImgGrass0, ImgGrass1, ImgGrass2, ImgKinoko, ImgKuri0, ImgKuri1, ImgKuriDead, ImgMt02, ImgMt11, ImgMt12, ImgMt13, ImgMt22, ImgNarioDead, ImgNarioLJump, ImgNarioLSlip, ImgNarioLStand, ImgNarioLWalk1, ImgNarioLWalk2, ImgNarioLWalk3, ImgNarioRJump, ImgNarioRSlip, ImgNarioRStand, ImgNarioRWalk1, ImgNarioRWalk2, ImgNarioRWalk3, ImgNoko0, ImgNoko1, ImgPole0, ImgPole1, ImgSNarioLJump, ImgSNarioLSit, ImgSNarioLSlip, ImgSNarioLStand, ImgSNarioLWalk1, ImgSNarioLWalk2, ImgSNarioLWalk3, ImgSNarioRJump, ImgSNarioRSit, ImgSNarioRSlip, ImgSNarioRStand, ImgSNarioRWalk1, ImgSNarioRWalk2, ImgSNarioRWalk3, 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", "coin0.bmp", "coin1.bmp", "coin2.bmp", "coin3.bmp", "dk00.bmp", "dk01.bmp", "dk10.bmp", "dk11.bmp", "flag.bmp", "flower.bmp", "fNarioLJump.bmp", "fNarioLShot.bmp", "fNarioLSit.bmp", "fNarioLSlip.bmp", "fNarioLStand.bmp", "fNarioLWalk1.bmp", "fNarioLWalk2.bmp", "fNarioLWalk3.bmp", "fNarioRJump.bmp", "fNarioRShot.bmp", "fNarioRSit.bmp", "fNarioRSlip.bmp", "fNarioRStand.bmp", "fNarioRWalk1.bmp", "fNarioRWalk2.bmp", "fNarioRWalk3.bmp", "font.bmp", "grass0.bmp", "grass1.bmp", "grass2.bmp", "kinoko.bmp", "kuri0.bmp", "kuri1.bmp", "kuriDead.bmp", "mt02.bmp", "mt11.bmp", "mt12.bmp", "mt13.bmp", "mt22.bmp", "narioDead.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", "noko1.bmp", "pole0.bmp", "pole1.bmp", "sNarioLJump.bmp", "sNarioLSit.bmp", "sNarioLSlip.bmp", "sNarioLStand.bmp", "sNarioLWalk1.bmp", "sNarioLWalk2.bmp", "sNarioLWalk3.bmp", "sNarioRJump.bmp", "sNarioRSit.bmp", "sNarioRSlip.bmp", "sNarioRStand.bmp", "sNarioRWalk1.bmp", "sNarioRWalk2.bmp", "sNarioRWalk3.bmp", "title.bmp"] 
     3data ImageType = Img100 | Img1000 | Img200 | Img500 | ImgBlock1 | ImgBlock2 | ImgBlock3 | ImgBlock4 | ImgBlock5 | ImgBroken | ImgCloud00 | ImgCloud01 | ImgCloud02 | ImgCloud10 | ImgCloud11 | ImgCloud12 | ImgCoin0 | ImgCoin1 | ImgCoin2 | ImgCoin3 | ImgDk00 | ImgDk01 | ImgDk10 | ImgDk11 | ImgFlag | ImgFlower | ImgFNarioLJump | ImgFNarioLShot | ImgFNarioLSit | ImgFNarioLSlip | ImgFNarioLStand | ImgFNarioLWalk1 | ImgFNarioLWalk2 | ImgFNarioLWalk3 | ImgFNarioRJump | ImgFNarioRShot | ImgFNarioRSit | ImgFNarioRSlip | ImgFNarioRStand | ImgFNarioRWalk1 | ImgFNarioRWalk2 | ImgFNarioRWalk3 | ImgFont | ImgGrass0 | ImgGrass1 | ImgGrass2 | ImgKinoko | ImgKuri0 | ImgKuri1 | ImgKuriDead | ImgMt02 | ImgMt11 | ImgMt12 | ImgMt13 | ImgMt22 | ImgNarioDead | ImgNarioLJump | ImgNarioLSlip | ImgNarioLStand | ImgNarioLWalk1 | ImgNarioLWalk2 | ImgNarioLWalk3 | ImgNarioRJump | ImgNarioRSlip | ImgNarioRStand | ImgNarioRWalk1 | ImgNarioRWalk2 | ImgNarioRWalk3 | ImgNoko0 | ImgNoko1 | ImgPole0 | ImgPole1 | ImgSNarioLJump | ImgSNarioLSit | ImgSNarioLSlip | ImgSNarioLStand | ImgSNarioLWalk1 | ImgSNarioLWalk2 | ImgSNarioLWalk3 | ImgSNarioRJump | ImgSNarioRSit | ImgSNarioRSlip | ImgSNarioRStand | ImgSNarioRWalk1 | ImgSNarioRWalk2 | ImgSNarioRWalk3 | ImgTitle     deriving (Eq) 
     4imageTypes = [Img100, Img1000, Img200, Img500, ImgBlock1, ImgBlock2, ImgBlock3, ImgBlock4, ImgBlock5, ImgBroken, ImgCloud00, ImgCloud01, ImgCloud02, ImgCloud10, ImgCloud11, ImgCloud12, ImgCoin0, ImgCoin1, ImgCoin2, ImgCoin3, ImgDk00, ImgDk01, ImgDk10, ImgDk11, ImgFlag, ImgFlower, ImgFNarioLJump, ImgFNarioLShot, ImgFNarioLSit, ImgFNarioLSlip, ImgFNarioLStand, ImgFNarioLWalk1, ImgFNarioLWalk2, ImgFNarioLWalk3, ImgFNarioRJump, ImgFNarioRShot, ImgFNarioRSit, ImgFNarioRSlip, ImgFNarioRStand, ImgFNarioRWalk1, ImgFNarioRWalk2, ImgFNarioRWalk3, ImgFont, ImgGrass0, ImgGrass1, ImgGrass2, ImgKinoko, ImgKuri0, ImgKuri1, ImgKuriDead, ImgMt02, ImgMt11, ImgMt12, ImgMt13, ImgMt22, ImgNarioDead, ImgNarioLJump, ImgNarioLSlip, ImgNarioLStand, ImgNarioLWalk1, ImgNarioLWalk2, ImgNarioLWalk3, ImgNarioRJump, ImgNarioRSlip, ImgNarioRStand, ImgNarioRWalk1, ImgNarioRWalk2, ImgNarioRWalk3, ImgNoko0, ImgNoko1, ImgPole0, ImgPole1, ImgSNarioLJump, ImgSNarioLSit, ImgSNarioLSlip, ImgSNarioLStand, ImgSNarioLWalk1, ImgSNarioLWalk2, ImgSNarioLWalk3, ImgSNarioRJump, ImgSNarioRSit, ImgSNarioRSlip, ImgSNarioRStand, ImgSNarioRWalk1, ImgSNarioRWalk2, ImgSNarioRWalk3, ImgTitle] 
     5imageFilenames = ["100.bmp", "1000.bmp", "200.bmp", "500.bmp", "block1.bmp", "block2.bmp", "block3.bmp", "block4.bmp", "block5.bmp", "broken.bmp", "cloud00.bmp", "cloud01.bmp", "cloud02.bmp", "cloud10.bmp", "cloud11.bmp", "cloud12.bmp", "coin0.bmp", "coin1.bmp", "coin2.bmp", "coin3.bmp", "dk00.bmp", "dk01.bmp", "dk10.bmp", "dk11.bmp", "flag.bmp", "flower.bmp", "fNarioLJump.bmp", "fNarioLShot.bmp", "fNarioLSit.bmp", "fNarioLSlip.bmp", "fNarioLStand.bmp", "fNarioLWalk1.bmp", "fNarioLWalk2.bmp", "fNarioLWalk3.bmp", "fNarioRJump.bmp", "fNarioRShot.bmp", "fNarioRSit.bmp", "fNarioRSlip.bmp", "fNarioRStand.bmp", "fNarioRWalk1.bmp", "fNarioRWalk2.bmp", "fNarioRWalk3.bmp", "font.bmp", "grass0.bmp", "grass1.bmp", "grass2.bmp", "kinoko.bmp", "kuri0.bmp", "kuri1.bmp", "kuriDead.bmp", "mt02.bmp", "mt11.bmp", "mt12.bmp", "mt13.bmp", "mt22.bmp", "narioDead.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", "noko1.bmp", "pole0.bmp", "pole1.bmp", "sNarioLJump.bmp", "sNarioLSit.bmp", "sNarioLSlip.bmp", "sNarioLStand.bmp", "sNarioLWalk1.bmp", "sNarioLWalk2.bmp", "sNarioLWalk3.bmp", "sNarioRJump.bmp", "sNarioRSit.bmp", "sNarioRSlip.bmp", "sNarioRStand.bmp", "sNarioRWalk1.bmp", "sNarioRWalk2.bmp", "sNarioRWalk3.bmp", "title.bmp"] 
    66imageFn = fromJust . flip lookup (zip imageTypes imageFilenames) 
  • lang/haskell/nario/Main.hs

    r20691 r20775  
    2323import Actor.Kinoko 
    2424import Actor.Flower 
     25import Actor.BrokenBlock 
     26import Actor.CoinGet 
     27import Actor.ScoreAdd 
    2528 
    2629-- 背景色 
     
    2932-- 描画コマンド 
    3033type Scr = Surface -> IO () 
     34 
     35 
     36pointBreakBlock = 50 
     37pointGetCoin = 200 
     38 
    3139 
    3240-- エントリ 
     
    110118 
    111119 
    112  
    113120-- マップのスクロールに応じたイベント 
    114121scrollEvent :: Field -> Int -> (Field, [Event]) 
     
    127134 
    128135 
    129  
    130136-- 当たり判定 
    131137hitcheck :: Player -> [ActorWrapper] -> (Player, [ActorWrapper]) 
     
    191197                proc gs (EvHitBlock imgtype cx cy bSuper) 
    192198                        | hardBlock c                   = gs 
    193                         | bSuper && breakable c = gs { fld = fieldSet (fld gs) cx cy ' ' } 
    194                         | otherwise                             = gs { fld = fld', actors = actors' } 
     199                        | bSuper && breakable c = breakBlock gs cx cy 
     200                        | c == 'K'                              = genKinoko 
     201                        | c == '?'                              = getCoin 
     202                        | otherwise                             = gs' 
    195203                        where 
    196204                                c = fieldRef (fld gs) cx cy 
    197                                 items 
    198                                         | c == 'K'      = if not bSuper then [ActorWrapper $ newKinoko cx cy] else [ActorWrapper $ newFlower cx cy] 
    199                                         | otherwise     = [] 
    200                                 actors' = actors gs ++ [ActorWrapper $ newAnimBlock cx cy $ fieldRef (fld gs) cx cy] ++ items 
     205                                breakable c = c == 'O' 
     206 
     207                                gs' = gs { fld = fld', actors = actors' } 
     208                                actors' = actors gs ++ [ActorWrapper $ newAnimBlock cx cy $ fieldRef (fld gs) cx cy] 
    201209                                fld' = fieldSet (fld gs) cx cy '*' 
    202                                 breakable c = c == 'O' 
     210 
     211                                breakBlock gs cx cy = 
     212                                        gs { 
     213                                                fld = fieldSet (fld gs) cx cy ' ', 
     214                                                actors = actors gs ++ map ActorWrapper (newBrokenBlock cx cy), 
     215                                                pl = addScore pointBreakBlock $ pl gs 
     216                                                } 
     217                                genKinoko = gs' { actors = actors gs' ++ [a] } 
     218                                        where a = if not bSuper then ActorWrapper $ newKinoko cx cy else ActorWrapper $ newFlower cx cy 
     219                                getCoin = gs' { actors = actors gs' ++ [ActorWrapper a], pl = addScore pointGetCoin $ playerGetCoin $ pl gs' } 
     220                                        where a = newCoinGet cx cy 
     221 
    203222                proc gs (EvSetField cx cy c) = gs { fld = fieldSet (fld gs) cx cy c } 
    204223                proc gs (EvAppearEnemy cx cy c) = gs { actors = actors gs ++ [ene] } 
     
    207226                                        'k'     -> ActorWrapper $ newKuribo cx cy 
    208227                                        'n'     -> ActorWrapper $ newNokonoko cx cy 
    209  
     228                proc gs (EvScoreAddEfe sx sy imgtype) = gs { actors = actors gs ++ [ActorWrapper $ newScoreAdd sx sy imgtype] } 
    210229 
    211230-- 描画 
     
    232251        puts 3 1 "NARIO" 
    233252        puts 3 2 $ deciWide 6 '0' $ getPlayerScore (pl gs) 
    234         puts 11 2 ("?*" ++ deciWide 2 '0' (getPlayerMedal (pl gs))) 
     253        puts 11 2 ("?*" ++ deciWide 2 '0' (getPlayerCoin (pl gs))) 
    235254        puts 18 1 "WORLD" 
    236255        puts 19 2 "1-1" 
  • lang/haskell/nario/Player.hs

    r20691 r20775  
    77        updatePlayer, 
    88        renderPlayer, 
     9        playerGetCoin, 
     10        addScore, 
    911        getScrollPos, 
    1012        getPlayerYPos, 
    1113        getPlayerVY, 
    1214        getPlayerHitRect, 
    13         getPlayerMedal, 
     15        getPlayerCoin, 
    1416        getPlayerScore, 
    1517        getPlayerType, 
     
    6163        undeadCount :: Int, 
    6264 
    63         medal :: Int, 
     65        coin :: Int, 
    6466        score :: Int, 
    6567 
     
    8082        undeadCount = 0, 
    8183 
    82         medal = 0, 
     84        coin = 0, 
    8385        score = 0, 
    8486 
     
    206208checkCeil fld self 
    207209        | stand self || vy self >= 0 || not isCeil      = (self, []) 
    208         | otherwise = (self { vy = 0, score = (score self) + 10 }, [EvHitBlock ImgBlock2 cx cy (pltype self /= SmallNario)]) 
     210        | otherwise = (self { y = y', vy = 0 }, [EvHitBlock ImgBlock2 cx cy (pltype self /= SmallNario)]) 
    209211        where 
    210212                yofs = case pltype self of 
    211                         SmallNario      -> 15 
    212                         SuperNario      -> 30 
    213                         FireNario       -> 30 
     213                        SmallNario      -> 14 
     214                        SuperNario      -> 28 
     215                        FireNario       -> 28 
    214216                ytmp = y self - yofs * one 
    215217 
     
    218220                isCeil = isBlock $ fieldRef fld cx cy 
    219221                yground y = (cellCrd y) * (chrSize * one) 
     222                y' = ((cy + 1) * chrSize + yofs) * one 
    220223 
    221224 
     
    267270                yy = y self `div` one 
    268271 
    269 -- メダル枚数取得 
    270 getPlayerMedal :: Player -> Int 
    271 getPlayerMedal = medal 
     272-- コイン枚数取得 
     273getPlayerCoin :: Player -> Int 
     274getPlayerCoin = coin 
    272275 
    273276-- スコア取得 
     
    293296stampPlayer :: Player -> Player 
    294297stampPlayer self = self { vy = stampVy } 
     298 
     299-- コイン取得 
     300playerGetCoin :: Player -> Player 
     301playerGetCoin self = self { coin = (coin self + 1) `mod` 100 } 
     302 
     303-- スコア加算 
     304addScore :: Int -> Player -> Player 
     305addScore a self = self { score = score self + a } 
    295306 
    296307-- 描画