| 21 | | -- AnimBlock |
| 22 | | -- ブロックを叩いたときのバウンド演出 |
| 23 | | |
| 24 | | data AnimBlock = AnimBlock { |
| 25 | | startcy :: Int, |
| 26 | | x :: Int, |
| 27 | | y :: Int, |
| 28 | | vy :: Int, |
| 29 | | chr :: Cell |
| 30 | | } |
| 31 | | |
| 32 | | instance Actor AnimBlock where |
| 33 | | update self |
| 34 | | | not (bDead self) = (self', ev') |
| 35 | | | otherwise = (self, []) |
| 36 | | |
| 37 | | where |
| 38 | | vy' = vy self + gravity |
| 39 | | y' = y self + vy' |
| 40 | | self' = self { vy = vy', y = y' } |
| 41 | | ev' = if (bDead self') |
| 42 | | then [EvSetField (cellCrd $ x self) (startcy self) $ chr self] |
| 43 | | else [] |
| 44 | | |
| 45 | | render self imgres scrx sur = do |
| 46 | | blitSurface (getImageSurface imgres $ chr2img $ chr self) Nothing sur (pt ((x self) `div` one - scrx) ((y self) `div` one - 8)) |
| 47 | | return () |
| 48 | | |
| 49 | | bDead self = vy self > 0 && y self >= startcy self * chrSize * one |
| 50 | | |
| 51 | | newAnimBlock :: Int -> Int -> Cell -> AnimBlock |
| 52 | | newAnimBlock cx cy c = |
| 53 | | AnimBlock { startcy = cy, x = cx * chrSize * one, y = cy * chrSize * one, vy = -3 * one, chr = cc } |
| 54 | | where |
| 55 | | cc = case c of |
| 56 | | '?' -> '#' |
| 57 | | x -> x |
| 58 | | |
| 59 | | |
| 60 | | -- ============================================================================ |