Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add goal check

  • Loading branch information...
commit d84238cbb17168876a5f35a97ee3915e9e60d8cf 1 parent 6905813
@mokehehe authored
Showing with 83 additions and 13 deletions.
  1. +55 −1 Main.hs
  2. +5 −0 Makefile
  3. +19 −8 Player.hs
  4. +4 −4 ToDo.txt
View
56 Main.hs
@@ -201,12 +201,18 @@ doGameMain fldmap gameState keyprocs = start : loop initialPad gameState (tail k
where
pad = updatePad opad $ key2btn ks
(scr', gs') = updateProc pad gs
- isPlayerDead = getPlayerY (pl_of gs') >= (screenHeight + chrSize * 2) * one
+-- isPlayerDead = getPlayerY (pl_of gs') >= (screenHeight + chrSize * 2) * one
+ isPlayerDead = getPlayerDead (pl_of gs') || getPlayerY (pl_of gs') >= (screenHeight + chrSize * 2) * one
timeOver = time_of gs' <= 0
left
| isPlayerDead || timeOver = doPlayerDead fldmap gs kss
+ | isGoal = doGoal fldmap gs kss
| otherwise = loop pad gs' kss
+
+ isGoal = getPlayerX (pl_of gs') >= pollx * 16 * one
+ pollx = length $ takeWhile (/= 'o') (fld_of gs' !! 2)
+
loop _ _ [] = undefined
-- Update
@@ -243,6 +249,36 @@ doGameMain fldmap gameState keyprocs = start : loop initialPad gameState (tail k
putStrLn $ "play " ++ show sndtype
return ()
+-- Goal
+doGoal :: Field -> GameGame -> [KeyProc] -> [Resources -> Scr]
+doGoal fldmap gameState keyprocs =
+ end : loop initialPad gameState (tail keyprocs)
+ where
+ end _ _ = do
+ stopBGM
+
+ loop :: Pad -> GameGame -> [KeyProc] -> [Resources -> Scr]
+ loop opad gs (ks:kss) = scr' : left
+ where
+ pad = updatePad opad $ key2btn ks
+ (scr', gs') = updateProc pad gs
+ left = loop pad gs' kss
+
+ updateProc :: Pad -> GameGame -> (Resources -> Scr, GameGame)
+ updateProc pad gs = (scr', gs)
+ where
+ scr' resources@(_, sndres) sur = do
+ renderProc gs resources sur
+
+ disp (imgres,_) sur = do
+ fillRect sur Nothing black
+ renderInfo gameState imgres sur
+ puts 11 15 "GOAL"
+
+ where
+ puts = fontPut font sur
+ font = Font (getImageSurface imgres ImgFont) 8 8 16
+
-- PlayerDead
doPlayerDead :: Field -> GameGame -> [KeyProc] -> [Resources -> Scr]
doPlayerDead fldmap gs keyprocs =
@@ -252,6 +288,24 @@ doPlayerDead fldmap gs keyprocs =
where
gs' = gs { num_pl_of = num_pl_of gs - 1 }
+{-
+-- PlayerDead
+doPlayerDead :: Field -> GameGame -> [KeyProc] -> [Resources -> Scr]
+doPlayerDead fldmap gameState keyprocs = start : loop initialPad gameState (tail keyprocs)
+ where
+ frameCount = 120
+
+ start _ _ = do
+ playBGM $ bgmPath ++ bgmFn BGMMain
+
+ branch =
+ if num_pl_of gs > 1
+ then doDispRest fldmap gs' keyprocs
+ else doGameOver fldmap gs' keyprocs
+ where
+ gs' = gs { num_pl_of = num_pl_of gs - 1 }
+-}
+
-- GameOver
doGameOver :: Field -> GameGame -> [KeyProc] -> [Resources -> Scr]
doGameOver fldmap gameState keyprocs =
View
5 Makefile
@@ -1,6 +1,8 @@
RUNHASKELL = runhaskell Setup.lhs
+SRCS = $(wildcard *.hs) $(wildcard Actor/*.hs)
+
all: build
configure:
@@ -15,6 +17,9 @@ clean:
run:
dist/build/monao/monao
+run-fullscreen:
+ dist/build/monao/monao --fullscreen
+
doc:
haddock -h -o man -l C:\\ghc\\haddock-2.0.0.0 -B c:\\ghc\\ghc-6.8.2 *.hs
View
27 Player.hs
@@ -18,7 +18,8 @@ module Player (
getPlayerType,
setPlayerType,
setPlayerDamage,
- stampPlayer
+ stampPlayer,
+ getPlayerDead
) where
import Graphics.UI.SDL (Surface)
@@ -53,7 +54,7 @@ data PlayerType = SmallMonao | SuperMonao | FireMonao
deriving (Eq)
-- State
-data PlayerState = Normal | Dead
+data PlayerState = Normal | DeadFall | Dead
deriving (Eq)
-- Structure
@@ -105,12 +106,12 @@ patJump = patWalk + walkPatNum
patSlip = patJump + 1
patSit = patSlip + 1
patShot = patSit + 1
-patDead = patShot + 2
+patDead = patShot + 1
imgTableSmall, imgTableSuper, imgTableFire :: [[ImageType]]
imgTableSmall = [
- [ImgMonaoLStand, ImgMonaoLWalk1, ImgMonaoLWalk2, ImgMonaoLWalk3, ImgMonaoLJump, ImgMonaoLSlip, ImgMonaoLStand],
- [ImgMonaoRStand, ImgMonaoRWalk1, ImgMonaoRWalk2, ImgMonaoRWalk3, ImgMonaoRJump, ImgMonaoRSlip, ImgMonaoRStand]
+ [ImgMonaoLStand, ImgMonaoLWalk1, ImgMonaoLWalk2, ImgMonaoLWalk3, ImgMonaoLJump, ImgMonaoLSlip, ImgMonaoLStand, ImgMonaoLStand, ImgMonaoDead],
+ [ImgMonaoRStand, ImgMonaoRWalk1, ImgMonaoRWalk2, ImgMonaoRWalk3, ImgMonaoRJump, ImgMonaoRSlip, ImgMonaoRStand, ImgMonaoLStand, ImgMonaoDead]
]
imgTableSuper = [
[ImgSMonaoLStand, ImgSMonaoLWalk1, ImgSMonaoLWalk2, ImgSMonaoLWalk3, ImgSMonaoLJump, ImgSMonaoLSlip, ImgSMonaoLSit],
@@ -264,8 +265,9 @@ shot pad self
updatePlayer :: Pad -> Field -> Player -> (Player, [Event])
updatePlayer pad fld self =
case plstate self of
- Normal -> updateNormal pad fld self'
- Dead -> updateDead pad fld self'
+ Normal -> updateNormal pad fld self'
+ DeadFall -> updateDeadFall pad fld self'
+ Dead -> updateDead pad fld self'
where
self' = decUndead self
decUndead pl = pl { undeadCount = max 0 $ undeadCount pl - 1 }
@@ -280,6 +282,10 @@ updateNormal pad fld self = (self3, ev1 ++ ev2 ++ ev3)
moveY = doJump pad . checkFloor fld . fall (pressing pad padA)
-- In dead state
+updateDeadFall :: Pad -> Field -> Player -> (Player, [Event])
+updateDeadFall _ _ self = (fall False self, [])
+
+-- In dead state
updateDead :: Pad -> Field -> Player -> (Player, [Event])
updateDead _ _ self = (fall False self, [])
@@ -326,7 +332,7 @@ setPlayerType t self = self { pltype = t }
setPlayerDamage :: Player -> Player
setPlayerDamage self
| undeadCount self > 0 = self
- | pltype self == SmallMonao = self { plstate = Dead, pat = patDead, vy = jumpVy, stand = False }
+ | pltype self == SmallMonao = self { pltype = SmallMonao, plstate = DeadFall, pat = patDead, vy = jumpVy, stand = False }
| otherwise = self { pltype = SmallMonao, undeadCount = undeadFrame }
-- Stamp enemy
@@ -341,6 +347,11 @@ playerGetCoin self = self { coin = (coin self + 1) `mod` 100 }
addScore :: Int -> Player -> Player
addScore a self = self { score = score self + a }
+-- Player is dead?
+getPlayerDead :: Player -> Bool
+getPlayerDead self =
+ plstate self /= Normal
+
-- Render
renderPlayer :: Surface -> ImageResource -> Int -> Player -> IO ()
renderPlayer sur imgres scrx_ self = do
View
8 ToDo.txt
@@ -12,7 +12,6 @@
- 土管に入れる
- コイン100枚で1UP
- 隠し1UP
--[v] サウンド追加
- コインなどのカラチェン
- 敵同士の当たり判定
- ポールの高さで得点
@@ -24,12 +23,13 @@
- タイトル画面でちゃんと背景を出す
- デモプレイ(リプレイ)
- アプリ終了時にエラーが出るのを修正
--[X] ウィンドウを拡大
--- SDL に機能がない
-- きのことかフラワーがにょきにょき出てくるように
- ダッシュすると2ブロックの隙間も走り抜けられてしまう
- 遅いマシン用対策(固定時間で待たない)
+-[v] サウンド追加
+-[v] きのことかフラワーがにょきにょき出てくるように
-[v] コマンドラインオプションでフルスクリーン化
+-[X] ウィンドウを拡大
+-- SDL に機能がない
* ソース
Please sign in to comment.
Something went wrong with that request. Please try again.