fallingblocks 0.1.3 → 0.1.4
raw patch · 3 files changed
+26/−16 lines, 3 filesdep ~SDL
Dependency ranges changed: SDL
Files
- TODO +0/−1
- fallingblocks.cabal +9/−8
- src/GameController.hs +17/−7
TODO view
@@ -1,6 +1,5 @@ * Wall kicks * Levels-* Pause * Options screen (music on/off, maybe different music) * Setup screen (options for speed, etc) that you see before starting a game * Quit current game (back to setup screen)
fallingblocks.cabal view
@@ -1,5 +1,5 @@ Name: fallingblocks-Version: 0.1.3+Version: 0.1.4 Synopsis: A fun falling blocks game. Description: A game where blocks of different shapes fall down the screen. If you either fill an entire line or get four of the same color in a row,@@ -7,18 +7,19 @@ License: GPL License-file: LICENSE Author: Ben Sanders-Copyright: (c) 2009 by Ben Sanders+Copyright: (c) 2009 by Ben Sanders Maintainer: Ben Sanders <bwsanders@gmail.com>-Build-Type: Simple+Build-Type: Simple Cabal-Version: >= 1.2-Category: Game-Data-Files: data/blueblock.bmp, data/cyanblock.bmp, data/greenblock.bmp, data/greyblock.bmp, - data/orangeblock.bmp, data/purpleblock.bmp, data/redblock.bmp, data/yellowblock.bmp,- data/music.mp3, data/Joystix.ttf+Category: Game+Homepage: http://bencode.blogspot.com/2009/03/falling-blocks-tetris-clone-in-haskell.html+Data-Files: data/blueblock.bmp, data/cyanblock.bmp, data/greenblock.bmp, data/greyblock.bmp, + data/orangeblock.bmp, data/purpleblock.bmp, data/redblock.bmp, data/yellowblock.bmp,+ data/music.mp3, data/Joystix.ttf Executable fallingblocks Main-is: main.hs other-modules: Board, BoardTest, GameController, Game, GameState, GameTest, GraphicsInfo, Helpers, Shape, ShapeTest, SplashController hs-source-dirs: src- Build-Depends: base, SDL, haskell98, containers, SDL-ttf, SDL-mixer >= 0.5.5+ Build-Depends: base, SDL == 0.5.4, haskell98, containers, SDL-ttf, SDL-mixer >= 0.5.5
src/GameController.hs view
@@ -14,16 +14,20 @@ handleGameEvents :: [Event] -> GameState -> GameState handleGameEvents [] gs = gs handleGameEvents ((KeyUp (Keysym SDLK_q _ _)):es) gs = gs { keepGoing = False}+handleGameEvents ((KeyUp (Keysym SDLK_p _ _)):es) gs + | paused gs = gs { paused = False }+ | otherwise = gs { paused = True } handleGameEvents (e:es) gs = handleGameEvents es (gs' themove) where gs' Nothing = gs gs' (Just m) = gs { game = move (game gs) m }- themove = - case e of - (KeyDown (Keysym SDLK_LEFT _ _)) -> Just MoveLeft- (KeyDown (Keysym SDLK_RIGHT _ _)) -> Just MoveRight- (KeyDown (Keysym SDLK_UP _ _)) -> Just Rotate- (KeyDown (Keysym SDLK_DOWN _ _)) -> Just MoveDown- otherwise -> Nothing+ themove | paused gs = Nothing+ | otherwise = + case e of + (KeyDown (Keysym SDLK_LEFT _ _)) -> Just MoveLeft+ (KeyDown (Keysym SDLK_RIGHT _ _)) -> Just MoveRight+ (KeyDown (Keysym SDLK_UP _ _)) -> Just Rotate+ (KeyDown (Keysym SDLK_DOWN _ _)) -> Just MoveDown+ otherwise -> Nothing -- Renders the current game state@@ -62,6 +66,12 @@ drawBlockRect (bkgdblock gri) s drawNextBlock (nextBlock g) g gri++ if paused gs && (stillRunning $ game gs)+ then do + gameOver <- renderTextSolid (titlefont gri) "Paused" (Color 255 0 0)+ blitSurface gameOver Nothing s (Just (Rect 50 200 200 0))+ else return False if not . stillRunning $ game gs then do