Changeset 20811 for lang/haskell/nario/Actor/Kinoko.hs
- Timestamp:
- 10/05/08 22:27:31 (3 months ago)
- Files:
-
- 1 modified
-
lang/haskell/nario/Actor/Kinoko.hs (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/haskell/nario/Actor/Kinoko.hs
r20775 r20811 1 -- -*- mode: haskell; Encoding: UTF-8 -*- 1 2 -- きのこ 2 3 … … 8 9 9 10 import Actor (Actor(..)) 11 import Actor.Common (updateActorBase) 10 12 import Const 11 import Util (sgn)12 13 import AppUtil (getImageSurface, cellCrd, Rect(..)) 13 14 import Images 14 15 import Field 15 16 import Player (PlayerType(..), getPlayerType, setPlayerType, addScore) 17 import Event (Event(..)) 16 18 17 maxVy = one * 6 18 19 pointKinoko = 1000 19 ofsH = 15 20 20 21 21 … … 28 28 29 29 instance Actor Kinoko where 30 update fld self 31 | isGround = (self { x = x', vx = vx', y = (cellCrd y') * one * chrSize, vy = 0 }, []) 32 | otherwise = (self { x = x', vx = vx', y = y', vy = vy' }, []) 30 update fld self = (self', []) 33 31 where 34 x' = x self + vx self 35 sideWall = isBlock $ fieldRef fld (cellCrd $ x' + sgn (vx self) * 6 * one) (cellCrd $ y self - chrSize * one `div` 2) 36 vx' 37 | sideWall = -(vx self) 38 | otherwise = vx self 39 40 vy' = min maxVy $ vy self + gravity 41 y' = y self + vy' 42 isGround = isBlock $ fieldRef fld (cellCrd $ x') (cellCrd y') 32 self' = self { x = x', y = y', vx = vx', vy = vy' } 33 (x', y', vx', vy') = updateActorBase fld (x self, y self, vx self, vy self) 43 34 44 35 render self imgres scrx sur = do 45 blitSurface (getImageSurface imgres imgtype) Nothing sur (pt ((x self) `div` one - chrSize `div` 2 - scrx) ((y self) `div` one - 15- 8))36 blitSurface (getImageSurface imgres imgtype) Nothing sur (pt ((x self) `div` one - chrSize `div` 2 - scrx) ((y self) `div` one - ofsH - 8)) 46 37 return () 47 38 where 48 39 imgtype = ImgKinoko 49 40 50 bDead self = y self `div` one >= screenHeight + chrSize * 341 bDead self = y self >= (screenHeight + chrSize * 3) * one || x self <= -chrSize * one 51 42 52 43 getHitRect self = Just $ Rect (xx - 8) (yy - 16) (xx + 8) yy … … 55 46 yy = y self `div` one 56 47 57 onHit pl self = (addScore pointKinoko $ setPlayerType nt pl, Nothing )48 onHit pl self = (addScore pointKinoko $ setPlayerType nt pl, Nothing, ev) 58 49 where 59 50 nt = case typ of … … 61 52 otherwise -> typ 62 53 typ = getPlayerType pl 63 54 ev = [EvScoreAddEfe (x self `div` one) (y self `div` one - chrSize * 2) pointKinoko] 64 55 65 56 newKinoko :: Int -> Int -> Kinoko
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)