root/lang/haskell/nario/Actor/CoinGet.hs @ 20775

Revision 20775, 1.0 kB (checked in by mokehehe, 6 years ago)

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

Line 
1-- コインを取ったときの演出コイン
2
3module Actor.CoinGet (
4        newCoinGet
5) where
6
7import Multimedia.SDL hiding (Event)
8
9import Actor (Actor(..))
10import AppUtil
11import Const
12import Images
13import Event
14
15
16data CoinGet = CoinGet {
17        sx :: Int,
18        y :: Int,
19        vy :: Int,
20        cnt :: Int,
21        starty :: Int
22        }
23
24imgtbl = [ImgCoin0, ImgCoin1, ImgCoin2, ImgCoin3]
25
26instance Actor CoinGet where
27        update _ self
28                | bDead self'   = (self', [EvScoreAddEfe (sx self) (y self `div` one) Img1000])
29                | otherwise             = (self', [])
30                where
31                        self' = self { y = y self + vy self, vy = vy self + gravity, cnt = cnt self + 1 }
32
33        render self imgres scrx sur = do
34                blitSurface (getImageSurface imgres imgtype) Nothing sur (pt (sx self - scrx) (y self `div` one - 8))
35                return ()
36                where
37                        imgtype = imgtbl !! (cnt self `div` 2 `mod` 4)
38
39        bDead self = vy self > 0 && y self >= (starty self - chrSize * one)
40
41newCoinGet :: Int -> Int -> CoinGet
42newCoinGet cx cy =
43        CoinGet { sx = xx, y = yy, vy = -12 * gravity, cnt = 0, starty = yy }
44        where
45                xx = cx * chrSize + 4
46                yy = (cy - 1) * chrSize * one
Note: See TracBrowser for help on using the browser.