From c36654520d6250bd39efad7a282529cdf67f7782 Mon Sep 17 00:00:00 2001 From: justin Date: Sat, 28 Aug 2021 16:22:21 +0100 Subject: [PATCH] Add missing dependencies, fix arc rendering --- shader/twoD/arc.frag | 4 ++- src/Dodge/Item/Weapon.hs | 2 ++ src/Dodge/Item/Weapon/AmmoParams.hs | 48 +++++++++++++++++++++++++++ src/Dodge/Room/Listed.hs | 7 ++++ src/Dodge/Room/Start.hs | 2 +- src/Dodge/WorldEvent/Flash.hs | 1 - src/Dodge/WorldEvent/Shockwave.hs | 2 +- src/Dodge/WorldEvent/SpawnParticle.hs | 19 ++++++----- src/Picture.hs | 7 ++-- 9 files changed, 77 insertions(+), 15 deletions(-) create mode 100644 src/Dodge/Item/Weapon/AmmoParams.hs create mode 100644 src/Dodge/Room/Listed.hs diff --git a/shader/twoD/arc.frag b/shader/twoD/arc.frag index dca6c1e1e..3119d572c 100644 --- a/shader/twoD/arc.frag +++ b/shader/twoD/arc.frag @@ -6,7 +6,9 @@ out vec4 fColor; void main() { - float d = dot(vec2(vparams.xy),vec2(vparams.xy)); + float d = (dot(vec2(vparams.xy),vec2(vparams.xy))); if ( d > 1 || d < vparams.z ) {discard;} + //if ( d > 1 ) {discard;} fColor = vColor; + //fColor = (10,0,0,10); } diff --git a/src/Dodge/Item/Weapon.hs b/src/Dodge/Item/Weapon.hs index f3308f40d..5d53fc923 100644 --- a/src/Dodge/Item/Weapon.hs +++ b/src/Dodge/Item/Weapon.hs @@ -141,6 +141,7 @@ teslaGun = defaultGun , _itUseModifiers = [ ammoCheckI , useTimeCheckI + , withTempLight 1 100 (V3 0 0 1) , withSoundForI 25 1 , useAmmo 1 ] @@ -175,6 +176,7 @@ lasGun = defaultAutoGun , _itUseModifiers = [ ammoCheckI , useTimeCheckI + , withTempLight 1 100 (V3 1 1 0) , withSoundForI 24 1 , useAmmo 1 ] diff --git a/src/Dodge/Item/Weapon/AmmoParams.hs b/src/Dodge/Item/Weapon/AmmoParams.hs new file mode 100644 index 000000000..ef8543e1a --- /dev/null +++ b/src/Dodge/Item/Weapon/AmmoParams.hs @@ -0,0 +1,48 @@ +module Dodge.Item.Weapon.AmmoParams + where +import Dodge.Data +import Dodge.Particle.Bullet.Spawn +import Geometry + +import Control.Lens + +useAmmoParams :: Item -> Creature -> World -> World +useAmmoParams it = withVelWthHiteff (_amBulVel b) (_amBulWth b) (_amBulEff b) + where + b = _wpAmmo it + +useAmmoParamsVelMod :: Float -> Item -> Creature -> World -> World +useAmmoParamsVelMod vfact it = withDelayedVelWthHiteff vfact (_amBulVel b) (_amBulWth b) (_amBulEff b) + where + b = _wpAmmo it + +{- | Creates a bullet with a given velocity, width, and 'HitEffect' -} +withVelWthHiteff + :: Point2 -- ^ Velocity, x direction is forward with respect to the creature + -> Float -- ^ Bullet width + -> HitEffect -- ^ Bullet effect when hitting creature, wall etc + -> Creature -- ^ Creature id + -> World + -> World +withVelWthHiteff vel width hiteff cr = over particles (newbul : ) + where + cid = _crID cr + newbul = aGenBulAt (Just cid) pos (rotateV dir vel) hiteff width + dir = _crDir cr + pos = _crPos cr +.+ _crRad cr *.* unitVectorAtAngle (_crDir cr) + +{- | Creates a bullet with a given velocity, width, and 'HitEffect' -} +withDelayedVelWthHiteff + :: Float -- ^ Velocity factor for first step + -> Point2 -- ^ Velocity, x direction is forward with respect to the creature + -> Float -- ^ Bullet width + -> HitEffect -- ^ Bullet effect when hitting creature, wall etc + -> Creature -- ^ Creature id + -> World + -> World +withDelayedVelWthHiteff vfact vel width hiteff cr = over particles (newbul : ) + where + cid = _crID cr + newbul = aDelayedBulAt vfact (Just cid) pos (rotateV dir vel) hiteff width + dir = _crDir cr + pos = _crPos cr +.+ _crRad cr *.* unitVectorAtAngle (_crDir cr) diff --git a/src/Dodge/Room/Listed.hs b/src/Dodge/Room/Listed.hs new file mode 100644 index 000000000..81baa7a93 --- /dev/null +++ b/src/Dodge/Room/Listed.hs @@ -0,0 +1,7 @@ +module Dodge.Room.Listed + ( roomList + ) where +import Dodge.Room.Data + +roomList :: [Room] +roomList = [] diff --git a/src/Dodge/Room/Start.hs b/src/Dodge/Room/Start.hs index 70a65ad91..17b2dd15f 100644 --- a/src/Dodge/Room/Start.hs +++ b/src/Dodge/Room/Start.hs @@ -27,7 +27,7 @@ startRoom = do highPipe 80 (V2 0 (h/3)) (V2 w (h/2)) ++ highPipe 40 (V2 0 (h/2)) (V2 w (h/3)) ++ highPipe 60 (V2 (w/3) 0 ) (V2 (w/3) h ) - theLamp = sPS (V2 (w/2) (h/2)) 0 $ putColorLamp (V3 0.75 0.25 0.25) + theLamp = sPS (V2 (w/2) (h/2)) 0 $ putColorLamp (V3 0.75 0.75 0.75) treeFromPost [Left rezBox, Left door] . Right <$> randomiseOutLinks (shiftRoomBy (V2 (-20) (-20),0) $ roomRectAutoLinks w h & rmPS .~ [fground,theLamp]) diff --git a/src/Dodge/WorldEvent/Flash.hs b/src/Dodge/WorldEvent/Flash.hs index 2f5cb76a4..69cf5be96 100644 --- a/src/Dodge/WorldEvent/Flash.hs +++ b/src/Dodge/WorldEvent/Flash.hs @@ -86,7 +86,6 @@ flashFlareAt col alphax (V2 x y) = Particle explosionFlashAt :: Point2 -> World -> World explosionFlashAt p = over tempLightSources ((:) $ tLightFade 20 150 intensityFunc p) - . glareAt 20 10 5 (withAlpha 0.3 white) 75 150 p where intensityFunc x | x < 10 = 1 / (10 - fromIntegral x) diff --git a/src/Dodge/WorldEvent/Shockwave.hs b/src/Dodge/WorldEvent/Shockwave.hs index cff3fa437..5c572a23e 100644 --- a/src/Dodge/WorldEvent/Shockwave.hs +++ b/src/Dodge/WorldEvent/Shockwave.hs @@ -50,7 +50,7 @@ Shockwave picture. drawShockwave :: Particle -> Picture drawShockwave pt = pic where - pic = setDepth 20 . uncurryV translate p + pic = setDepth 20 . setLayer 1 . uncurryV translate p $ color (_btColor' pt) $ thickCircle rad thickness p = _btPos' pt r = _btRad' pt diff --git a/src/Dodge/WorldEvent/SpawnParticle.hs b/src/Dodge/WorldEvent/SpawnParticle.hs index f29caaa6c..8b57189b3 100644 --- a/src/Dodge/WorldEvent/SpawnParticle.hs +++ b/src/Dodge/WorldEvent/SpawnParticle.hs @@ -122,7 +122,7 @@ moveFlame rotd w pt closeCrs cr = dist ep (_crPos cr) < _crRad cr + 10 - min 9 (max 0 (fromIntegral time - 80)) + 5 * angleCoeff (angleVV (ep -.- _crPos cr) rotd) - angleCoeff x = abs $ 1 - abs ( (x * 2 - pi) / pi ) + angleCoeff x' = abs $ 1 - abs ( (x' * 2 - pi) / pi ) hiteff = _btHitEffect' pt pt rfl wl p = Just $ pt { _btTimer' = time -1 @@ -167,10 +167,13 @@ drawFlameletZ -> Particle -> Picture drawFlameletZ rot pt = pictures - [ setLayer 5 pic - , setLayer 4 pi2 - , setLayer 3 piu - , setLayer 1 glow + --[ setLayer 5 pic + --, setLayer 4 pi2 + --, setLayer 3 piu + [ setLayer 1 pic + , setLayer 1 pi2 + , setLayer 1 piu + --, setLayer 1 glow ] where z = _ptZ pt @@ -184,13 +187,13 @@ drawFlameletZ rot pt = pictures $ circleSolidCol (withAlpha 0 red) (withAlpha 0.05 red) 30 piu = setDepth (z + 20) . uncurryV translate ep - . color (dark red) + . color (brightX 2 2 $ dark red) . rotate (negate (rot - 0.1 * fromIntegral time)) . scale s1 s1 $ polygon (rectNSWE siz2 (-siz2) (-siz2) siz2) pi2 = setDepth (z + 20) . uncurryV translate ep - . color (mixColors (fromIntegral (max 0 (time-2))) (10-fromIntegral time) + . color (brightX 2 2 $ mixColors (fromIntegral (max 0 (time-2))) (10-fromIntegral time) orange (dark red) ) . rotate (negate (rot + 0.2 * fromIntegral time)) @@ -198,7 +201,7 @@ drawFlameletZ rot pt = pictures $ polygon (rectNSWE siz2 (-siz2) (-siz2) siz2) pic = setDepth (z + 20) . uncurryV translate ep - . color (mixColors (fromIntegral (max 0 (time-2))) (10-fromIntegral time) + . color (brightX 2 2 $ mixColors (fromIntegral (max 0 (time-2))) (10-fromIntegral time) white (dark red) ) . rotate (negate ( 0.1 * fromIntegral time + rot)) diff --git a/src/Picture.hs b/src/Picture.hs index cf320450a..4672c4c07 100644 --- a/src/Picture.hs +++ b/src/Picture.hs @@ -301,9 +301,9 @@ arc startA endA rad = thickArc startA endA rad 1 thickArc :: Float -> Float -> Float -> Float -> Picture {-# INLINE thickArc #-} thickArc startA endA rad wdth - | endA - startA > pi = pictures - [ thickArc (startA + pi) endA rad wdth - , thickArcHelp startA (startA + pi) r w + | endA - startA > (pi/ 2) = pictures + [ thickArc (startA + pi/2) endA rad wdth + , thickArcHelp startA (startA + pi/2) r w ] | otherwise = thickArcHelp startA endA r w where @@ -323,6 +323,7 @@ thickArcHelp startA endA rad wdth = map f where (V2 xa ya) = rotateV startA (V2 rad 0) (V2 xb yb) = rotateV (0.5 * (startA + endA)) (V2 (rad * sqrt 2) 0) + --(V2 xb yb) = rotateV (0.5 * (startA + endA)) (V2 (rad * 2) 0) (V2 xc yc) = rotateV endA (V2 rad 0) f (pos,col,V3 a b c) = Verx pos col [a,b,c] 0 arcNum