|
Revision 20775, 1.0 kB
(checked in by mokehehe, 5 years ago)
|
|
エフェクトオブジェクト(コイン取得、スコア加算、ブロック破壊)追加
|
| Line | |
|---|
| 1 | -- コインを取ったときの演出コイン |
|---|
| 2 | |
|---|
| 3 | module Actor.CoinGet ( |
|---|
| 4 | newCoinGet |
|---|
| 5 | ) where |
|---|
| 6 | |
|---|
| 7 | import Multimedia.SDL hiding (Event) |
|---|
| 8 | |
|---|
| 9 | import Actor (Actor(..)) |
|---|
| 10 | import AppUtil |
|---|
| 11 | import Const |
|---|
| 12 | import Images |
|---|
| 13 | import Event |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | data CoinGet = CoinGet { |
|---|
| 17 | sx :: Int, |
|---|
| 18 | y :: Int, |
|---|
| 19 | vy :: Int, |
|---|
| 20 | cnt :: Int, |
|---|
| 21 | starty :: Int |
|---|
| 22 | } |
|---|
| 23 | |
|---|
| 24 | imgtbl = [ImgCoin0, ImgCoin1, ImgCoin2, ImgCoin3] |
|---|
| 25 | |
|---|
| 26 | instance 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 | |
|---|
| 41 | newCoinGet :: Int -> Int -> CoinGet |
|---|
| 42 | newCoinGet 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 |
|---|