dow 0.1.0 → 0.2.0
raw patch · 7 files changed
+33/−16 lines, 7 files
Files
- CHANGES +6/−0
- README +2/−2
- dow.cabal +2/−1
- src/Game.hs +14/−10
- src/Level.hs +6/−0
- src/Main.hs +3/−2
- src/Sprites.hs +0/−1
+ CHANGES view
@@ -0,0 +1,6 @@+0.2.0 - 100424+* sanitised enemy movement+* added enter as an alternative fire key++0.1.0 - 100211+* first public version
README view
@@ -2,11 +2,11 @@ =============== Dungeons of Wor is a homage to the classic arcade game, Wizard of Wor.-It uses the artwork and levels from the Astrocade version, but the+It uses the artwork and levels from the arcade version, but the gameplay mechanics differ from the original in several ways. Controls: - player one and menu - arrows + right control+ player one and menu - arrows + right control/enter player two - WASD + left control quit at any time - escape
dow.cabal view
@@ -1,5 +1,5 @@ Name: dow-Version: 0.1.0+Version: 0.2.0 Cabal-Version: >= 1.2 Synopsis: Dungeons of Wor Category: game, reactivity, FRP@@ -35,6 +35,7 @@ Data-Files: README+ CHANGES data/charset.txt data/levels.txt data/sprites.txt
src/Game.hs view
@@ -11,6 +11,7 @@ import FRP.Elerea.Experimental.Simple import Actor+import GraphUtils import HighScore import Level import Sprites@@ -193,11 +194,13 @@ hitBy e = isDead e && abs (ex-px) < fieldMid && abs (ey-py) < fieldMid where V ex ey = position e -newDir lev rnd act = if not (canMove lev act) then Just pickedLegalDir- else if rnd `mod` 1000 < 992 then Nothing- else Just (toEnum (rnd `mod` 4))+newDir lev rnd act = if canMove lev act && (isHalfway || rnd `mod` 1000 < 500)+ then Nothing+ else Just pickedDir where legal = legalMovesAt lev (fieldPos (position act))- pickedLegalDir = legal !! (rnd `mod` length legal)+ dirPool = if length legal < 2 then legal else legal \\ [turnBack (facing act)]+ pickedDir = dirPool !! (rnd `mod` length dirPool)+ isHalfway = halfway (fieldSub (position act)) (facing act) movePlayer level mov shoot enemies plr = case action plr of Entering dir False -> let startMoving = isJust mov@@ -236,9 +239,9 @@ move :: Level -> Direction -> Actor -> Actor move lev dir ent = mv ent $ fmap snd . find fst $- [(halfway dir || atFieldMid && dirIsLegal, dir)- ,(not atFieldMid && dirIsLegal, dir')- ,(halfway entDir || legalMove entDir, entDir)+ [(isHalfway dir || isAtMid && dirIsLegal, dir)+ ,(not isAtMid && dirIsLegal, dir')+ ,(isHalfway entDir || legalMove entDir, entDir) ] where mv e Nothing = e mv e (Just d) = e { position = position e + fromIntegral (speed e) * dirVec d@@ -248,9 +251,10 @@ dirIsLegal = legalMove dir legalMove d = d `elem` legalMovesAt lev (fieldPos (position ent)) - (sx,sy) = fieldSub (position ent)- atFieldMid = 0 == if isVertical dir then sx else sy- halfway d = 0 /= if isVertical d then sy else sx+ isAtMid = atFieldMid sub dir+ isHalfway = halfway sub++ sub@(sx,sy) = fieldSub (position ent) entDir = facing ent dir' = case entDir of
src/Level.hs view
@@ -30,6 +30,12 @@ fieldSub (V x y) = (mkSub x, mkSub y) where mkSub c = let s = c `mod` fieldSize in if s >= fieldMid then s-fieldSize else s +atFieldMid :: (Int,Int) -> Direction -> Bool+atFieldMid (sx,sy) dir = 0 == if isVertical dir then sx else sy++halfway :: (Int,Int) -> Direction -> Bool+halfway (sx,sy) dir = 0 /= if isVertical dir then sy else sx+ dirFromInt :: Int -> Direction dirFromInt = toEnum . (`mod` 4)
src/Main.hs view
@@ -84,11 +84,12 @@ ks1 <- getKey DOWN kw1 <- getKey LEFT ke1 <- getKey RIGHT- kt1 <- getKey RCTRL+ kt1a <- getKey RCTRL+ kt1b <- getKey ENTER kn2 <- getKey 'W' ks2 <- getKey 'S' kw2 <- getKey 'A' ke2 <- getKey 'D' kt2 <- getKey LCTRL- sink ((pr kn1, pr ks1, pr kw1, pr ke1, pr kt1),+ sink ((pr kn1, pr ks1, pr kw1, pr ke1, pr kt1a || pr kt1b), (pr kn2, pr ks2, pr kw2, pr ke2, pr kt2))
src/Sprites.hs view
@@ -1,7 +1,6 @@ module Sprites ( SpriteStore , parseSprites- , explodeMatrix ) where import Control.Applicative