Changeset 20397
- Timestamp:
- 10/01/08 22:17:57 (3 months ago)
- Location:
- lang/haskell/nario
- Files:
-
- 5 added
- 8 modified
-
Actor.hs (modified) (1 diff)
-
AppUtil.hs (added)
-
Const.hs (modified) (2 diffs)
-
Event.hs (modified) (1 diff)
-
Field.hs (modified) (1 diff)
-
Images.hs (added)
-
Main.hs (modified) (2 diffs)
-
Makefile (modified) (1 diff)
-
Player.hs (modified) (1 diff)
-
Util.hs (modified) (2 diffs)
-
tool (added)
-
tool/FileUtils.hs (added)
-
tool/listup-imgs.hs (added)
Legend:
- Unmodified
- Added
- Removed
-
lang/haskell/nario/Actor.hs
r20243 r20397 5 5 6 6 import Const 7 import Images 7 8 import Util 9 import AppUtil 8 10 import Event 9 11 -
lang/haskell/nario/Const.hs
r20243 r20397 12 12 gravity2 = one `div` 4 13 13 14 {- 14 15 -- 画像 15 16 data ImageType = … … 79 80 ImgTitle 80 81 ] 82 -} -
lang/haskell/nario/Event.hs
r20244 r20397 3 3 4 4 import Const 5 import Images 5 6 import Field 6 7 -
lang/haskell/nario/Field.hs
r20244 r20397 19 19 20 20 import Const 21 import Images 21 22 import Util 23 import AppUtil 22 24 23 25 type Cell = Char -
lang/haskell/nario/Main.hs
r20243 r20397 12 12 import Field 13 13 import Util 14 import AppUtil 14 15 import Const 16 import Images 15 17 import Font 16 18 import Event … … 96 98 process :: [[SDLKey]] -> IO [Scr] 97 99 process kss = do 98 imgres <- loadImageResource image s100 imgres <- loadImageResource imageTypes 99 101 st <- initialState 100 102 let scrs = map (\scr -> scr imgres) $ loop [] st kss -
lang/haskell/nario/Makefile
r19868 r20397 20 20 doc: 21 21 haddock -h -o man -l C:\\ghc\\haddock-2.0.0.0 -B c:\\ghc\\ghc-6.8.2 *.hs 22 23 24 imgs: 25 runghc -itool tool/listup-imgs.hs data/img > Images.hs -
lang/haskell/nario/Player.hs
r20244 r20397 13 13 14 14 import Util 15 import AppUtil 15 16 import SDLUtil 16 17 import Const 18 import Images 17 19 import Field 18 20 import Event -
lang/haskell/nario/Util.hs
r20243 r20397 1 1 module Util where 2 3 import System.Time (getClockTime, diffClockTimes, noTimeDiff, tdMin, tdSec, tdPicosec)4 import Control.Concurrent (threadDelay)5 import Data.Maybe (fromJust)6 import Multimedia.SDL7 8 import Const9 2 10 3 … … 34 27 | x < -d = x + d 35 28 | otherwise = 0 36 37 38 39 -- キーボード処理40 41 data PadBtn =42 PadU | PadD | PadL | PadR | PadA | PadB43 deriving (Eq, Show, Enum)44 45 data KeyState =46 Pushed | Pushing | Released | Releasing47 deriving (Eq, Show)48 49 isPressed Pushed = True50 isPressed Pushing = True51 isPressed _ = False52 53 type KeyProc = PadBtn -> KeyState54 55 keyProc bef cur gk56 | not bp && not cp = Releasing57 | not bp && cp = Pushed58 | bp && not cp = Released59 | bp && cp = Pushing60 where61 bp = any (flip elem bef) phykeys62 cp = any (flip elem cur) phykeys63 phykeys = mapPhyKey gk64 65 mapPhyKey PadU = [SDLK_UP, SDLK_i]66 mapPhyKey PadD = [SDLK_DOWN, SDLK_k]67 mapPhyKey PadL = [SDLK_LEFT, SDLK_j]68 mapPhyKey PadR = [SDLK_RIGHT, SDLK_l]69 mapPhyKey PadA = [SDLK_SPACE, SDLK_z]70 mapPhyKey PadB = [SDLK_LSHIFT, SDLK_RSHIFT]71 72 73 74 -- 画像リソース75 type ImageResource = [(ImageType, Surface)]76 77 78 -- 画像リソース読み込み79 loadImageResource :: [ImageType] -> IO ImageResource80 loadImageResource = mapM load81 where82 load imgtype = do83 sur <- loadBMP $ ("data/img/" ++) $ imageFn imgtype84 setNuki sur85 converted <- displayFormat sur86 freeSurface sur87 return (imgtype, converted)88 89 setNuki sur = do90 let fmt = surfacePixelFormat sur91 if not $ null $ pfPalette fmt92 then setColorKey sur [SRCCOLORKEY] 0 >> return () -- パレット0番目をぬき色に93 else return ()94 95 releaseImageResource :: ImageResource -> IO ()96 releaseImageResource = mapM_ (\(t, sur) -> freeSurface sur)97 98 getImageSurface :: ImageResource -> ImageType -> Surface99 getImageSurface imgres t = fromJust $ lookup t imgres100 101 102 -- 固定座標系からセル座標系に103 cellCrd :: Int -> Int104 cellCrd x = x `div` (chrSize * one)
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)