Permalink
Browse files

エフェクトオブジェクト(コイン取得、スコア加算、ブロック破壊)追加

git-svn-id: http://svn.coderepos.org/share/lang/haskell/nario@20775 d0d07461-0603-4401-acd4-de1884942a52
  • Loading branch information...
1 parent 2da9925 commit 28738a9492168d4bd44afd2b45c7f4fc346f241e mokehehe committed Oct 5, 2008
Showing with 189 additions and 30 deletions.
  1. +1 −4 Actor/AnimBlock.hs
  2. +46 −0 Actor/BrokenBlock.hs
  3. +46 −0 Actor/CoinGet.hs
  4. +4 −2 Actor/Kinoko.hs
  5. +35 −0 Actor/ScoreAdd.hs
  6. +3 −0 Event.hs
  7. +3 −3 Images.hs
  8. +30 −11 Main.hs
  9. +21 −10 Player.hs
View
@@ -13,9 +13,6 @@ import Images
import Field
import Event
--- ============================================================================
--- AnimBlock
--- ブロックを叩いたときのバウンド演出
data AnimBlock = AnimBlock {
startcy :: Int,
@@ -39,7 +36,7 @@ instance Actor AnimBlock where
else []
render self imgres scrx sur = do
- blitSurface (getImageSurface imgres $ chr2img $ chr self) Nothing sur (pt ((x self) `div` one - scrx) ((y self) `div` one - 8))
+ blitSurface (getImageSurface imgres $ chr2img $ chr self) Nothing sur (pt (x self `div` one - scrx) (y self `div` one - 8))
return ()
bDead self = vy self > 0 && y self >= startcy self * chrSize * one
View
@@ -0,0 +1,46 @@
+-- ブロックを叩いたときのバウンド演出
+
+module Actor.BrokenBlock (
+ newBrokenBlock
+) where
+
+import Multimedia.SDL hiding (Event)
+
+import Actor (Actor(..))
+import AppUtil
+import Const
+import Images
+
+
+data BrokenBlock = BrokenBlock {
+ x :: Int,
+ y :: Int,
+ vx :: Int,
+ vy :: Int
+ }
+
+instance Actor BrokenBlock where
+ update _ self = (self { x = x self + vx self, y = y self + vy self, vy = vy self + gravity }, [])
+
+ render self imgres scrx sur = do
+ blitSurface (getImageSurface imgres ImgBroken) Nothing sur (pt (x self `div` one - 4 - scrx) (y self `div` one - 4 - 8))
+ return ()
+
+ bDead self = y self >= (screenHeight + chrSize * 2) * one
+
+newBrokenBlock :: Int -> Int -> [BrokenBlock]
+newBrokenBlock cx cy =
+ [ BrokenBlock { x = xx + dx1, y = yy + dy1, vx = -vx', vy = vy1 },
+ BrokenBlock { x = xx + dx2, y = yy + dy1, vx = vx', vy = vy1 },
+ BrokenBlock { x = xx + dx1, y = yy + dy2, vx = -vx', vy = vy2 },
+ BrokenBlock { x = xx + dx2, y = yy + dy2, vx = vx', vy = vy2 } ]
+ where
+ xx = cx * chrSize * one
+ yy = cy * chrSize * one
+ dx1 = 4 * one
+ dx2 = 12 * one
+ dy1 = 4 * one
+ dy2 = 12 * one
+ vx' = 3 * one `div` 2
+ vy1 = -8 * one
+ vy2 = -5 * one
View
@@ -0,0 +1,46 @@
+-- コインを取ったときの演出コイン
+
+module Actor.CoinGet (
+ newCoinGet
+) where
+
+import Multimedia.SDL hiding (Event)
+
+import Actor (Actor(..))
+import AppUtil
+import Const
+import Images
+import Event
+
+
+data CoinGet = CoinGet {
+ sx :: Int,
+ y :: Int,
+ vy :: Int,
+ cnt :: Int,
+ starty :: Int
+ }
+
+imgtbl = [ImgCoin0, ImgCoin1, ImgCoin2, ImgCoin3]
+
+instance Actor CoinGet where
+ update _ self
+ | bDead self' = (self', [EvScoreAddEfe (sx self) (y self `div` one) Img1000])
+ | otherwise = (self', [])
+ where
+ self' = self { y = y self + vy self, vy = vy self + gravity, cnt = cnt self + 1 }
+
+ render self imgres scrx sur = do
+ blitSurface (getImageSurface imgres imgtype) Nothing sur (pt (sx self - scrx) (y self `div` one - 8))
+ return ()
+ where
+ imgtype = imgtbl !! (cnt self `div` 2 `mod` 4)
+
+ bDead self = vy self > 0 && y self >= (starty self - chrSize * one)
+
+newCoinGet :: Int -> Int -> CoinGet
+newCoinGet cx cy =
+ CoinGet { sx = xx, y = yy, vy = -12 * gravity, cnt = 0, starty = yy }
+ where
+ xx = cx * chrSize + 4
+ yy = (cy - 1) * chrSize * one
View
@@ -12,10 +12,12 @@ import Util (sgn)
import AppUtil (getImageSurface, cellCrd, Rect(..))
import Images
import Field
-import Player (PlayerType(..), getPlayerType, setPlayerType)
+import Player (PlayerType(..), getPlayerType, setPlayerType, addScore)
maxVy = one * 6
+pointKinoko = 1000
+
data Kinoko = Kinoko {
x :: Int,
@@ -52,7 +54,7 @@ instance Actor Kinoko where
xx = x self `div` one
yy = y self `div` one
- onHit pl self = (setPlayerType nt pl, Nothing)
+ onHit pl self = (addScore pointKinoko $ setPlayerType nt pl, Nothing)
where
nt = case typ of
SmallNario -> SuperNario
View
@@ -0,0 +1,35 @@
+-- スコアが増えるときの増分表示
+
+module Actor.ScoreAdd (
+ newScoreAdd
+) where
+
+import Multimedia.SDL hiding (Event)
+
+import Actor (Actor(..))
+import AppUtil
+import Const
+import Images
+
+vy = -1
+
+data ScoreAdd = ScoreAdd {
+ imgtype :: ImageType,
+ sx :: Int,
+ sy :: Int,
+ cnt :: Int
+ }
+
+
+instance Actor ScoreAdd where
+ update _ self = (self { sy = sy self + vy, cnt = cnt self + 1 }, [])
+
+ render self imgres scrx sur = do
+ blitSurface (getImageSurface imgres $ imgtype self) Nothing sur (pt (sx self - scrx) (sy self))
+ return ()
+
+ bDead self = cnt self >= frameRate `div` 2
+
+newScoreAdd :: Int -> Int -> ImageType -> ScoreAdd
+newScoreAdd sx' sy' imgtype' =
+ ScoreAdd { imgtype = imgtype', sx = sx', sy = sy', cnt = 0 }
View
@@ -13,3 +13,6 @@ data Event =
-- 敵登場
| EvAppearEnemy Int Int Cell
+
+ -- スコア加算エフェクト
+ | EvScoreAddEfe Int Int ImageType
View
@@ -1,6 +1,6 @@
module Images (ImageType(..), imageTypes, imageFn) where
import Maybe (fromJust)
-data ImageType = ImgBlock1 | ImgBlock2 | ImgBlock3 | ImgBlock4 | ImgBlock5 | ImgCloud00 | ImgCloud01 | ImgCloud02 | ImgCloud10 | ImgCloud11 | ImgCloud12 | ImgCoin0 | ImgCoin1 | ImgCoin2 | ImgCoin3 | 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 | ImgKuriDead | ImgMt02 | ImgMt11 | ImgMt12 | ImgMt13 | ImgMt22 | ImgNarioDead | 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)
-imageTypes = [ImgBlock1, ImgBlock2, ImgBlock3, ImgBlock4, ImgBlock5, ImgCloud00, ImgCloud01, ImgCloud02, ImgCloud10, ImgCloud11, ImgCloud12, ImgCoin0, ImgCoin1, ImgCoin2, ImgCoin3, 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, ImgKuriDead, ImgMt02, ImgMt11, ImgMt12, ImgMt13, ImgMt22, ImgNarioDead, 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]
-imageFilenames = ["block1.bmp", "block2.bmp", "block3.bmp", "block4.bmp", "block5.bmp", "cloud00.bmp", "cloud01.bmp", "cloud02.bmp", "cloud10.bmp", "cloud11.bmp", "cloud12.bmp", "coin0.bmp", "coin1.bmp", "coin2.bmp", "coin3.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", "kuriDead.bmp", "mt02.bmp", "mt11.bmp", "mt12.bmp", "mt13.bmp", "mt22.bmp", "narioDead.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"]
+data ImageType = Img100 | Img1000 | Img200 | Img500 | ImgBlock1 | ImgBlock2 | ImgBlock3 | ImgBlock4 | ImgBlock5 | ImgBroken | ImgCloud00 | ImgCloud01 | ImgCloud02 | ImgCloud10 | ImgCloud11 | ImgCloud12 | ImgCoin0 | ImgCoin1 | ImgCoin2 | ImgCoin3 | 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 | ImgKuriDead | ImgMt02 | ImgMt11 | ImgMt12 | ImgMt13 | ImgMt22 | ImgNarioDead | 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)
+imageTypes = [Img100, Img1000, Img200, Img500, ImgBlock1, ImgBlock2, ImgBlock3, ImgBlock4, ImgBlock5, ImgBroken, ImgCloud00, ImgCloud01, ImgCloud02, ImgCloud10, ImgCloud11, ImgCloud12, ImgCoin0, ImgCoin1, ImgCoin2, ImgCoin3, 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, ImgKuriDead, ImgMt02, ImgMt11, ImgMt12, ImgMt13, ImgMt22, ImgNarioDead, 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]
+imageFilenames = ["100.bmp", "1000.bmp", "200.bmp", "500.bmp", "block1.bmp", "block2.bmp", "block3.bmp", "block4.bmp", "block5.bmp", "broken.bmp", "cloud00.bmp", "cloud01.bmp", "cloud02.bmp", "cloud10.bmp", "cloud11.bmp", "cloud12.bmp", "coin0.bmp", "coin1.bmp", "coin2.bmp", "coin3.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", "kuriDead.bmp", "mt02.bmp", "mt11.bmp", "mt12.bmp", "mt13.bmp", "mt22.bmp", "narioDead.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"]
imageFn = fromJust . flip lookup (zip imageTypes imageFilenames)
View
@@ -22,13 +22,21 @@ import Actor.Kuribo
import Actor.Nokonoko
import Actor.Kinoko
import Actor.Flower
+import Actor.BrokenBlock
+import Actor.CoinGet
+import Actor.ScoreAdd
-- 背景色
backColor = 0x5080FF
-- 描画コマンド
type Scr = Surface -> IO ()
+
+pointBreakBlock = 50
+pointGetCoin = 200
+
+
-- エントリ
main :: IO ()
main = do
@@ -109,7 +117,6 @@ doTitle fldmap kss = loop kss
| otherwise = loop kss
-
-- マップのスクロールに応じたイベント
scrollEvent :: Field -> Int -> (Field, [Event])
scrollEvent fld cx
@@ -126,7 +133,6 @@ scrollEvent fld cx
| otherwise = Nothing
-
-- 当たり判定
hitcheck :: Player -> [ActorWrapper] -> (Player, [ActorWrapper])
hitcheck player actors = foldl proc (player, []) actors
@@ -190,23 +196,36 @@ procEvent gs ev = foldl proc gs ev
where
proc gs (EvHitBlock imgtype cx cy bSuper)
| hardBlock c = gs
- | bSuper && breakable c = gs { fld = fieldSet (fld gs) cx cy ' ' }
- | otherwise = gs { fld = fld', actors = actors' }
+ | bSuper && breakable c = breakBlock gs cx cy
+ | c == 'K' = genKinoko
+ | c == '?' = getCoin
+ | otherwise = gs'
where
c = fieldRef (fld gs) cx cy
- items
- | c == 'K' = if not bSuper then [ActorWrapper $ newKinoko cx cy] else [ActorWrapper $ newFlower cx cy]
- | otherwise = []
- actors' = actors gs ++ [ActorWrapper $ newAnimBlock cx cy $ fieldRef (fld gs) cx cy] ++ items
- fld' = fieldSet (fld gs) cx cy '*'
breakable c = c == 'O'
+
+ gs' = gs { fld = fld', actors = actors' }
+ actors' = actors gs ++ [ActorWrapper $ newAnimBlock cx cy $ fieldRef (fld gs) cx cy]
+ fld' = fieldSet (fld gs) cx cy '*'
+
+ breakBlock gs cx cy =
+ gs {
+ fld = fieldSet (fld gs) cx cy ' ',
+ actors = actors gs ++ map ActorWrapper (newBrokenBlock cx cy),
+ pl = addScore pointBreakBlock $ pl gs
+ }
+ genKinoko = gs' { actors = actors gs' ++ [a] }
+ where a = if not bSuper then ActorWrapper $ newKinoko cx cy else ActorWrapper $ newFlower cx cy
+ getCoin = gs' { actors = actors gs' ++ [ActorWrapper a], pl = addScore pointGetCoin $ playerGetCoin $ pl gs' }
+ where a = newCoinGet cx cy
+
proc gs (EvSetField cx cy c) = gs { fld = fieldSet (fld gs) cx cy c }
proc gs (EvAppearEnemy cx cy c) = gs { actors = actors gs ++ [ene] }
where
ene = case c of
'k' -> ActorWrapper $ newKuribo cx cy
'n' -> ActorWrapper $ newNokonoko cx cy
-
+ proc gs (EvScoreAddEfe sx sy imgtype) = gs { actors = actors gs ++ [ActorWrapper $ newScoreAdd sx sy imgtype] }
-- 描画
renderProc :: GameGame -> ImageResource -> Scr
@@ -231,7 +250,7 @@ renderInfo :: GameGame -> ImageResource -> Scr
renderInfo gs imgres sur = do
puts 3 1 "NARIO"
puts 3 2 $ deciWide 6 '0' $ getPlayerScore (pl gs)
- puts 11 2 ("?*" ++ deciWide 2 '0' (getPlayerMedal (pl gs)))
+ puts 11 2 ("?*" ++ deciWide 2 '0' (getPlayerCoin (pl gs)))
puts 18 1 "WORLD"
puts 19 2 "1-1"
puts 25 1 "TIME"
View
@@ -6,11 +6,13 @@ module Player (
newPlayer,
updatePlayer,
renderPlayer,
+ playerGetCoin,
+ addScore,
getScrollPos,
getPlayerYPos,
getPlayerVY,
getPlayerHitRect,
- getPlayerMedal,
+ getPlayerCoin,
getPlayerScore,
getPlayerType,
setPlayerType,
@@ -60,7 +62,7 @@ data Player = Player {
stand :: Bool,
undeadCount :: Int,
- medal :: Int,
+ coin :: Int,
score :: Int,
lr :: Int,
@@ -79,7 +81,7 @@ newPlayer = Player {
stand = False,
undeadCount = 0,
- medal = 0,
+ coin = 0,
score = 0,
lr = 1,
@@ -205,18 +207,19 @@ checkFloor fld self
checkCeil :: Field -> Player -> (Player, [Event])
checkCeil fld self
| stand self || vy self >= 0 || not isCeil = (self, [])
- | otherwise = (self { vy = 0, score = (score self) + 10 }, [EvHitBlock ImgBlock2 cx cy (pltype self /= SmallNario)])
+ | otherwise = (self { y = y', vy = 0 }, [EvHitBlock ImgBlock2 cx cy (pltype self /= SmallNario)])
where
yofs = case pltype self of
- SmallNario -> 15
- SuperNario -> 30
- FireNario -> 30
+ SmallNario -> 14
+ SuperNario -> 28
+ FireNario -> 28
ytmp = y self - yofs * one
cx = cellCrd $ x self
cy = cellCrd ytmp
isCeil = isBlock $ fieldRef fld cx cy
yground y = (cellCrd y) * (chrSize * one)
+ y' = ((cy + 1) * chrSize + yofs) * one
-- ジャンプする?
@@ -266,9 +269,9 @@ getPlayerHitRect self = Rect (xx - 6) (yy - 16) (xx + 6) yy
xx = x self `div` one
yy = y self `div` one
--- メダル枚数取得
-getPlayerMedal :: Player -> Int
-getPlayerMedal = medal
+-- コイン枚数取得
+getPlayerCoin :: Player -> Int
+getPlayerCoin = coin
-- スコア取得
getPlayerScore :: Player -> Int
@@ -293,6 +296,14 @@ setPlayerDamage self
stampPlayer :: Player -> Player
stampPlayer self = self { vy = stampVy }
+-- コイン取得
+playerGetCoin :: Player -> Player
+playerGetCoin self = self { coin = (coin self + 1) `mod` 100 }
+
+-- スコア加算
+addScore :: Int -> Player -> Player
+addScore a self = self { score = score self + a }
+
-- 描画
renderPlayer sur imgres scrx self = do
if undeadCount self == 0 || (undeadCount self .&. 1) /= 0

0 comments on commit 28738a9

Please sign in to comment.