Permalink
Browse files

Remove warnings

  • Loading branch information...
1 parent 4f42aa4 commit 9672a7af997b301b8531e62cbca94abec15b0b95 @mokehehe committed Apr 22, 2009
Showing with 178 additions and 123 deletions.
  1. +1 −1 Actor.hs
  2. +2 −2 Actor/AnimBlock.hs
  3. +1 −0 Actor/CoinGet.hs
  4. +2 −2 Actor/Common.hs
  5. +5 −5 Actor/Flower.hs
  6. +3 −2 Actor/Kinoko.hs
  7. +1 −0 Actor/Koura.hs
  8. +3 −1 Actor/Kuribo.hs
  9. +1 −0 Actor/Nokonoko.hs
  10. +2 −0 Actor/ScoreAdd.hs
  11. +2 −2 Actor/Shot.hs
  12. +3 −2 AppUtil.hs
  13. +23 −14 Const.hs
  14. +1 −1 Event.hs
  15. +5 −2 Field.hs
  16. +2 −0 Font.hs
  17. +3 −0 Images.hs
  18. +66 −58 Main.hs
  19. +8 −2 Mixer.hs
  20. +9 −7 Pad.hs
  21. +21 −18 Player.hs
  22. +3 −1 Sounds.hs
  23. +8 −3 Util.hs
  24. +3 −0 tool/listup-imgs.hs
View
@@ -29,7 +29,7 @@ class Actor a where
getHitRect _ = Nothing
onHit :: Player -> a -> (Player, Maybe ActorWrapper, [Event])
- onHit pl ac = (pl, Nothing, [])
+ onHit pl _ = (pl, Nothing, [])
----
View
@@ -20,7 +20,7 @@ data AnimBlock = AnimBlock {
}
instance Actor AnimBlock where
- update fld self
+ update _ self
| not (bDead self) = (self', ev')
| otherwise = (self, [])
@@ -44,4 +44,4 @@ newAnimBlock cx cy c =
cc = case c of
'?' -> '#'
'K' -> '#'
- x -> x
+ o -> o
View
@@ -19,6 +19,7 @@ data CoinGet = CoinGet {
starty :: Int
}
+imgtbl :: [ImageType]
imgtbl = [ImgCoin0, ImgCoin1, ImgCoin2, ImgCoin3]
instance Actor CoinGet where
View
@@ -8,7 +8,7 @@ module Actor.Common (
import Const
import Field
import AppUtil (cellCrd)
-import Player (Player(..), getPlayerVY)
+import Player (Player, getPlayerVY)
-- Common action
@@ -34,4 +34,4 @@ updateActorBase fld (x, y, vx, vy)
-- Stamp by player?
stamp :: Player -> (Int, Int) -> Bool
-stamp pl (x, y) = getPlayerVY pl > 0
+stamp pl (_,_) = getPlayerVY pl > 0
View
@@ -6,7 +6,7 @@ module Actor.Flower (
import Actor (Actor(..))
import Const
-import AppUtil (cellCrd, Rect(..), putimg)
+import AppUtil (Rect(..), putimg)
import Images
import Player (PlayerType(..), getPlayerType, setPlayerType, addScore)
import Event (Event(..))
@@ -20,7 +20,7 @@ data Flower = Flower {
}
instance Actor Flower where
- update fld self = (self, [])
+ update _ self = (self, [])
render self imgres scrx sur =
putimg sur imgres ImgFlower ((x self) `div` one - chrSize `div` 2 - scrx) ((y self) `div` one - 15 - 8)
@@ -32,11 +32,11 @@ instance Actor Flower where
onHit pl self = (addScore pointFlower $ setPlayerType nt pl, Nothing, ev)
where
- nt = case typ of
+ nt = case pltype of
SmallMonao -> SuperMonao
SuperMonao -> FireMonao
- otherwise -> typ
- typ = getPlayerType pl
+ _ -> pltype
+ pltype = getPlayerType pl
ev = [EvScoreAddEfe (x self `div` one) (y self `div` one - chrSize * 2) pointFlower]
View
@@ -12,9 +12,9 @@ import Images
import Player (PlayerType(..), getPlayerType, setPlayerType, addScore)
import Event (Event(..))
+ofsH :: Int
ofsH = 15
-
data Kinoko = Kinoko {
x :: Int,
y :: Int,
@@ -42,7 +42,8 @@ instance Actor Kinoko where
where
nt = case typ of
SmallMonao -> SuperMonao
- otherwise -> typ
+ SuperMonao -> FireMonao
+ _ -> typ
typ = getPlayerType pl
ev = [EvScoreAddEfe (x self `div` one) (y self `div` one - chrSize * 2) pointKinoko]
View
@@ -12,6 +12,7 @@ import Images
import Player (getPlayerX, stampPlayer, setPlayerDamage, addScore)
import Event (Event(..))
+ofsH, vel, reviveCount :: Int
ofsH = 15
vel = 7 * one `div` 2
reviveCount = 6 * frameRate
View
@@ -12,6 +12,7 @@ import Images
import Player (setPlayerDamage, stampPlayer, addScore)
import Event (Event(..))
+ofsH :: Int
ofsH = 15
data Kuribo = Kuribo {
@@ -59,11 +60,12 @@ data StampedKuribo = StampedKuribo {
}
instance Actor StampedKuribo where
- update fld self = (self { ccnt = ccnt self + 1 }, [])
+ update _ self = (self { ccnt = ccnt self + 1 }, [])
render self imgres scrx sur =
putimg sur imgres ImgKuriDead (sx self - scrx) (sy self - 7 - 8)
bDead self = ccnt self >= frameRate `div` 2
+newStampedKuribo :: Int -> Int -> StampedKuribo
newStampedKuribo sx' sy' = StampedKuribo { sx = sx', sy = sy', ccnt = 0 }
View
@@ -13,6 +13,7 @@ import Images
import Player (setPlayerDamage, stampPlayer, addScore)
import Event (Event(..))
+ofsH :: Int
ofsH = 23
data Nokonoko = Nokonoko {
View
@@ -9,6 +9,7 @@ import AppUtil (putimg)
import Const
import Images
+vy :: Int
vy = -1
data ScoreAdd = ScoreAdd {
@@ -31,6 +32,7 @@ instance Actor ScoreAdd where
400 -> Img400
500 -> Img500
1000 -> Img1000
+ _ -> undefined
bDead self = cnt self >= frameRate `div` 2
View
@@ -8,9 +8,9 @@ import Actor (Actor(..))
import AppUtil (cellCrd, putimg)
import Const
import Images
-import Field (Cell, isBlock, fieldRef)
-import Event (Event(..))
+import Field (isBlock, fieldRef)
+velX, velY, size :: Int
velX = 4 * one
velY = 3 * one
size = 8
View
@@ -26,7 +26,6 @@ import Graphics.UI.SDL hiding (flip)
import Graphics.UI.SDL.Utilities
import Graphics.UI.SDL.Mixer
import Data.Maybe (fromJust)
-import Data.Bits ((.|.))
import Data.List (findIndices)
import System.IO.Unsafe (unsafeInterleaveIO)
import Foreign
@@ -36,6 +35,7 @@ import Const
import Images
import Sounds
+imagePath, soundPath, bgmPath :: String
imagePath = "data/img/"
soundPath = "data/snd/"
bgmPath = "data/snd/"
@@ -82,6 +82,7 @@ delayedStream microsec func = unsafeInterleaveIO $ do
-- Process SDL events
-- return True if quit event has come
+procSDLEvent :: IO Bool
procSDLEvent = do
ev <- pollEvent
case ev of
@@ -109,7 +110,7 @@ loadImageResource = mapM load
setNuki sur = setColorKey sur [SrcColorKey] (Pixel 0) >> return () -- Set color key to palet 0
releaseImageResource :: ImageResource -> IO ()
-releaseImageResource = mapM_ (\(t, sur) -> freeSurface sur)
+releaseImageResource = mapM_ (\(_, sur) -> freeSurface sur)
getImageSurface :: ImageResource -> ImageType -> Surface
getImageSurface imgres = fromJust . (`lookup` imgres)
View
@@ -1,35 +1,44 @@
module Const where
-- Window
+wndTitle :: String
wndTitle = "Monao in Haskell"
-screenWidth = 256 :: Int
-screenHeight = 224 :: Int
-wndBpp = 32 :: Int
-frameRate = 60 :: Int
+screenWidth, screenHeight, wndBpp, frameRate :: Int
+screenWidth = 256
+screenHeight = 224
+wndBpp = 32
+
+frameRate = 60
-- Game timer
-timeBase = 22 :: Int
+timeBase :: Int
+timeBase = 22
-- One for fixed point integer
-one = 256 :: Int
+one :: Int
+one = 256
-- Size of charcter
-chrSize = 16 :: Int
+chrSize :: Int
+chrSize = 16
-- Gravity
+gravity :: Int
gravity = one * 2 `div` 5
-- Maximum speed for falling
+maxVy :: Int
maxVy = one * 5
-- Score point
-pointKuribo = 100 :: Int
-pointNokonoko = 100 :: Int
-pointKinoko = 1000 :: Int
-pointFlower = 1000 :: Int
-pointBreakBlock = 50 :: Int
-pointGetCoin = 200 :: Int
-pointKoura = 400 :: Int
+pointKuribo, pointNokonoko, pointKinoko, pointFlower, pointBreakBlock, pointGetCoin, pointKoura :: Int
+pointKuribo = 100
+pointNokonoko = 100
+pointKinoko = 1000
+pointFlower = 1000
+pointBreakBlock = 50
+pointGetCoin = 200
+pointKoura = 400
View
@@ -2,7 +2,7 @@ module Event where
import Images (ImageType)
import Field (Cell)
-import {-# SOURCE #-} Actor (Actor(..), ActorWrapper(..))
+import {-# SOURCE #-} Actor (ActorWrapper(..))
import Sounds
data Event =
View
@@ -16,7 +16,7 @@ module Field (
chr2img
) where
-import Graphics.UI.SDL
+import Graphics.UI.SDL (Surface)
import Const
import Images
@@ -36,6 +36,7 @@ loadField stage = readFile fn >>= return . lines
fn = "data/stage" ++ (show stage) ++ ".map"
+chr2img :: Char -> ImageType
chr2img '@' = ImgBlock1
chr2img 'O' = ImgBlock2
chr2img 'X' = ImgBlock3
@@ -61,9 +62,10 @@ chr2img 'l' = ImgDk10
chr2img '|' = ImgDk11
chr2img 'o' = ImgPole0
chr2img '!' = ImgPole1
-
chr2img 'K' = ImgBlock4
+chr2img _ = undefined
+
isBlock :: Cell -> Bool
isBlock = (`elem` "@OX?#[]l|*K")
@@ -85,6 +87,7 @@ fieldSet fld x y c
| otherwise = fld
+renderField :: Surface -> ImageResource -> Int -> Field -> IO ()
renderField sur imgres scrx fld =
sequence_ $ concatMap lineProc $ zip [0..] fld
where
View
@@ -18,9 +18,11 @@ data Font = Font {
-- Put string
+fontPut :: Font -> Surface -> Int -> Int -> String -> IO ()
fontPut font sur x y str = zipWithM_ (\i c -> fontPutc font sur i y c) [x..] str
-- Put char
+fontPutc :: Font -> Surface -> Int -> Int -> Char -> IO Bool
fontPutc font sur x y c = do
blitSurface (fontSurface font) (Just rc) sur (Just $ Rect (x * fontWidth font) (y * fontHeight font) w h)
where
View
@@ -1,6 +1,9 @@
module Images (ImageType(..), imageTypes, imageFn) where
import Data.Maybe (fromJust)
data ImageType = Img100 | Img1000 | Img200 | Img400 | Img500 | ImgBlock1 | ImgBlock2 | ImgBlock3 | ImgBlock4 | ImgBlock5 | ImgBroken | ImgCloud00 | ImgCloud01 | ImgCloud02 | ImgCloud10 | ImgCloud11 | ImgCloud12 | ImgCoin0 | ImgCoin1 | ImgCoin2 | ImgCoin3 | ImgDk00 | ImgDk01 | ImgDk10 | ImgDk11 | ImgFire0 | ImgFire1 | ImgFire2 | ImgFire3 | ImgFlag | ImgFlower | ImgFMonaoLJump | ImgFMonaoLShot | ImgFMonaoLSit | ImgFMonaoLSlip | ImgFMonaoLStand | ImgFMonaoLWalk1 | ImgFMonaoLWalk2 | ImgFMonaoLWalk3 | ImgFMonaoRJump | ImgFMonaoRShot | ImgFMonaoRSit | ImgFMonaoRSlip | ImgFMonaoRStand | ImgFMonaoRWalk1 | ImgFMonaoRWalk2 | ImgFMonaoRWalk3 | ImgFont | ImgGrass0 | ImgGrass1 | ImgGrass2 | ImgKinoko | ImgKoura | ImgKoura2 | ImgKuri0 | ImgKuri1 | ImgKuriDead | ImgMonaoDead | ImgMonaoLJump | ImgMonaoLSlip | ImgMonaoLStand | ImgMonaoLWalk1 | ImgMonaoLWalk2 | ImgMonaoLWalk3 | ImgMonaoRJump | ImgMonaoRSlip | ImgMonaoRStand | ImgMonaoRWalk1 | ImgMonaoRWalk2 | ImgMonaoRWalk3 | ImgMt02 | ImgMt11 | ImgMt12 | ImgMt13 | ImgMt22 | ImgNokoL0 | ImgNokoL1 | ImgNokoR0 | ImgNokoR1 | ImgPole0 | ImgPole1 | ImgSMonaoLJump | ImgSMonaoLSit | ImgSMonaoLSlip | ImgSMonaoLStand | ImgSMonaoLWalk1 | ImgSMonaoLWalk2 | ImgSMonaoLWalk3 | ImgSMonaoRJump | ImgSMonaoRSit | ImgSMonaoRSlip | ImgSMonaoRStand | ImgSMonaoRWalk1 | ImgSMonaoRWalk2 | ImgSMonaoRWalk3 | ImgTitle deriving (Eq)
+imageTypes :: [ImageType]
imageTypes = [Img100, Img1000, Img200, Img400, Img500, ImgBlock1, ImgBlock2, ImgBlock3, ImgBlock4, ImgBlock5, ImgBroken, ImgCloud00, ImgCloud01, ImgCloud02, ImgCloud10, ImgCloud11, ImgCloud12, ImgCoin0, ImgCoin1, ImgCoin2, ImgCoin3, ImgDk00, ImgDk01, ImgDk10, ImgDk11, ImgFire0, ImgFire1, ImgFire2, ImgFire3, ImgFlag, ImgFlower, ImgFMonaoLJump, ImgFMonaoLShot, ImgFMonaoLSit, ImgFMonaoLSlip, ImgFMonaoLStand, ImgFMonaoLWalk1, ImgFMonaoLWalk2, ImgFMonaoLWalk3, ImgFMonaoRJump, ImgFMonaoRShot, ImgFMonaoRSit, ImgFMonaoRSlip, ImgFMonaoRStand, ImgFMonaoRWalk1, ImgFMonaoRWalk2, ImgFMonaoRWalk3, ImgFont, ImgGrass0, ImgGrass1, ImgGrass2, ImgKinoko, ImgKoura, ImgKoura2, ImgKuri0, ImgKuri1, ImgKuriDead, ImgMonaoDead, ImgMonaoLJump, ImgMonaoLSlip, ImgMonaoLStand, ImgMonaoLWalk1, ImgMonaoLWalk2, ImgMonaoLWalk3, ImgMonaoRJump, ImgMonaoRSlip, ImgMonaoRStand, ImgMonaoRWalk1, ImgMonaoRWalk2, ImgMonaoRWalk3, ImgMt02, ImgMt11, ImgMt12, ImgMt13, ImgMt22, ImgNokoL0, ImgNokoL1, ImgNokoR0, ImgNokoR1, ImgPole0, ImgPole1, ImgSMonaoLJump, ImgSMonaoLSit, ImgSMonaoLSlip, ImgSMonaoLStand, ImgSMonaoLWalk1, ImgSMonaoLWalk2, ImgSMonaoLWalk3, ImgSMonaoRJump, ImgSMonaoRSit, ImgSMonaoRSlip, ImgSMonaoRStand, ImgSMonaoRWalk1, ImgSMonaoRWalk2, ImgSMonaoRWalk3, ImgTitle]
+imageFilenames :: [String]
imageFilenames = ["100.bmp", "1000.bmp", "200.bmp", "400.bmp", "500.bmp", "block1.bmp", "block2.bmp", "block3.bmp", "block4.bmp", "block5.bmp", "broken.bmp", "cloud00.bmp", "cloud01.bmp", "cloud02.bmp", "cloud10.bmp", "cloud11.bmp", "cloud12.bmp", "coin0.bmp", "coin1.bmp", "coin2.bmp", "coin3.bmp", "dk00.bmp", "dk01.bmp", "dk10.bmp", "dk11.bmp", "fire0.bmp", "fire1.bmp", "fire2.bmp", "fire3.bmp", "flag.bmp", "flower.bmp", "fMonaoLJump.bmp", "fMonaoLShot.bmp", "fMonaoLSit.bmp", "fMonaoLSlip.bmp", "fMonaoLStand.bmp", "fMonaoLWalk1.bmp", "fMonaoLWalk2.bmp", "fMonaoLWalk3.bmp", "fMonaoRJump.bmp", "fMonaoRShot.bmp", "fMonaoRSit.bmp", "fMonaoRSlip.bmp", "fMonaoRStand.bmp", "fMonaoRWalk1.bmp", "fMonaoRWalk2.bmp", "fMonaoRWalk3.bmp", "font.bmp", "grass0.bmp", "grass1.bmp", "grass2.bmp", "kinoko.bmp", "koura.bmp", "koura2.bmp", "kuri0.bmp", "kuri1.bmp", "kuriDead.bmp", "MonaoDead.bmp", "MonaoLJump.bmp", "MonaoLSlip.bmp", "MonaoLStand.bmp", "MonaoLWalk1.bmp", "MonaoLWalk2.bmp", "MonaoLWalk3.bmp", "MonaoRJump.bmp", "MonaoRSlip.bmp", "MonaoRStand.bmp", "MonaoRWalk1.bmp", "MonaoRWalk2.bmp", "MonaoRWalk3.bmp", "mt02.bmp", "mt11.bmp", "mt12.bmp", "mt13.bmp", "mt22.bmp", "nokoL0.bmp", "nokoL1.bmp", "nokoR0.bmp", "nokoR1.bmp", "pole0.bmp", "pole1.bmp", "sMonaoLJump.bmp", "sMonaoLSit.bmp", "sMonaoLSlip.bmp", "sMonaoLStand.bmp", "sMonaoLWalk1.bmp", "sMonaoLWalk2.bmp", "sMonaoLWalk3.bmp", "sMonaoRJump.bmp", "sMonaoRSit.bmp", "sMonaoRSlip.bmp", "sMonaoRStand.bmp", "sMonaoRWalk1.bmp", "sMonaoRWalk2.bmp", "sMonaoRWalk3.bmp", "title.bmp"]
+imageFn :: ImageType -> String
imageFn = fromJust . flip lookup (zip imageTypes imageFilenames)
Oops, something went wrong.

0 comments on commit 9672a7a

Please sign in to comment.