Changeset 20943 for lang/haskell
- Timestamp:
- 10/08/08 07:34:08 (2 months ago)
- Location:
- lang/haskell/nario
- Files:
-
- 13 modified
-
Actor/AnimBlock.hs (modified) (1 diff)
-
Actor/BrokenBlock.hs (modified) (1 diff)
-
Actor/CoinGet.hs (modified) (1 diff)
-
Actor/Flower.hs (modified) (1 diff)
-
Actor/Kinoko.hs (modified) (1 diff)
-
Actor/Koura.hs (modified) (1 diff)
-
Actor/Kuribo.hs (modified) (2 diffs)
-
Actor/Nokonoko.hs (modified) (1 diff)
-
Actor/ScoreAdd.hs (modified) (1 diff)
-
AppUtil.hs (modified) (3 diffs)
-
Main.hs (modified) (4 diffs)
-
Player.hs (modified) (4 diffs)
-
Util.hs (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
lang/haskell/nario/Actor/AnimBlock.hs
r20925 r20943 36 36 else [] 37 37 38 render self imgres scrx sur = do38 render self imgres scrx sur = 39 39 putimg sur imgres (chr2img $ chr self) (x self `div` one - scrx) (y self `div` one - 8) 40 return ()41 40 42 41 bDead self = vy self > 0 && y self >= startcy self * chrSize * one -
lang/haskell/nario/Actor/BrokenBlock.hs
r20925 r20943 24 24 update _ self = (self { x = x self + vx self, y = y self + vy self, vy = vy self + gravity }, []) 25 25 26 render self imgres scrx sur = do26 render self imgres scrx sur = 27 27 putimg sur imgres ImgBroken (x self `div` one - 4 - scrx) (y self `div` one - 4 - 8) 28 return ()29 28 30 29 bDead self = y self >= (screenHeight + chrSize * 2) * one -
lang/haskell/nario/Actor/CoinGet.hs
r20925 r20943 32 32 self' = self { y = y self + vy self, vy = vy self + gravity, cnt = cnt self + 1 } 33 33 34 render self imgres scrx sur = do34 render self imgres scrx sur = 35 35 putimg sur imgres imgtype (sx self - scrx) (y self `div` one - 8) 36 return ()37 36 where 38 37 imgtype = imgtbl !! (cnt self `div` 2 `mod` 4) -
lang/haskell/nario/Actor/Flower.hs
r20925 r20943 27 27 update fld self = (self, []) 28 28 29 render self imgres scrx sur = do29 render self imgres scrx sur = 30 30 putimg sur imgres ImgFlower ((x self) `div` one - chrSize `div` 2 - scrx) ((y self) `div` one - 15 - 8) 31 return ()32 31 33 32 getHitRect self = Just $ Rect (xx - 8) (yy - 16) (xx + 8) yy -
lang/haskell/nario/Actor/Kinoko.hs
r20925 r20943 32 32 (x', y', vx', vy') = updateActorBase fld (x self, y self, vx self, vy self) 33 33 34 render self imgres scrx sur = do 35 putimg sur imgres imgtype ((x self) `div` one - chrSize `div` 2 - scrx) ((y self) `div` one - ofsH - 8) 36 return () 37 where 38 imgtype = ImgKinoko 34 render self imgres scrx sur = 35 putimg sur imgres ImgKinoko ((x self) `div` one - chrSize `div` 2 - scrx) ((y self) `div` one - ofsH - 8) 39 36 40 37 bDead self = y self >= (screenHeight + chrSize * 3) * one || x self <= -chrSize * one -
lang/haskell/nario/Actor/Koura.hs
r20925 r20943 44 44 45 45 render self imgres scrx sur = do 46 putimg sur imgres imgtype ((x self) `div` one - chrSize `div` 2 - scrx) ((y self) `div` one - ofsH - 8) 47 return () 48 where 49 imgtype = ImgKoura 46 putimg sur imgres ImgKoura ((x self) `div` one - chrSize `div` 2 - scrx) ((y self) `div` one - ofsH - 8) 50 47 51 48 bDead self = y self >= (screenHeight + chrSize * 3) * one || x self <= -chrSize * one -
lang/haskell/nario/Actor/Kuribo.hs
r20925 r20943 32 32 (x', y', vx', vy') = updateActorBase fld (x self, y self, vx self, vy self) 33 33 34 render self imgres scrx sur = do34 render self imgres scrx sur = 35 35 putimg sur imgres imgtype (x self `div` one - chrSize `div` 2 - scrx) (y self `div` one - ofsH - 8) 36 return ()37 36 where 38 37 imgtype = [ImgKuri0, ImgKuri1] !! (cnt self `mod` 16 `div` 8) … … 66 65 update fld self = (self { ccnt = ccnt self + 1 }, []) 67 66 68 render self imgres scrx sur = do67 render self imgres scrx sur = 69 68 putimg sur imgres ImgKuriDead (sx self - scrx) (sy self - 7 - 8) 70 return ()71 69 72 70 bDead self = ccnt self >= frameRate `div` 2 -
lang/haskell/nario/Actor/Nokonoko.hs
r20925 r20943 33 33 (x', y', vx', vy') = updateActorBase fld (x self, y self, vx self, vy self) 34 34 35 render self imgres scrx sur = do35 render self imgres scrx sur = 36 36 putimg sur imgres imgtype (x self `div` one - chrSize `div` 2 - scrx) (y self `div` one - ofsH - 8) 37 return ()38 37 where 39 38 imgtype = imgtbl !! (cnt self `mod` 16 `div` 8) -
lang/haskell/nario/Actor/ScoreAdd.hs
r20925 r20943 26 26 update _ self = (self { sy = sy self + vy, cnt = cnt self + 1 }, []) 27 27 28 render self imgres scrx sur = do28 render self imgres scrx sur = 29 29 putimg sur imgres imgtype (sx self - scrx) (sy self) 30 return ()31 30 where 32 31 imgtype = case pnt self of -
lang/haskell/nario/AppUtil.hs
r20925 r20943 1 module AppUtil where 1 module AppUtil ( 2 KeyState(..), 3 isPressing, 4 KeyProc, 5 keyProc, 6 7 PadBtn(..), 8 padPressing, 9 padPressed, 10 11 ImageResource, 12 loadImageResource, 13 releaseImageResource, 14 getImageSurface, 15 putimg, 16 17 cellCrd, 18 Rect(..), 19 ishit 20 ) where 2 21 3 22 import Multimedia.SDL (Surface, SDLKey(..), loadBMP, freeSurface, surfacePixelFormat, displayFormat, pfPalette, setColorKey, SurfaceFlag(..), blitSurface, pt) … … 9 28 -- キーボード処理 10 29 11 data PadBtn =12 PadU | PadD | PadL | PadR | PadA | PadB13 deriving (Eq, Show, Enum)14 15 30 data KeyState = 16 31 Pushed | Pushing | Released | Releasing 17 deriving (Eq , Show)32 deriving (Eq) 18 33 19 isPress edPushed = True20 isPress edPushing = True21 isPress ed_ = False34 isPressing Pushed = True 35 isPressing Pushing = True 36 isPressing _ = False 22 37 23 type KeyProc = PadBtn-> KeyState38 type KeyProc = SDLKey -> KeyState 24 39 25 keyProc bef cur gk 40 keyProc :: [SDLKey] -> [SDLKey] -> KeyProc 41 keyProc bef cur k 26 42 | not bp && not cp = Releasing 27 43 | not bp && cp = Pushed … … 29 45 | bp && cp = Pushing 30 46 where 31 bp = any (flip elem bef) phykeys 32 cp = any (flip elem cur) phykeys 33 phykeys = mapPhyKey gk 47 bp = k `elem` bef 48 cp = k `elem` cur 34 49 35 mapPhyKey PadU = [SDLK_UP, SDLK_i] 36 mapPhyKey PadD = [SDLK_DOWN, SDLK_k] 37 mapPhyKey PadL = [SDLK_LEFT, SDLK_j] 38 mapPhyKey PadR = [SDLK_RIGHT, SDLK_l] 39 mapPhyKey PadA = [SDLK_SPACE, SDLK_z] 40 mapPhyKey PadB = [SDLK_LSHIFT, SDLK_RSHIFT] 50 51 -- パッド 52 53 data PadBtn = 54 PadU | PadD | PadL | PadR | PadA | PadB 55 deriving (Eq) 56 57 padPressing kp btn = any (isPressing . kp) $ mapSDLKey btn 58 padPressed kp btn = any ((== Pushed) . kp) $ mapSDLKey btn 59 60 mapSDLKey PadU = [SDLK_UP, SDLK_i] 61 mapSDLKey PadD = [SDLK_DOWN, SDLK_k] 62 mapSDLKey PadL = [SDLK_LEFT, SDLK_j] 63 mapSDLKey PadR = [SDLK_RIGHT, SDLK_l] 64 mapSDLKey PadA = [SDLK_SPACE, SDLK_z] 65 mapSDLKey PadB = [SDLK_LSHIFT, SDLK_RSHIFT] 41 66 42 67 -
lang/haskell/nario/Main.hs
r20925 r20943 86 86 87 87 88 -- キー入力 を処理して描画コマンドを返す88 -- キー入力全体を処理して描画コマンド列を返す 89 89 process :: [[SDLKey]] -> IO [Scr] 90 90 process kss = do … … 93 93 94 94 let tmpscrs = doTitle fldmap kss 95 96 let scrs = map (\scr sur -> scr imgres sur >> flipSurface sur >> return ()) $ tmpscrs 97 return $ scrs ++ [(\sur -> do {releaseImageResource imgres})] 98 95 let scrs = zipWith (common imgres) tmpscrs kss 96 return $ scrs ++ [final imgres] 97 98 where 99 -- 共通動作 100 common imgres scr ks sur = do 101 scr imgres sur 102 if SDLK_s `elem` ks 103 then saveBMP sur "ss.bmp" >> return () 104 else return () 105 flipSurface sur 106 return () 107 -- 後始末 108 final imgres sur = releaseImageResource imgres 99 109 100 110 -- タイトル … … 172 182 -- 更新 173 183 updateProc :: KeyProc -> GameGame -> (ImageResource -> Scr, GameGame) 174 updateProc kp gs = ( renderProc gs', gs')184 updateProc kp gs = (scr', gs') 175 185 where 176 186 time' = max 0 (time gs - 1) … … 186 196 gstmp = gs { pl = pl'', fld = fld', actors = actors'', time = time' } 187 197 gs' = procEvent gstmp (plev ++ ev' ++ screv' ++ ev'') 198 scr' = renderProc gs' 188 199 189 200 initialState = GameGame { pl = newPlayer, fld = fldmap, actors = [], time = 400 * timeBase } -
lang/haskell/nario/Player.hs
r20925 r20943 26 26 27 27 import Util 28 import AppUtil (KeyProc, isPressed, PadBtn(..), cellCrd, KeyState(..), getImageSurface, Rect(..), putimg)28 import AppUtil (KeyProc, padPressed, padPressing, PadBtn(..), cellCrd, KeyState(..), getImageSurface, Rect(..), putimg) 29 29 import Const 30 30 import Images … … 132 132 x' = max xmin $ (x self) + vx' 133 133 134 padd = if isPressed (kp PadD)then True else False135 padl = if isPressed (kp PadL)then 1 else 0136 padr = if isPressed (kp PadR)then 1 else 0134 padd = if padPressing kp PadD then True else False 135 padl = if padPressing kp PadL then 1 else 0 136 padr = if padPressing kp PadR then 1 else 0 137 137 maxspd 138 138 | not $ stand self = walkVx `div` 2 139 | isPressed (kp PadB)= runVx139 | padPressing kp PadB = runVx 140 140 | otherwise = walkVx 141 141 nowacc 142 | isPressed (kp PadB)= acc2142 | padPressing kp PadB = acc2 143 143 | otherwise = acc 144 144 xmin = (scrx self + chrSize `div` 2) * one … … 237 237 doJump :: KeyProc -> Player -> Player 238 238 doJump kp self 239 | stand self && kp PadA == Pushed= self { vy = vy', stand = False, pat = patJump }239 | stand self && padPressed kp PadA = self { vy = vy', stand = False, pat = patJump } 240 240 | otherwise = self 241 241 where … … 257 257 moveY $ scroll self $ checkX fld $ moveX kp self 258 258 where 259 moveY = checkCeil fld . doJump kp . checkFloor fld . fall ( isPressed $kp PadA)259 moveY = checkCeil fld . doJump kp . checkFloor fld . fall (padPressing kp PadA) 260 260 261 261 -- 死亡時 -
lang/haskell/nario/Util.hs
r20925 r20943 8 8 9 9 -- けつの n 個取り出し 10 lastN n xs = loopn [] xs10 lastN n xs = supply n [] xs 11 11 where 12 loop _ acc [] = acc 13 loop 0 acc (x:xs) = loop 0 (tail acc ++ [x]) xs 14 loop n acc (x:xs) = loop (n-1) (acc ++ [x]) xs 12 supply _ acc [] = acc 13 supply 0 acc xs = queue acc xs 14 supply n acc (x:xs) = supply (n-1) (acc ++ [x]) xs 15 queue acc [] = acc 16 queue acc (x:xs) = queue (tail acc ++ [x]) xs 15 17 16 18 -- 数値の符号を返す
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)