Changeset 20661 for lang/haskell/nario/Main.hs
- Timestamp:
- 10/04/08 07:57:29 (3 months ago)
- Files:
-
- 1 modified
-
lang/haskell/nario/Main.hs (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/haskell/nario/Main.hs
r20641 r20661 20 20 import Event 21 21 import Actor 22 import Actor.AnimBlock 23 import Actor.Kuribo 22 24 23 25 wndTitle = "NARIO in Haskell" … … 113 115 | otherwise = loop kss 114 116 117 118 119 -- マップのスクロールに応じたイベント 120 scrollEvent :: Field -> Int -> (Field, [Event]) 121 scrollEvent fld cx 122 | cx < length (head fld) = foldl proc (fld, []) $ zip [0..] cols 123 | otherwise = (fld, []) 124 where 125 proc (f, e) (cy, c) = 126 case event cy c of 127 Just ev -> (fieldSet f cx cy ' ', ev : e) 128 Nothing -> (f, e) 129 cols = map (!! cx) fld 130 event cy c 131 | c `elem` "k" = Just $ EvAppearEnemy cx cy c 132 | otherwise = Nothing 133 115 134 -- ゲーム 116 135 doGame :: Field -> [[SDLKey]] -> [ImageResource -> Scr] … … 133 152 where 134 153 time' = max 0 (time gs - one `div` 25) 135 (pl', ev) = updatePlayer kp (fld gs) (pl gs) 154 (fld', screv') = scrollEvent (fld gs) $ getScrollPos (pl gs) `div` chrSize + 18 155 156 (pl', plev) = updatePlayer kp fld' (pl gs) 136 157 actors_updates = updateActors (actors gs) 137 158 actors' = filterActors $ map fst actors_updates 138 159 ev' = concatMap snd actors_updates 139 160 140 gstmp = gs { pl = pl', actors = actors', time = time' }141 gs' = procEvent gstmp ( ev ++ev')161 gstmp = gs { pl = pl', fld = fld', actors = actors', time = time' } 162 gs' = procEvent gstmp (plev ++ ev' ++ screv') 142 163 143 164 initialState = GameGame { pl = newPlayer, fld = fldmap, actors = [], time = 400 * one } … … 148 169 -- イベントを処理 149 170 procEvent :: GameGame -> [Event] -> GameGame 150 procEvent gs ev = foldl fgs ev151 where 152 fgs (EvHitBlock imgtype cx cy)171 procEvent gs ev = foldl proc gs ev 172 where 173 proc gs (EvHitBlock imgtype cx cy) 153 174 | hardBlock c = gs 154 175 | otherwise = gs { fld = fld', actors = actors' } … … 157 178 actors' = actors gs ++ [ObjWrapper $ newAnimBlock cx cy $ fieldRef (fld gs) cx cy] 158 179 fld' = fieldSet (fld gs) cx cy '*' 159 f gs (EvSetField cx cy c) = gs { fld = fld' } 160 where 161 fld' = fieldSet (fld gs) cx cy c 180 proc gs (EvSetField cx cy c) = gs { fld = fieldSet (fld gs) cx cy c } 181 proc gs (EvAppearEnemy cx cy c) = gs { actors = actors gs ++ [ene] } 182 where 183 ene = case c of 184 'k' -> ObjWrapper $ newKuribo cx cy 162 185 163 186 … … 190 213 puts 25 1 "TIME" 191 214 puts 26 2 $ deciWide 3 ' ' ((time gs + one-1) `div` one) 215 192 216 where 193 217 puts = fontPut sur fontsur
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)