Changeset 20680

Show
Ignore:
Timestamp:
10/04/08 16:01:22 (3 months ago)
Author:
mokehehe
Message:

きのこを取って巨大化
花を取ってファイヤー化(ショットはまだ撃てない)

Location:
lang/haskell/nario
Files:
1 added
8 modified

Legend:

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

    r20673 r20680  
    1414import AppUtil (ImageResource, Rect) 
    1515import Field (Field) 
     16import Player (Player) 
    1617 
    1718 
     
    2526        getHitRect :: a -> Maybe Rect 
    2627        getHitRect _ = Nothing 
     28 
     29        onHit :: Player -> a -> (Player, Maybe a) 
     30        onHit pl ac = (pl, Nothing) 
    2731 
    2832-- ============================================================================ 
  • lang/haskell/nario/Actor/Kinoko.hs

    r20673 r20680  
    1313import Images 
    1414import Field 
     15import Player (PlayerType(..), getPlayerType, setPlayerType) 
    1516 
    1617maxVy = one * 6 
     
    5253                        yy = y self `div` one 
    5354 
     55        onHit pl self = (setPlayerType nt pl, Nothing) 
     56                where 
     57                        nt = case typ of 
     58                                SmallNario      -> SuperNario 
     59                                otherwise       -> typ 
     60                        typ = getPlayerType pl 
     61 
    5462 
    5563newKinoko :: Int -> Int -> Kinoko 
  • lang/haskell/nario/Actor/Nokonoko.hs

    r20670 r20680  
    2828                return () 
    2929                where 
    30                         imgtype = ImgNoko0 
     30                        imgtype = [ImgNoko0, ImgNoko1] !! (cnt self `mod` 16 `div` 8) 
    3131 
    3232newNokonoko :: Int -> Int -> Nokonoko 
  • lang/haskell/nario/Event.hs

    r20670 r20680  
    66 
    77data Event = 
    8                 -- ブロックをたたいた 
    9                 EvHitBlock ImageType Int Int 
     8                -- ブロックをたたいた x y super? 
     9                EvHitBlock ImageType Int Int Bool 
    1010 
    1111                -- フィールドを変更 
  • lang/haskell/nario/Images.hs

    r20670 r20680  
    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 | 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) 
    4 imageTypes = [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] 
    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", "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"] 
     3data ImageType = ImgBlock1 | ImgBlock2 | ImgBlock3 | ImgBlock4 | ImgBlock5 | ImgCloud00 | ImgCloud01 | ImgCloud02 | ImgCloud10 | ImgCloud11 | ImgCloud12 | 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 | ImgMt02 | ImgMt11 | ImgMt12 | ImgMt13 | ImgMt22 | ImgNarioDie | 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 = [ImgBlock1, ImgBlock2, ImgBlock3, ImgBlock4, ImgBlock5, ImgCloud00, ImgCloud01, ImgCloud02, ImgCloud10, ImgCloud11, ImgCloud12, 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, ImgMt02, ImgMt11, ImgMt12, ImgMt13, ImgMt22, ImgNarioDie, 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 = ["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", "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", "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", "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

    r20673 r20680  
    2222import Actor.Nokonoko 
    2323import Actor.Kinoko 
     24import Actor.Flower 
    2425 
    2526-- 背景色 
     
    140141                                nothingHappened = (pl, ac ++ [ActorWrapper a]) 
    141142                                plrc = getPlayerHitRect player 
    142                                 pl' = pl 
    143                                 ac' = ac 
     143                                (pl', a') = onHit pl a 
     144                                ac' = case a' of 
     145                                        Just a''        -> ac ++ [ActorWrapper a''] 
     146                                        Nothing         -> ac 
    144147 
    145148 
     
    186189procEvent gs ev = foldl proc gs ev 
    187190        where 
    188                 proc gs (EvHitBlock imgtype cx cy) 
    189                         | hardBlock c   = gs 
    190                         | otherwise             = gs { fld = fld', actors = actors' } 
     191                proc gs (EvHitBlock imgtype cx cy bSuper) 
     192                        | hardBlock c                   = gs 
     193                        | bSuper && breakable c = gs { fld = fieldSet (fld gs) cx cy ' ' } 
     194                        | otherwise                             = gs { fld = fld', actors = actors' } 
    191195                        where 
    192196                                c = fieldRef (fld gs) cx cy 
    193197                                items 
    194                                         | c == 'K'      = [ActorWrapper $ newKinoko cx cy] 
     198                                        | c == 'K'      = if not bSuper then [ActorWrapper $ newKinoko cx cy] else [ActorWrapper $ newFlower cx cy] 
    195199                                        | otherwise     = [] 
    196200                                actors' = actors gs ++ [ActorWrapper $ newAnimBlock cx cy $ fieldRef (fld gs) cx cy] ++ items 
    197201                                fld' = fieldSet (fld gs) cx cy '*' 
     202                                breakable c = c == 'O' 
    198203                proc gs (EvSetField cx cy c) = gs { fld = fieldSet (fld gs) cx cy c } 
    199204                proc gs (EvAppearEnemy cx cy c) = gs { actors = actors gs ++ [ene] } 
     
    213218        renderField sur imgres scrx (fld gs) 
    214219        renderInfo gs imgres sur 
     220        renderActors imgres scrx sur (actors gs) 
    215221        renderPlayer sur imgres scrx (pl gs) 
    216222 
    217         renderActors imgres scrx sur (actors gs) 
    218223        return () 
    219224 
  • lang/haskell/nario/Player.hs

    r20673 r20680  
    33module Player ( 
    44        Player(..), 
     5        PlayerType(..), 
    56        newPlayer, 
    67        updatePlayer, 
     
    1011        getPlayerHitRect, 
    1112        getPlayerMedal, 
    12         getPlayerScore 
     13        getPlayerScore, 
     14        getPlayerType, 
     15        setPlayerType 
    1316) where 
    1417 
     
    3235gravity2 = one `div` 4          -- Aを長押ししたときの重力 
    3336 
     37data PlayerType = SmallNario | SuperNario | FireNario 
     38        deriving (Eq) 
     39 
    3440data Player = Player { 
     41        pltype :: PlayerType, 
    3542        x :: Int, 
    3643        y :: Int, 
     
    4956 
    5057newPlayer = Player { 
     58        pltype = SmallNario, 
    5159        x = 3 * chrSize * one, 
    5260        y = 13 * chrSize * one, 
     
    7078patJump = patWalk + walkPatNum 
    7179patSlip = patJump + 1 
    72  
    73 imgTable = [ 
    74         [ImgNarioLStand, ImgNarioLWalk1, ImgNarioLWalk2, ImgNarioLWalk3, ImgNarioLJump, ImgNarioLSlip], 
    75         [ImgNarioRStand, ImgNarioRWalk1, ImgNarioRWalk2, ImgNarioRWalk3, ImgNarioRJump, ImgNarioRSlip] 
     80patSit = patSlip + 1 
     81patShot = patSit + 1 
     82 
     83imgTableSmall = [ 
     84        [ImgNarioLStand, ImgNarioLWalk1, ImgNarioLWalk2, ImgNarioLWalk3, ImgNarioLJump, ImgNarioLSlip, ImgNarioLStand], 
     85        [ImgNarioRStand, ImgNarioRWalk1, ImgNarioRWalk2, ImgNarioRWalk3, ImgNarioRJump, ImgNarioRSlip, ImgNarioRStand] 
     86        ] 
     87imgTableSuper = [ 
     88        [ImgSNarioLStand, ImgSNarioLWalk1, ImgSNarioLWalk2, ImgSNarioLWalk3, ImgSNarioLJump, ImgSNarioLSlip, ImgSNarioLSit], 
     89        [ImgSNarioRStand, ImgSNarioRWalk1, ImgSNarioRWalk2, ImgSNarioRWalk3, ImgSNarioRJump, ImgSNarioRSlip, ImgSNarioRSit] 
     90        ] 
     91imgTableFire = [ 
     92        [ImgFNarioLStand, ImgFNarioLWalk1, ImgFNarioLWalk2, ImgFNarioLWalk3, ImgFNarioLJump, ImgFNarioLSlip, ImgFNarioLSit, ImgFNarioLShot], 
     93        [ImgFNarioRStand, ImgFNarioRWalk1, ImgFNarioRWalk2, ImgFNarioRWalk3, ImgFNarioRJump, ImgFNarioRSlip, ImgFNarioRSit, ImgFNarioRShot] 
    7694        ] 
    7795 
     
    7997-- 横移動 
    8098moveX :: KeyProc -> Player -> Player 
    81 moveX kp player = 
    82         if (stand player) 
    83                 then player' { lr = lr', pat = pat', anm = anm' } 
    84                 else player' 
     99moveX kp self = 
     100        if (stand self) 
     101                then self' { lr = lr', pat = pat', anm = anm' } 
     102                else self' 
    85103        where 
    86104                ax = (-padl + padr) * acc 
    87105                vx' 
    88                         | ax /= 0                       = rangeadd (vx player) ax (-maxspd) maxspd 
    89                         | stand player          = friction (vx player) acc 
    90                         | otherwise                     = vx player 
    91                 x' = max xmin $ (x player) + vx' 
     106                        | ax /= 0                       = rangeadd (vx self) ax (-maxspd) maxspd 
     107                        | stand self            = friction (vx self) acc 
     108                        | otherwise                     = vx self 
     109                x' = max xmin $ (x self) + vx' 
    92110                scrx' 
    93                         | vx' > 0 && (x' - (scrx player)) `div` one > scrollPos = (scrx player) + vx' 
    94                         | otherwise                                                                                             = (scrx player) 
     111                        | vx' > 0 && (x' - (scrx self)) `div` one > scrollPos   = (scrx self) + vx' 
     112                        | otherwise                                                                                             = (scrx self) 
    95113 
    96114                scrollPos = (max vx' 0) * (scrollMaxX - scrollMinX) `div` runVx + scrollMinX 
     
    99117                padr = if isPressed (kp PadR) then 1 else 0 
    100118                maxspd 
    101                         | not $ stand player    = walkVx `div` 2 
     119                        | not $ stand self      = walkVx `div` 2 
    102120                        | isPressed (kp PadB)   = walkVx * 2 
    103121                        | otherwise                             = walkVx 
    104                 xmin = (scrx player) + chrSize `div` 2 * one 
    105  
    106                 player' = player { x = x', vx = vx', scrx = scrx' } 
     122                xmin = (scrx self) + chrSize `div` 2 * one 
     123 
     124                self' = self { x = x', vx = vx', scrx = scrx' } 
    107125 
    108126                lr' = 
    109127                        case (-padl + padr) of 
    110                                 0       -> lr player 
     128                                0       -> lr self 
    111129                                -1      -> 0 
    112130                                1       -> 1 
     
    118136                anm' 
    119137                        | vx' == 0              = 0 
    120                         | otherwise             = ((anm player) + (abs vx')) `mod` (walkPatNum * anmCnt) 
     138                        | otherwise             = ((anm self) + (abs vx')) `mod` (walkPatNum * anmCnt) 
    121139                anmCnt = walkVx * 3 
    122140 
     
    124142-- 横移動チェック 
    125143checkX :: Field -> Player -> Player 
    126 checkX fld player 
    127         | dir == 0      = check (-1) $ check 1 $ player 
    128         | otherwise = check dir $ player 
    129         where 
    130                 dir = sgn $ vx player 
    131                 check dx player 
    132                         | isBlock $ fieldRef fld cx cy  = player { x = (x player) - dx * one, vx = 0 } 
    133                         | otherwise                                             = player 
     144checkX fld self 
     145        | dir == 0      = check (-1) $ check 1 $ self 
     146        | otherwise = check dir $ self 
     147        where 
     148                dir = sgn $ vx self 
     149                check dx self 
     150                        | isBlock $ fieldRef fld cx cy  = self { x = (x self) - dx * one, vx = 0 } 
     151                        | otherwise                                             = self 
    134152                        where 
    135                                 cx = cellCrd (x player + ofsx dx) 
    136                                 cy = cellCrd (y player - chrSize `div` 2 * one) 
     153                                cx = cellCrd (x self + ofsx dx) 
     154                                cy = cellCrd (y self - chrSize `div` 2 * one) 
    137155                                ofsx (-1) = -6 * one 
    138156                                ofsx   1  =  5 * one 
     
    141159-- 重力による落下 
    142160fall :: KeyProc -> Player -> Player 
    143 fall kp player 
    144         | stand player  = player 
    145         | otherwise             = player { y = y', vy = vy' } 
     161fall kp self 
     162        | stand self    = self 
     163        | otherwise             = self { y = y', vy = vy' } 
    146164        where 
    147165                ay 
    148                         | vy player < 0 && isPressed (kp PadA)  = gravity2 
     166                        | vy self < 0 && isPressed (kp PadA)    = gravity2 
    149167                        | otherwise                                                             = gravity 
    150                 vy' = min maxVy $ vy player + ay 
    151                 y' = y player + vy' 
     168                vy' = min maxVy $ vy self + ay 
     169                y' = y self + vy' 
    152170 
    153171 
    154172-- 床をチェック 
    155173checkFloor :: Field -> Player -> Player 
    156 checkFloor fld player 
    157         | stand'        = player { stand = stand', y = ystand, vy = 0 } 
    158         | otherwise     = player { stand = stand' } 
     174checkFloor fld self 
     175        | stand'        = self { stand = stand', y = ystand, vy = 0 } 
     176        | otherwise     = self { stand = stand' } 
    159177        where 
    160178                stand' 
    161                         | vy player >= 0        = isGround (-6) || isGround 5 
    162                         | otherwise                     = stand player 
    163                 ystand = (cellCrd $ y player) * (chrSize * one) 
    164  
    165                 isGround ofsx = isBlock $ fieldRef fld (cellCrd $ x player + ofsx * one) (cellCrd (y player)) 
     179                        | vy self >= 0  = isGround (-6) || isGround 5 
     180                        | otherwise                     = stand self 
     181                ystand = (cellCrd $ y self) * (chrSize * one) 
     182 
     183                isGround ofsx = isBlock $ fieldRef fld (cellCrd $ x self + ofsx * one) (cellCrd (y self)) 
    166184 
    167185-- 上をチェック 
    168186checkCeil :: Field -> Player -> (Player, [Event]) 
    169 checkCeil fld player 
    170         | stand player || vy player >= 0 || not isCeil  = (player, []) 
    171         | otherwise = (player { vy = 0, score = (score player) + 10 }, [EvHitBlock ImgBlock2 cx cy]) 
    172         where 
    173                 ytmp = y player - one * chrSize 
    174  
    175                 cx = cellCrd $ x player 
     187checkCeil fld self 
     188        | stand self || vy self >= 0 || not isCeil      = (self, []) 
     189        | otherwise = (self { vy = 0, score = (score self) + 10 }, [EvHitBlock ImgBlock2 cx cy (pltype self /= SmallNario)]) 
     190        where 
     191                yofs = case pltype self of 
     192                        SmallNario      -> 15 
     193                        SuperNario      -> 30 
     194                        FireNario       -> 30 
     195                ytmp = y self - yofs * one 
     196 
     197                cx = cellCrd $ x self 
    176198                cy = cellCrd ytmp 
    177199                isCeil = isBlock $ fieldRef fld cx cy 
     
    181203-- ジャンプする? 
    182204doJump :: KeyProc -> Player -> Player 
    183 doJump kp player 
    184         | stand player && kp PadA == Pushed     = player { vy = jumpVy, stand = False, pat = patJump } 
    185         | otherwise                                                     = player 
     205doJump kp self 
     206        | stand self && kp PadA == Pushed       = self { vy = jumpVy, stand = False, pat = patJump } 
     207        | otherwise                                                     = self 
    186208 
    187209 
    188210-- 更新処理 
    189211updatePlayer :: KeyProc -> Field -> Player -> (Player, [Event]) 
    190 updatePlayer kp fld player = 
    191         moveY $ checkX fld $ moveX kp player 
     212updatePlayer kp fld self = 
     213        moveY $ checkX fld $ moveX kp self 
    192214        where 
    193215                moveY = checkCeil fld . doJump kp . checkFloor fld . fall kp 
     
    195217-- スクロール位置取得 
    196218getScrollPos :: Player -> Int 
    197 getScrollPos player = (scrx player) `div` one 
     219getScrollPos self = (scrx self) `div` one 
    198220 
    199221-- Y座標取得 
     
    216238getPlayerScore = score 
    217239 
     240-- タイプ取得 
     241getPlayerType :: Player -> PlayerType 
     242getPlayerType = pltype 
     243 
     244-- タイプ設定 
     245setPlayerType :: PlayerType -> Player -> Player 
     246setPlayerType t self = self { pltype = t } 
     247 
    218248-- 描画 
    219 renderPlayer sur imgres scrx player = do 
     249renderPlayer sur imgres scrx self = do 
    220250        blitSurface (getImageSurface imgres imgtype) Nothing sur pos 
    221251        where 
    222                 pos = pt ((x player) `div` one - chrSize `div` 2 - scrx) ((y player) `div` one - chrSize+1 - 8) 
    223                 imgtype = imgTable !! (lr player) !! (pat player) 
     252                pos = case pltype self of 
     253                        SmallNario      -> pt sx $ sy - chrSize + 1 
     254                        otherwise       -> pt sx $ sy - chrSize * 2 + 1 
     255                imgtype = imgtbl !! lr self !! pat self 
     256                imgtbl = case pltype self of 
     257                        SmallNario      -> imgTableSmall 
     258                        SuperNario      -> imgTableSuper 
     259                        FireNario       -> imgTableFire 
     260                sx = x self `div` one - chrSize `div` 2 - scrx 
     261                sy = y self `div` one - 8 
  • lang/haskell/nario/README.txt

    r20661 r20680  
    55を Haskell/HSDL で作る 
    66 
    7  
    87HSDL 
    98http://fxp.hp.infoseek.co.jp/haskell/HSDL/ 
     9 
    1010 
    1111 
     
    3333 
    3434 
     35★ビルド 
     36・必要なもの 
     37        Haskell コンパイラ 
     38 
     39        SDL 
     40        http://www.libsdl.org/ 
     41 
     42        HSDL 
     43        http://fxp.hp.infoseek.co.jp/haskell/HSDL/ 
     44 
     45 ○ビルド 
     46        make 
     47 
     48 ○実行 
     49        できた実行ファイルを入力、または 
     50        make run 
    3551 
    3652