Work on bouncing debris
This commit is contained in:
+12
-51
@@ -1,4 +1,11 @@
|
||||
module Dodge.Block.Debris where
|
||||
module Dodge.Block.Debris (
|
||||
cubeShape,
|
||||
dirtColor,
|
||||
makeDoorDebris,
|
||||
makeBlockDebris,
|
||||
makeDebris,
|
||||
makeDebrisDirected,
|
||||
) where
|
||||
|
||||
import Color
|
||||
import Data.Foldable
|
||||
@@ -36,57 +43,11 @@ makeBlockDebris bl w = foldl' (flip $ makeDebris mt col) w ps
|
||||
wl <- w ^? cWorld . lWorld . walls . ix wlid
|
||||
return (_wlMaterial wl, _wlColor wl)
|
||||
|
||||
makeDebrisToHeight :: Float -> Material -> Color -> Point2 -> World -> World
|
||||
makeDebrisToHeight = makeDebrisDirectedHeight 1 2 (2 * pi) 0
|
||||
|
||||
makeDebris :: Material -> Color -> Point2 -> World -> World
|
||||
makeDebris = makeDebrisDirected 1 2 (2 * pi) 0
|
||||
makeDebris = makeDebrisDirected (2 * pi) 0
|
||||
|
||||
makeDebrisDirectedHeight ::
|
||||
Float ->
|
||||
Float ->
|
||||
Float ->
|
||||
Float ->
|
||||
Float ->
|
||||
Material ->
|
||||
Color ->
|
||||
Point2 ->
|
||||
World ->
|
||||
World
|
||||
makeDebrisDirectedHeight mindist maxdist arcrad dir maxh bm col p w =
|
||||
w
|
||||
& flip (foldl' (flip $ plNew (cWorld . lWorld . props) prID)) thedebris
|
||||
& randGen .~ newg
|
||||
& soundOriginsIDsAt [MaterialSound bm i | i <- [0, 1, 2]] (destroyMatS bm) p
|
||||
where
|
||||
dsize = debrisSize bm
|
||||
(thedebris, newg) = mapM f [10, 10 + dsize .. maxh + 5] & runState $ _randGen w
|
||||
f h = do
|
||||
v <- rotateV (dir - arcrad / 2) <$> randInArcStrip mindist maxdist arcrad
|
||||
q <- Q.vToQuat (V3 0 0 1) <$> randOnUnitSphere
|
||||
spinspeed <- randomR (-0.2, -0.1) & state
|
||||
basedebris <- baseDebris bm
|
||||
return $
|
||||
basedebris
|
||||
& prColor .~ col
|
||||
& prPos .~ p
|
||||
& prVel .~ v
|
||||
& prQuatSpin .~ Q.axisAngle (vNormal v `v2z` 0) spinspeed
|
||||
& prQuat .~ q
|
||||
& prVelZ .~ 0
|
||||
& prPosZ .~ h
|
||||
|
||||
makeDebrisDirected ::
|
||||
Float ->
|
||||
Float ->
|
||||
Float ->
|
||||
Float ->
|
||||
Material ->
|
||||
Color ->
|
||||
Point2 ->
|
||||
World ->
|
||||
World
|
||||
makeDebrisDirected mindist maxdist arcrad dir bm col p w =
|
||||
makeDebrisDirected :: Float -> Float -> Material -> Color -> Point2 -> World -> World
|
||||
makeDebrisDirected arcrad dir bm col p w =
|
||||
w
|
||||
& flip (foldl' (flip $ plNew (cWorld . lWorld . props) prID)) thedebris
|
||||
& randGen .~ newg
|
||||
@@ -94,7 +55,7 @@ makeDebrisDirected mindist maxdist arcrad dir bm col p w =
|
||||
where
|
||||
(thedebris, newg) = mapM f [35, 55 .. 95] & runState $ _randGen w
|
||||
f h = do
|
||||
v <- rotateV (dir - arcrad / 2) <$> randInArcStrip mindist maxdist arcrad
|
||||
v <- rotateV (dir - arcrad / 2) <$> randInArcStrip 1 2 arcrad
|
||||
q <- Q.vToQuat (V3 0 0 1) <$> randOnUnitSphere
|
||||
spinspeed <- randomR (-0.2, -0.1) & state
|
||||
basedebris <- baseDebris bm
|
||||
|
||||
Reference in New Issue
Block a user