Changeset 20925
- Timestamp:
- 10/07/08 20:42:00 (3 months ago)
- Location:
- lang/haskell/nario
- Files:
-
- 17 modified
-
Actor.hs (modified) (3 diffs)
-
Actor/AnimBlock.hs (modified) (3 diffs)
-
Actor/BrokenBlock.hs (modified) (2 diffs)
-
Actor/CoinGet.hs (modified) (3 diffs)
-
Actor/Flower.hs (modified) (2 diffs)
-
Actor/Kinoko.hs (modified) (2 diffs)
-
Actor/Koura.hs (modified) (2 diffs)
-
Actor/Kuribo.hs (modified) (3 diffs)
-
Actor/Nokonoko.hs (modified) (2 diffs)
-
Actor/ScoreAdd.hs (modified) (2 diffs)
-
AppUtil.hs (modified) (2 diffs)
-
Field.hs (modified) (1 diff)
-
Font.hs (modified) (1 diff)
-
Main.hs (modified) (1 diff)
-
Player.hs (modified) (3 diffs)
-
README.txt (modified) (3 diffs)
-
Util.hs (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
lang/haskell/nario/Actor.hs
r20811 r20925 1 1 {-# OPTIONS_GHC -fglasgow-exts #-} 2 -- -*- mode: haskell; Encoding: UTF-8 -*- 3 4 -- ゲーム内に登場するオブジェクト 2 5 3 6 module Actor ( … … 11 14 import Multimedia.SDL (Surface) 12 15 16 import AppUtil (ImageResource, Rect) 13 17 import Event (Event) 14 import AppUtil (ImageResource, Rect)15 18 import Field (Field) 16 19 import Player (Player) … … 30 33 onHit pl ac = (pl, Nothing, []) 31 34 32 -- ============================================================================33 35 34 36 ---- -
lang/haskell/nario/Actor/AnimBlock.hs
r20811 r20925 1 -- -*- mode: haskell; Encoding: UTF-8 -*-1 -- -*- mode: haskell; Encoding: UTF-8 -*- 2 2 -- ブロックを叩いたときのバウンド演出 3 3 … … 6 6 ) where 7 7 8 import Multimedia.SDL hiding (Event)8 --import Multimedia.SDL hiding (Event) 9 9 10 10 import Actor (Actor(..)) 11 import AppUtil (cellCrd, putimg) 11 12 import Const 12 import AppUtil 13 import Images 14 import Field 15 import Event 13 import Field (Cell, chr2img) 14 import Event (Event(..)) 16 15 17 16 … … 33 32 y' = y self + vy' 34 33 self' = self { vy = vy', y = y' } 35 ev' = if (bDead self')34 ev' = if bDead self' 36 35 then [EvSetField (cellCrd $ x self) (startcy self) $ chr self] 37 36 else [] 38 37 39 38 render self imgres scrx sur = do 40 blitSurface (getImageSurface imgres $ chr2img $ chr self) Nothing sur (pt (x self `div` one - scrx) (y self `div` one - 8))39 putimg sur imgres (chr2img $ chr self) (x self `div` one - scrx) (y self `div` one - 8) 41 40 return () 42 41 -
lang/haskell/nario/Actor/BrokenBlock.hs
r20825 r20925 9 9 10 10 import Actor (Actor(..)) 11 import AppUtil12 11 import Const 12 import AppUtil (putimg) 13 13 import Images 14 14 … … 25 25 26 26 render self imgres scrx sur = do 27 blitSurface (getImageSurface imgres ImgBroken) Nothing sur (pt (x self `div` one - 4 - scrx) (y self `div` one - 4 - 8))27 putimg sur imgres ImgBroken (x self `div` one - 4 - scrx) (y self `div` one - 4 - 8) 28 28 return () 29 29 -
lang/haskell/nario/Actor/CoinGet.hs
r20811 r20925 1 -- -*- mode: haskell; Encoding: UTF-8 -*-1 -- -*- mode: haskell; Encoding: UTF-8 -*- 2 2 -- コインを取ったときの演出コイン 3 3 … … 9 9 10 10 import Actor (Actor(..)) 11 import AppUtil 11 import AppUtil (putimg) 12 12 import Const 13 13 import Images 14 import Event 14 import Event (Event(..)) 15 15 16 16 … … 33 33 34 34 render self imgres scrx sur = do 35 blitSurface (getImageSurface imgres imgtype) Nothing sur (pt (sx self - scrx) (y self `div` one - 8))35 putimg sur imgres imgtype (sx self - scrx) (y self `div` one - 8) 36 36 return () 37 37 where -
lang/haskell/nario/Actor/Flower.hs
r20811 r20925 6 6 ) where 7 7 8 import Multimedia.SDL (blitSurface, pt)8 --import Multimedia.SDL (itSurface, pt) 9 9 10 10 import Actor (Actor(..)) 11 11 import Const 12 12 import Util (sgn) 13 import AppUtil ( getImageSurface, cellCrd, Rect(..))13 import AppUtil (cellCrd, Rect(..), putimg) 14 14 import Images 15 import Field16 15 import Player (PlayerType(..), getPlayerType, setPlayerType, addScore) 17 16 import Event (Event(..)) … … 29 28 30 29 render self imgres scrx sur = do 31 blitSurface (getImageSurface imgres ImgFlower) Nothing sur (pt ((x self) `div` one - chrSize `div` 2 - scrx) ((y self) `div` one - 15 - 8))30 putimg sur imgres ImgFlower ((x self) `div` one - chrSize `div` 2 - scrx) ((y self) `div` one - 15 - 8) 32 31 return () 33 32 -
lang/haskell/nario/Actor/Kinoko.hs
r20825 r20925 6 6 ) where 7 7 8 import Multimedia.SDL (blitSurface, pt)8 --import Multimedia.SDL (blitSurface, pt) 9 9 10 10 import Actor (Actor(..)) 11 11 import Actor.Common (updateActorBase) 12 import AppUtil (Rect(..), putimg) 12 13 import Const 13 import AppUtil (getImageSurface, Rect(..))14 14 import Images 15 15 import Player (PlayerType(..), getPlayerType, setPlayerType, addScore) … … 33 33 34 34 render self imgres scrx sur = do 35 blitSurface (getImageSurface imgres imgtype) Nothing sur (pt ((x self) `div` one - chrSize `div` 2 - scrx) ((y self) `div` one - ofsH - 8))35 putimg sur imgres imgtype ((x self) `div` one - chrSize `div` 2 - scrx) ((y self) `div` one - ofsH - 8) 36 36 return () 37 37 where -
lang/haskell/nario/Actor/Koura.hs
r20825 r20925 6 6 ) where 7 7 8 import Multimedia.SDL (blitSurface, pt)8 --import Multimedia.SDL (blitSurface, pt) 9 9 10 10 import Actor (Actor(..), ActorWrapper(..)) 11 11 import Actor.Common (updateActorBase, stamp) 12 import AppUtil (Rect(..), putimg) 12 13 import Const 13 import AppUtil (getImageSurface, Rect(..))14 14 import Images 15 15 import Player (getPlayerX, stampPlayer, setPlayerDamage, addScore) … … 44 44 45 45 render self imgres scrx sur = do 46 blitSurface (getImageSurface imgres imgtype) Nothing sur (pt ((x self) `div` one - chrSize `div` 2 - scrx) ((y self) `div` one - ofsH - 8))46 putimg sur imgres imgtype ((x self) `div` one - chrSize `div` 2 - scrx) ((y self) `div` one - ofsH - 8) 47 47 return () 48 48 where -
lang/haskell/nario/Actor/Kuribo.hs
r20825 r20925 6 6 ) where 7 7 8 import Multimedia.SDL (blitSurface, pt)8 --import Multimedia.SDL (blitSurface, pt) 9 9 10 10 import Actor (Actor(..), ActorWrapper(..)) 11 11 import Actor.Common (updateActorBase, stamp) 12 import AppUtil (Rect(..), putimg) 12 13 import Const 13 import AppUtil (getImageSurface, Rect(..))14 14 import Images 15 15 import Player (setPlayerDamage, stampPlayer, addScore) … … 33 33 34 34 render self imgres scrx sur = do 35 blitSurface (getImageSurface imgres imgtype) Nothing sur (pt (x self `div` one - chrSize `div` 2 - scrx) (y self `div` one - ofsH - 8))35 putimg sur imgres imgtype (x self `div` one - chrSize `div` 2 - scrx) (y self `div` one - ofsH - 8) 36 36 return () 37 37 where … … 67 67 68 68 render self imgres scrx sur = do 69 blitSurface (getImageSurface imgres ImgKuriDead) Nothing sur (pt (sx self - scrx) (sy self - 7 - 8))69 putimg sur imgres ImgKuriDead (sx self - scrx) (sy self - 7 - 8) 70 70 return () 71 71 -
lang/haskell/nario/Actor/Nokonoko.hs
r20825 r20925 6 6 ) where 7 7 8 import Multimedia.SDL (blitSurface, pt)8 --import Multimedia.SDL (blitSurface, pt) 9 9 10 10 import Actor (Actor(..), ActorWrapper(..)) 11 11 import Actor.Common (updateActorBase, stamp) 12 12 import Actor.Koura 13 import AppUtil (Rect(..), putimg) 13 14 import Const 14 import AppUtil (getImageSurface, Rect(..))15 15 import Images 16 16 import Player (setPlayerDamage, stampPlayer, addScore) … … 34 34 35 35 render self imgres scrx sur = do 36 blitSurface (getImageSurface imgres imgtype) Nothing sur (pt (x self `div` one - chrSize `div` 2 - scrx) (y self `div` one - ofsH - 8))36 putimg sur imgres imgtype (x self `div` one - chrSize `div` 2 - scrx) (y self `div` one - ofsH - 8) 37 37 return () 38 38 where -
lang/haskell/nario/Actor/ScoreAdd.hs
r20811 r20925 6 6 ) where 7 7 8 import Multimedia.SDL hiding (Event)8 --import Multimedia.SDL hiding (Event) 9 9 10 10 import Actor (Actor(..)) 11 import AppUtil 11 import AppUtil (putimg) 12 12 import Const 13 13 import Images … … 27 27 28 28 render self imgres scrx sur = do 29 blitSurface (getImageSurface imgres imgtype) Nothing sur (pt (sx self - scrx) (sy self))29 putimg sur imgres imgtype (sx self - scrx) (sy self) 30 30 return () 31 31 where -
lang/haskell/nario/AppUtil.hs
r20673 r20925 1 1 module AppUtil where 2 2 3 import Multimedia.SDL (Surface, SDLKey(..), loadBMP, freeSurface, surfacePixelFormat, displayFormat, pfPalette, setColorKey, SurfaceFlag(..) )3 import Multimedia.SDL (Surface, SDLKey(..), loadBMP, freeSurface, surfacePixelFormat, displayFormat, pfPalette, setColorKey, SurfaceFlag(..), blitSurface, pt) 4 4 import Data.Maybe (fromJust) 5 5 … … 69 69 getImageSurface imgres = fromJust . flip lookup imgres 70 70 71 putimg :: Surface -> ImageResource -> ImageType -> Int -> Int -> IO () 72 putimg sur imgres imgtype x y = do 73 blitSurface (getImageSurface imgres imgtype) Nothing sur (pt x y) 74 return () 75 71 76 72 77 -- 固定座標系からセル座標系に -
lang/haskell/nario/Field.hs
r20670 r20925 94 94 | c `elem` " *" = return () 95 95 | otherwise = putchr x y c >> return () 96 putchr x y c = blitSurface (getImageSurface imgres $ chr2img c) Nothing sur $ pt(x*chrSize - rx) (y*chrSize - 8)96 putchr x y c = putimg sur imgres (chr2img c) (x*chrSize - rx) (y*chrSize - 8) 97 97 98 98 -- 表示される部分だけ取り出す -
lang/haskell/nario/Font.hs
r20670 r20925 1 -- -*- mode: haskell; Encoding: UTF-8 -*- 1 2 -- Bitmap font 2 3 module Font ( 4 Font(..), 3 5 fontPut, 4 6 fontPutc 5 7 ) where 6 8 7 import Multimedia.SDL 8 import Control.Monad 9 import Data.Char 9 import Multimedia.SDL (blitSurface, pt, Rect(..), Surface) 10 import Control.Monad (zipWithM_) 11 import Data.Char (ord) 10 12 11 fontWidth = 8 12 fontHeight = 8 13 fontXN = 16 13 data Font = Font { 14 fontSurface :: Surface, 15 fontWidth :: Int, 16 fontHeight :: Int, 17 fontXN :: Int 18 } 19 14 20 15 21 -- 文字列表示 16 fontPut sur imgsur x y str = zipWithM_ (\i c -> fontPutc sur imgsur i y c) [x..] str22 fontPut font sur x y str = zipWithM_ (\i c -> fontPutc font sur i y c) [x..] str 17 23 18 24 -- 1文字表示 19 fontPutc sur imgsur x y c = do20 blitSurface imgsur(Just rc) sur pos25 fontPutc font sur x y c = do 26 blitSurface (fontSurface font) (Just rc) sur pos 21 27 where 22 pos = pt (x * fontWidth) (y * fontHeight)28 pos = pt (x * (fontWidth font)) (y * (fontHeight font)) 23 29 ic = ord c - ord ' ' 24 u = (ic `mod` fontXN) * fontWidth 25 v = (ic `div` fontXN) * fontHeight 26 rc = Rect u v fontWidth fontHeight 30 u = (ic `mod` xn) * w 31 v = (ic `div` xn) * h 32 rc = Rect u v w h 33 34 xn = fontXN font 35 w = fontWidth font 36 h = fontHeight font -
lang/haskell/nario/Main.hs
r20825 r20925 240 240 return () 241 241 242 tailN n = reverse . take n . reverse243 244 deciWide w c n = tailN w $ replicate w c ++ show n245 246 242 -- 情報描画 247 243 renderInfo :: GameGame -> ImageResource -> Scr 248 244 renderInfo gs imgres sur = do 249 puts 3 1 "NARIO"250 puts 3 2 $ deciWide 6 '0' $ getPlayerScore (pl gs)251 puts 11 2 ("?*" ++ deciWide 2 '0' (getPlayerCoin (pl gs)))245 puts 3 1 "NARIO" 246 puts 3 2 $ deciWide 6 '0' $ getPlayerScore (pl gs) 247 puts 11 2 ("?*" ++ deciWide 2 '0' (getPlayerCoin $ pl gs)) 252 248 puts 18 1 "WORLD" 253 249 puts 19 2 "1-1" 254 250 puts 25 1 "TIME" 255 puts 26 2 $ deciWide 3 '0' ((time gs + timeBase-1) `div` timeBase) 256 257 where 258 puts = fontPut sur fontsur 259 fontsur = getImageSurface imgres ImgFont 251 puts 26 2 $ deciWide 3 '0' $ (time gs + timeBase-1) `div` timeBase 252 where 253 puts = fontPut font sur 254 font = Font (getImageSurface imgres ImgFont) 8 8 16 260 255 261 256 -- タイトル画面 262 257 renderTitle imgres sur = do 263 blitSurface (getImageSurface imgres ImgTitle) Nothing sur (pt (5*8) (3*8))258 putimg sur imgres ImgTitle (5*8) (3*8) 264 259 -- puts 13 14 "@1985 NINTENDO" 265 puts 9 17 "> 1 PLAYER GAME"266 -- puts 9 19 " 2 PLAYER GAME"260 puts 9 17 "> 1 PLAYER GAME" 261 -- puts 9 19 " 2 PLAYER GAME" 267 262 puts 12 22 "TOP- 000000" 268 263 where 269 puts = fontPut sur fontsur270 font sur = getImageSurface imgres ImgFont264 puts = fontPut font sur 265 font = Font (getImageSurface imgres ImgFont) 8 8 16 -
lang/haskell/nario/Player.hs
r20811 r20925 26 26 27 27 import Util 28 import AppUtil (KeyProc, isPressed, PadBtn(..), cellCrd, KeyState(..), getImageSurface, Rect(..) )28 import AppUtil (KeyProc, isPressed, PadBtn(..), cellCrd, KeyState(..), getImageSurface, Rect(..), putimg) 29 29 import Const 30 30 import Images … … 120 120 moveX :: KeyProc -> Player -> Player 121 121 moveX kp self = 122 if (stand self)122 if stand self 123 123 then self' { lr = lr', pat = pat', anm = anm' } 124 124 else self' … … 324 324 renderPlayer sur imgres scrx self = do 325 325 if undeadCount self == 0 || (undeadCount self .&. 1) /= 0 326 then blitSurface (getImageSurface imgres imgtype) Nothing sur pos >> return ()326 then putimg sur imgres imgtype sx posy 327 327 else return () 328 328 where 329 pos = case pltype self of330 SmallNario -> pt sx $sy - chrSize + 1331 otherwise -> pt sx $sy - chrSize * 2 + 1329 posy = case pltype self of 330 SmallNario -> sy - chrSize + 1 331 otherwise -> sy - chrSize * 2 + 1 332 332 imgtype 333 333 | plstate self == Dead = ImgNarioDead -
lang/haskell/nario/README.txt
r20811 r20925 4 4 5 5 を Haskell/HSDL で作る 6 7 HSDL8 http://fxp.hp.infoseek.co.jp/haskell/HSDL/9 6 10 7 … … 15 12 16 13 スペースキー, z 17 Aボタン14 ジャンプ(Aボタン) 18 15 19 16 シフトキー 20 Bボタン17 ダッシュ(Bボタン) 21 18 22 19 エスケープキー … … 47 44 48 45 ○実行 49 できた実行ファイルを 入力、または46 できた実行ファイルを起動する、または 50 47 make run 51 48 -
lang/haskell/nario/Util.hs
r20670 r20925 7 7 replace ls i v = take i ls ++ [v] ++ drop (i + 1) ls 8 8 9 -- 符号を返す 9 -- けつの n 個取り出し 10 lastN n xs = loop n [] xs 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 15 16 -- 数値の符号を返す 10 17 sgn x 11 18 | x > 0 = 1 12 19 | x < 0 = -1 13 20 | otherwise = 0 21 22 -- 10進数 n 桁文字列を返す 23 deciWide n c = lastN n . (replicate n c ++) . show 14 24 15 25 -- x に d を加算した結果が x0~x1 の範囲内を超えないようにする
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)