diff --git a/src/Dodge/Data.hs b/src/Dodge/Data.hs index 6b1bf50fa..4044bf911 100644 --- a/src/Dodge/Data.hs +++ b/src/Dodge/Data.hs @@ -471,7 +471,8 @@ data Particle' = , _btTimer' :: Int } -type HitEffect = Point2 -> Point2 -> (Point2, (Either3 Creature Wall ForceField)) -> World -> World +type HitEffect = Particle' -> [( Point2, [(Point2, (Either3 Creature Wall ForceField))] )] + -> World -> World type HitEffect' = Particle' -> (Point2, (Either3 Creature Wall ForceField)) -> World -> World data Particle = diff --git a/src/Dodge/LevelGen.hs b/src/Dodge/LevelGen.hs index 87d8a59a8..85b887341 100644 --- a/src/Dodge/LevelGen.hs +++ b/src/Dodge/LevelGen.hs @@ -120,7 +120,7 @@ instance Shiftable PlacementSpot where rotateS r' (PS p r x) = PS (rotateV r' p) (r + r') x putWindowBlock :: Point2 -> Point2 -> World -> World -putWindowBlock a b w = removePathsCrossing a b $ foldr makeBlockAt w $ zip ps ns +putWindowBlock a b w = removePathsCrossing a b $ foldr (makeBlockAt bSide) w $ zip ps ns where d = dist a b rot = argV (b -.- a) numPoints' = floor (d / 20) @@ -128,17 +128,17 @@ putWindowBlock a b w = removePathsCrossing a b $ foldr makeBlockAt w $ zip ps ns ns = take (numPoints+1) [0..] ps = map (\i -> a +.+ i/ (fromIntegral numPoints) *.* (b -.- a)) $ map fromIntegral ns - k = newKey $ _walls w - ksAtN i = [k+i*4,k+i*4 + 1 ,k+i*4 +2, k+i*4+3] bSide = d / (fromIntegral numPoints) - ds = [(-bSide,-10),(-bSide,10),(bSide,10),(bSide,-10)] - polyAtP p = map ((+.+) p . rotateV rot) ds - hp = 1 - degradeHP = [5,5] - winCol = withAlpha 0.5 cyan - makeBlockAt :: (Point2,Int) -> World -> World - makeBlockAt (p,i) w = - let (k0:k1:k2:k3:_) = ksAtN i + makeBlockAt :: Float -> (Point2,Int) -> World -> World + makeBlockAt bSide (p,i) w = + let k = newKey $ _walls w + ds = [(-bSide,-9),(-bSide,9),(bSide,9),(bSide,-9)] + polyAtP p = map ((+.+) p . rotateV rot) ds + hp = 1 + degradeHP = [5,5] + winCol = withAlpha 0.5 cyan + ksAtN i = [k+i*4,k+i*4 + 1 ,k+i*4 +2, k+i*4+3] + (k0:k1:k2:k3:_) = ksAtN i (bl:tl:tr:br:_) = polyAtP p shadows | i == 0 = ksAtN 1 | i == numPoints - 1 = ksAtN $ numPoints - 2 diff --git a/src/Dodge/WorldActions/ThingsHit.hs b/src/Dodge/WorldActions/ThingsHit.hs index 44bdea8ae..3a510f140 100644 --- a/src/Dodge/WorldActions/ThingsHit.hs +++ b/src/Dodge/WorldActions/ThingsHit.hs @@ -42,9 +42,6 @@ thingsHit sp ep w where hitCrs = IM.elems $ IM.filter (\cr -> circOnLine sp ep (_crPos cr) (_crRad cr)) $ _creatures w - -- $ creaturesAlongLine sp ep w - -- creaturesAlongLine doesn't always - -- hit crs crPs = map (\cr -> ssaTriPoint ep (_crPos cr) sp (_crRad cr)) hitCrs crs = zip crPs (map E3x1 hitCrs) @@ -58,3 +55,6 @@ thingsHit sp ep w hitFFs = mapMaybe (collidePointFF sp ep (_randGen w)) (IM.elems $ _forceFields w) ffs = map (\(p,(_,i)) -> (p, E3x3 $ _forceFields w IM.! i)) hitFFs +thingsHitOnPath :: [Point2] -> World -> [ [ ( Point2, (Either3 Creature Wall ForceField) ) ] ] +thingsHitOnPath [] _ = error "tried to find thingsHitOnPath containing no points" +thingsHitOnPath ps w = map (flip (uncurry thingsHit) w) . zip ps $ tail ps