edge 0.8 → 0.8.2
raw patch · 30 files changed
+197/−129 lines, 30 files
Files
- AfterEffect/MineExplosion.hs +3/−2
- AfterEffect/SimpleExplosion.hs +5/−4
- Animation.hs +2/−1
- BigAsteroid.hs +3/−2
- Common.hs +10/−0
- Display.hs +23/−10
- Lance.hs +6/−5
- Moving.hs +7/−6
- Projectile/Blade.hs +5/−4
- Projectile/BulletMI.hs +5/−4
- Projectile/BulletMII.hs +5/−4
- Projectile/BulletMkI.hs +5/−4
- Projectile/BulletSI.hs +5/−4
- Projectile/BulletSII.hs +5/−4
- Projectile/Cannon.hs +5/−4
- Projectile/Mine.hs +2/−1
- Projectile/Nuke.hs +5/−4
- Projectile/Pellet.hs +4/−3
- Step.hs +31/−16
- Unit/Simple/Turret.hs +7/−6
- Unit/Smart/ATank.hs +7/−6
- Unit/Smart/Death.hs +7/−6
- Unit/Smart/Ninja.hs +7/−6
- Unit/Smart/Saucer.hs +7/−6
- Unit/Smart/Sniper.hs +7/−6
- Unit/Smart/Tank.hs +7/−6
- Universe.hs +3/−0
- Updating.hs +4/−3
- edge.cabal +3/−2
- edge.hs +2/−0
AfterEffect/MineExplosion.hs view
@@ -10,14 +10,15 @@ import Data.Maybe import ResourceTracker import GHC.Float+import Common data MineExplosion = MineExplosion { center :: WrapPoint- , timeRemaining :: Double+ , timeRemaining :: Time , soundSource :: Maybe Source , wrapMap :: WrapMap , resourceTracker :: ResourceTracker- , animClock :: Double+ , animClock :: Time } new :: ResourceTracker -> WrapMap -> WrapPoint -> MineExplosion
AfterEffect/SimpleExplosion.hs view
@@ -10,18 +10,19 @@ import Data.Maybe import ResourceTracker import GHC.Float+import Common data SimpleExplosion = SimpleExplosion { center :: WrapPoint- , timeRemaining :: Double+ , timeRemaining :: Time , soundSource :: Maybe Source , wrapMap :: WrapMap , resourceTracker :: ResourceTracker- , animClock :: Double- , velocity :: (Double, Double)+ , animClock :: Time+ , velocity :: Velocity } -new :: ResourceTracker -> WrapMap -> WrapPoint -> (Double, Double) -> SimpleExplosion+new :: ResourceTracker -> WrapMap -> WrapPoint -> Velocity -> SimpleExplosion new rt wmap center' velocity' = SimpleExplosion { center = center' , timeRemaining = 3.0
Animation.hs view
@@ -4,9 +4,10 @@ import Moving import Data.WrapAround import Sound.ALUT+import Common class Animation a where- image :: a -> Double -> Picture+ image :: a -> Time -> Picture class Audible a where processAudio :: a -> WrapPoint -> IO a
BigAsteroid.hs view
@@ -10,6 +10,7 @@ import GHC.Float import Combat import Data.Maybe+import Common asteroidRadius = 30.0 @@ -18,12 +19,12 @@ data BigAsteroid = BigAsteroid { location :: WrapPoint , idealTargetLocation :: Maybe WrapPoint- , velocity :: (Double, Double)+ , velocity :: Velocity , wrapMap :: WrapMap , animDefault0 :: Picture } -new :: ResourceTracker -> WrapMap -> WrapPoint -> (Double, Double) -> BigAsteroid+new :: ResourceTracker -> WrapMap -> WrapPoint -> Velocity -> BigAsteroid new rt wmap location velocity = let pic = fromMaybe (Scale 0.20 0.20
+ Common.hs view
@@ -0,0 +1,10 @@+module Common where++-- seconds+type Time = Double++-- Radians+type Angle = Double++-- mysterious unit but usually same as pixels+type Velocity = (Double, Double)
Display.hs view
@@ -16,6 +16,7 @@ import Unit import Item import ResourceTracker+import Trigonometry data Displayable = forall a. (Locatable a, Animation a) => Displayable a @@ -46,6 +47,8 @@ let (x, y) = vectorRelation wmap wp viewCenterWp in let pic = image displayable undefined in [ Translate (double2Float x) (double2Float y) pic ] in+ let lanceLives x = if isNothing (lance arena')+ then Blank else x in let deflectorBar' = Translate 65.0 370.0 (case lance arena' of Just x -> deflectorBar (deflectorCharge x)@@ -85,19 +88,29 @@ integrityAssessment) in let sP = Translate 450.0 330.0 (sensorPanel arena' (100.0, 100.0)) in+ let levelMessage = case levelMessageTimer u of+ Nothing -> Blank+ Just mt -> if mt `doubleRem` 0.5 < 0.25+ then Blank+ else Translate (-200.0) 150.0+ (Text+ ("level "+ ++ show (level u + 1))) in return $ Pictures $ displayables ++ [ pship'- , deflectorText'- , deflectorBar'- , levelText- , livesText- , sP+ , lanceLives $ deflectorText'+ , lanceLives $ deflectorBar'+ , lanceLives $ levelText+ , lanceLives $ livesText+ , lanceLives $ sP , godText- , integrityText- , integrityTextL2- , Translate (-400.0) 340.0 (inventoryDisplay- (lance arena')- (resourceTracker u))+ , lanceLives $ integrityText+ , lanceLives $ integrityTextL2+ , lanceLives $ Translate (-400.0) 340.0+ (inventoryDisplay+ (lance arena')+ (resourceTracker u))+ , lanceLives $ levelMessage ] inventoryDisplay :: Maybe Lance -> ResourceTracker -> Picture
Lance.hs view
@@ -36,6 +36,7 @@ import qualified AfterEffect.SimpleExplosion as SimpleExplosion import Sound.ALUT import Item+import Common radialVelocity = pi -- radians per second @@ -52,7 +53,7 @@ type LanceInventory = [Bool] -data Lance = Lance { angle :: Double -- radians+data Lance = Lance { angle :: Angle -- radians , center :: WrapPoint , rotationalThrusters :: RotationDirection , idealTargetCenter :: Maybe WrapPoint@@ -67,7 +68,7 @@ -- firing , launchTube :: [Projectile]- , sinceLastShot :: Double+ , sinceLastShot :: Time , fireTrigger :: Bool , currentWeapon :: Int , inventory :: LanceInventory@@ -171,7 +172,7 @@ shielded :: Lance -> Bool shielded lance = deflectorCharge lance >= 1.0 && deflector lance -updateAngle :: Double -> Lance -> Lance+updateAngle :: Time -> Lance -> Lance updateAngle t lance | rotationalThrusters lance == CW = lance { angle = angle lance - radialVelocity * t}@@ -361,7 +362,7 @@ else min 2.0 (charge + t * 0.05) in lance { deflectorCharge = charge' } -updateIdealTargetCenter :: Double -> Lance -> Lance+updateIdealTargetCenter :: Time -> Lance -> Lance updateIdealTargetCenter t lance = lance { idealTargetCenter = Just (M.idealNewLocation (wrapMap lance) (center lance)@@ -369,7 +370,7 @@ t) } -updateVelocity :: Double -> Lance -> Lance+updateVelocity :: Time -> Lance -> Lance updateVelocity t lance | linearThrusters lance = lance { velocity = M.calcNewVelocity
Moving.hs view
@@ -5,11 +5,12 @@ import Trigonometry import Data.List (find) import Control.Monad (join)+import Common maxExpectedVelocity = 1000 -- should equal max velocity of fastest object in arena calcNewVelocity- :: (Double, Double) -> Double -> Double -> Double -> Double -> (Double, Double)+ :: Velocity -> Double -> Angle -> Double -> Time -> (Double, Double) calcNewVelocity oVelocity accelerationRate thrustAngle maxVelocity t = let (vXo, vYo) = oVelocity in let acceleration = t * accelerationRate in@@ -27,7 +28,7 @@ let finalY = sin aVN * finalMag in (finalX, finalY) -idealNewLocation :: WrapMap -> WrapPoint -> (Double, Double) -> Double -> WrapPoint+idealNewLocation :: WrapMap -> WrapPoint -> Velocity -> Time -> WrapPoint idealNewLocation wmap oLocation (velX, velY) t = addPoints' wmap oLocation velocity' where velocity' = (velX * t, velY * t)@@ -37,13 +38,13 @@ class (Locatable a) => Moving a where - velocity :: a -> (Double, Double)+ velocity :: a -> Velocity class (Moving a) => Colliding a where collisionRadius :: a -> Double -data Collision = Collision { time :: Double -- since start of collision detection+data Collision = Collision { time :: Time -- since start of collision detection -- window frame , center1 :: WrapPoint -- at point of collision , center2 :: WrapPoint -- likewise@@ -52,7 +53,7 @@ -- Double refers to time window for checking for collision collision :: (Colliding a, Colliding b) => WrapMap- -> Double+ -> Time -> a -> b -> Maybe Collision@@ -82,7 +83,7 @@ collisionWindow wmap range obj1 obj2 = W.distance wmap (center obj1) (center obj2) <= range -collisionScan :: (Colliding a, Colliding b) => WrapMap -> a -> [b] -> Double -> Maybe Collision+collisionScan :: (Colliding a, Colliding b) => WrapMap -> a -> [b] -> Time -> Maybe Collision collisionScan wmap c cs t = let relAsteroids = [ a | a <- cs
Projectile/Blade.hs view
@@ -15,6 +15,7 @@ import Data.Maybe import ResourceTracker import GHC.Float+import Common velocityC = 250.0 rangeC = 1500.0@@ -24,17 +25,17 @@ speed = velocityC data Blade =- Blade { velocity :: (Double, Double)+ Blade { velocity :: Velocity , center :: WrapPoint , rangeLeft :: Double , wrapMap :: WrapMap , idealNewCenter :: Maybe WrapPoint- , clock :: Double+ , clock :: Time , resourceTracker :: ResourceTracker } -- angle is radians-new :: WrapMap -> ResourceTracker -> Double -> WrapPoint -> (Double, Double) -> Blade+new :: WrapMap -> ResourceTracker -> Angle -> WrapPoint -> Velocity -> Blade new wmap rt angle center' (vpx, vpy) = let x = cos angle * velocityC in let y = sin angle * velocityC in@@ -86,7 +87,7 @@ , clock = clock self + t } -updateIdealTargetCenter :: Double -> Blade -> Blade+updateIdealTargetCenter :: Time -> Blade -> Blade updateIdealTargetCenter t self = let newLoc = M.idealNewLocation (wrapMap self) (center self)
Projectile/BulletMI.hs view
@@ -9,22 +9,23 @@ import Graphics.Gloss.Data.Color import Data.WrapAround import qualified Moving as M+import Common velocityC = 400.0 rangeC = 500.0 data BulletMI =- BulletMI { velocity :: (Double, Double)+ BulletMI { velocity :: Velocity , center :: WrapPoint , rangeLeft :: Double , wrapMap :: WrapMap , idealNewCenter :: Maybe WrapPoint , impacted :: Bool- , clock :: Double+ , clock :: Time } -- angle is radians-new :: WrapMap -> Double -> WrapPoint -> (Double, Double) -> BulletMI+new :: WrapMap -> Angle -> WrapPoint -> Velocity -> BulletMI new wmap angle center' (vpx, vpy) = let x = cos angle * velocityC in let y = sin angle * velocityC in@@ -83,7 +84,7 @@ , idealNewCenter = Nothing } -updateIdealTargetCenter :: Double -> BulletMI -> BulletMI+updateIdealTargetCenter :: Time -> BulletMI -> BulletMI updateIdealTargetCenter t self = let newLoc = M.idealNewLocation (wrapMap self) (center self)
Projectile/BulletMII.hs view
@@ -9,22 +9,23 @@ import Graphics.Gloss.Data.Color import Data.WrapAround import qualified Moving as M+import Common velocityC = 400.0 rangeC = 700.0 data BulletMII =- BulletMII { velocity :: (Double, Double)+ BulletMII { velocity :: Velocity , center :: WrapPoint , rangeLeft :: Double , wrapMap :: WrapMap , idealNewCenter :: Maybe WrapPoint , impacted :: Bool- , clock :: Double+ , clock :: Time } -- angle is radians-new :: WrapMap -> Double -> WrapPoint -> (Double, Double) -> BulletMII+new :: WrapMap -> Angle -> WrapPoint -> Velocity -> BulletMII new wmap angle center' (vpx, vpy) = let x = cos angle * velocityC in let y = sin angle * velocityC in@@ -83,7 +84,7 @@ , idealNewCenter = Nothing } -updateIdealTargetCenter :: Double -> BulletMII -> BulletMII+updateIdealTargetCenter :: Time -> BulletMII -> BulletMII updateIdealTargetCenter t self = let newLoc = M.idealNewLocation (wrapMap self) (center self)
Projectile/BulletMkI.hs view
@@ -9,22 +9,23 @@ import Graphics.Gloss.Data.Color import Data.WrapAround import qualified Moving as M+import Common velocityC = 700.0 rangeC = 1000.0 data BulletMkI =- BulletMkI { velocity :: (Double, Double)+ BulletMkI { velocity :: Velocity , center :: WrapPoint , rangeLeft :: Double , wrapMap :: WrapMap , idealNewCenter :: Maybe WrapPoint , impacted :: Bool- , clock :: Double+ , clock :: Time } -- angle is radians-new :: WrapMap -> Double -> WrapPoint -> (Double, Double) -> BulletMkI+new :: WrapMap -> Angle -> WrapPoint -> Velocity -> BulletMkI new wmap angle center' (vpx, vpy) = let x = cos angle * velocityC in let y = sin angle * velocityC in@@ -83,7 +84,7 @@ , idealNewCenter = Nothing } -updateIdealTargetCenter :: Double -> BulletMkI -> BulletMkI+updateIdealTargetCenter :: Time -> BulletMkI -> BulletMkI updateIdealTargetCenter t self = let newLoc = M.idealNewLocation (wrapMap self) (center self)
Projectile/BulletSI.hs view
@@ -9,22 +9,23 @@ import Graphics.Gloss.Data.Color import Data.WrapAround import qualified Moving as M+import Common velocityC = 400.0 rangeC = 500.0 data BulletSI =- BulletSI { velocity :: (Double, Double)+ BulletSI { velocity :: Velocity , center :: WrapPoint , rangeLeft :: Double , wrapMap :: WrapMap , idealNewCenter :: Maybe WrapPoint , impacted :: Bool- , clock :: Double+ , clock :: Time } -- angle is radians-new :: WrapMap -> Double -> WrapPoint -> (Double, Double) -> BulletSI+new :: WrapMap -> Angle -> WrapPoint -> Velocity -> BulletSI new wmap angle center' (vpx, vpy) = let x = cos angle * velocityC in let y = sin angle * velocityC in@@ -83,7 +84,7 @@ , idealNewCenter = Nothing } -updateIdealTargetCenter :: Double -> BulletSI -> BulletSI+updateIdealTargetCenter :: Time -> BulletSI -> BulletSI updateIdealTargetCenter t self = let newLoc = M.idealNewLocation (wrapMap self) (center self)
Projectile/BulletSII.hs view
@@ -10,6 +10,7 @@ import Graphics.Gloss.Data.Color import Data.WrapAround import qualified Moving as M+import Common velocityC = 600.0 rangeC = 1000.0@@ -17,17 +18,17 @@ speed = velocityC data BulletSII =- BulletSII { velocity :: (Double, Double)+ BulletSII { velocity :: Velocity , center :: WrapPoint , rangeLeft :: Double , wrapMap :: WrapMap , idealNewCenter :: Maybe WrapPoint , impacted :: Bool- , clock :: Double+ , clock :: Time } -- angle is radians-new :: WrapMap -> Double -> WrapPoint -> (Double, Double) -> BulletSII+new :: WrapMap -> Angle -> WrapPoint -> Velocity -> BulletSII new wmap angle center' (vpx, vpy) = let x = cos angle * velocityC in let y = sin angle * velocityC in@@ -86,7 +87,7 @@ , idealNewCenter = Nothing } -updateIdealTargetCenter :: Double -> BulletSII -> BulletSII+updateIdealTargetCenter :: Time -> BulletSII -> BulletSII updateIdealTargetCenter t self = let newLoc = M.idealNewLocation (wrapMap self) (center self)
Projectile/Cannon.hs view
@@ -10,6 +10,7 @@ import Data.WrapAround import qualified Moving as M import GHC.Float+import Common velocityC = 500.0 rangeC = 800.0@@ -21,17 +22,17 @@ radiusC = 12.0 data Cannon =- Cannon { velocity :: (Double, Double)+ Cannon { velocity :: Velocity , center :: WrapPoint , rangeLeft :: Double , wrapMap :: WrapMap , idealNewCenter :: Maybe WrapPoint , integrity :: Double- , clock :: Double+ , clock :: Time } -- angle is radians-new :: WrapMap -> Double -> WrapPoint -> (Double, Double) -> Cannon+new :: WrapMap -> Angle -> WrapPoint -> Velocity -> Cannon new wmap angle center' (vpx, vpy) = let x = cos angle * velocityC in let y = sin angle * velocityC in@@ -90,7 +91,7 @@ , idealNewCenter = Nothing } -updateIdealTargetCenter :: Double -> Cannon -> Cannon+updateIdealTargetCenter :: Time -> Cannon -> Cannon updateIdealTargetCenter t self = let newLoc = M.idealNewLocation (wrapMap self) (center self)
Projectile/Mine.hs view
@@ -13,6 +13,7 @@ import Data.Maybe import qualified AfterEffect.MineExplosion as MineExplosion import AfterEffect+import Common detRadius = 100.0 punch = 1.0@@ -20,7 +21,7 @@ data Mine = Mine { center :: WrapPoint , impacted :: Bool- , clock :: Double+ , clock :: Time , resourceTracker :: ResourceTracker , wrapMap :: WrapMap }
Projectile/Nuke.hs view
@@ -11,6 +11,7 @@ import qualified Moving as M import ResourceTracker import Data.Maybe+import Common velocityC = 200.0 @@ -20,17 +21,17 @@ detTime = 1.5 data Nuke =- Nuke { velocity :: (Double, Double)+ Nuke { velocity :: Velocity , center :: WrapPoint , wrapMap :: WrapMap , idealNewCenter :: Maybe WrapPoint- , clock :: Double+ , clock :: Time , initialBlastCompleted :: Bool , resourceTracker :: ResourceTracker } -- angle is radians-new :: WrapMap -> ResourceTracker -> Double -> WrapPoint -> (Double, Double) -> Nuke+new :: WrapMap -> ResourceTracker -> Angle -> WrapPoint -> Velocity -> Nuke new wmap rt angle center' (vpx, vpy) = let x = cos angle * velocityC in let y = sin angle * velocityC in@@ -102,7 +103,7 @@ , initialBlastCompleted = clock self >= detTime } -updateIdealTargetCenter :: Double -> Nuke -> Nuke+updateIdealTargetCenter :: Time -> Nuke -> Nuke updateIdealTargetCenter t self = let newLoc = M.idealNewLocation (wrapMap self) (center self)
Projectile/Pellet.hs view
@@ -10,6 +10,7 @@ import Graphics.Gloss.Data.Color import Data.WrapAround import qualified Moving as M+import Common velocityC = 600.0 rangeC = 300.0@@ -18,7 +19,7 @@ range = rangeC data Pellet =- Pellet { velocity :: (Double, Double)+ Pellet { velocity :: Velocity , center :: WrapPoint , rangeLeft :: Double , wrapMap :: WrapMap@@ -27,7 +28,7 @@ } -- angle is radians-new :: WrapMap -> Double -> WrapPoint -> (Double, Double) -> Pellet+new :: WrapMap -> Angle -> WrapPoint -> Velocity -> Pellet new wmap angle center' (vpx, vpy) = let x = cos angle * velocityC in let y = sin angle * velocityC in@@ -71,7 +72,7 @@ , idealNewCenter = Nothing } -updateIdealTargetCenter :: Double -> Pellet -> Pellet+updateIdealTargetCenter :: Time -> Pellet -> Pellet updateIdealTargetCenter t self = let newLoc = M.idealNewLocation (wrapMap self) (center self)
Step.hs view
@@ -25,7 +25,10 @@ import System.Exit import Resources import Sound.ALUT+import Common +delayOnDeath = 4.0+ stepUniverse :: Float -> Universe -> IO Universe stepUniverse t u = let t' = float2Double t in@@ -36,7 +39,7 @@ return u' -handleLives :: (Double, Universe) -> IO (Double, Universe)+handleLives :: (Time, Universe) -> IO (Time, Universe) handleLives (t, u) = do let a = arena u let wmap = Universe.wrapMap a@@ -54,7 +57,7 @@ a { lance = Just (Lance.new rt wmap (wrappoint wmap (0, 0))) }- , delayRemaining = 2.0+ , delayRemaining = delayOnDeath } ) else return@@ -66,11 +69,11 @@ } , level = 0 , lives = 3- , delayRemaining = 2.0+ , delayRemaining = delayOnDeath } ) -handleNewLevel :: (Double, Universe) -> IO (Double, Universe)+handleNewLevel :: (Time, Universe) -> IO (Time, Universe) handleNewLevel (t, u) | not (null (simpleUnits (arena u)) && null (smartUnits (arena u))) && not (skipLevel u)@@ -96,6 +99,7 @@ } , level = level u + 1 , skipLevel = False+ , levelMessageTimer = Just 0.0 } return (t, u') @@ -110,7 +114,7 @@ -- if level u >= length (levels u) -- then -handlePureUpdates :: (Double, Universe) -> IO (Double, Universe)+handlePureUpdates :: (Time, Universe) -> IO (Time, Universe) handlePureUpdates (t, u) = return $ ( handleExpiration . handlePostUpdates . handleCollisions@@ -119,10 +123,21 @@ . handlePreUpdates . handleVisionUpdates . fixFocus+ . handleUniverseCounters ) (t, u) +handleUniverseCounters :: (Time, Universe) -> (Time, Universe)+handleUniverseCounters (t, u) =+ let u' = u { levelMessageTimer = case levelMessageTimer u of+ Nothing -> Nothing+ Just mt -> if mt > 1.5+ then Nothing+ else Just (mt + t)+ , panelActivationTimer = panelActivationTimer u + t+ } in+ (t, u') -handleSound :: (Double, Universe) -> IO (Double, Universe)+handleSound :: (Time, Universe) -> IO (Time, Universe) handleSound (t, u) = let arena' = arena u in do let listenerCoords = case lance arena' of@@ -153,7 +168,7 @@ return (t, u') -handleExpiration :: (Double, Universe) -> (Double, Universe)+handleExpiration :: (Time, Universe) -> (Time, Universe) handleExpiration (t, u) = let arena' = arena u in @@ -206,7 +221,7 @@ Just a -> (nxs, nAFX ++ a) -handleLanceLaunches :: (Double, Universe) -> (Double, Universe)+handleLanceLaunches :: (Time, Universe) -> (Time, Universe) handleLanceLaunches (t, u) = let arena' = arena u in case lance arena' of@@ -220,7 +235,7 @@ } in (t, u') -handleUnitLaunches :: (Double, Universe) -> (Double, Universe)+handleUnitLaunches :: (Time, Universe) -> (Time, Universe) handleUnitLaunches (t, u) = let arena' = arena u in let (simpleUnits', unitProjectiles') =@@ -250,9 +265,9 @@ (t, u') handleUpdatesCore :: (forall a. (InternallyUpdating a- => (a -> Double -> a)))- -> (Double, Universe)- -> (Double, Universe)+ => (a -> Time -> a)))+ -> (Time, Universe)+ -> (Time, Universe) handleUpdatesCore f (t, u) = let arena' = arena u in let lance' = do llance <- lance arena'@@ -278,13 +293,13 @@ } in (t, u') -handlePreUpdates :: (Double, Universe) -> (Double, Universe)+handlePreUpdates :: (Time, Universe) -> (Time, Universe) handlePreUpdates (t, u) = handleUpdatesCore Updating.preUpdate (t, u) -handlePostUpdates :: (Double, Universe) -> (Double, Universe)+handlePostUpdates :: (Time, Universe) -> (Time, Universe) handlePostUpdates (t, u) = handleUpdatesCore Updating.postUpdate (t, u) -handleVisionUpdates :: (Double, Universe) -> (Double, Universe)+handleVisionUpdates :: (Time, Universe) -> (Time, Universe) handleVisionUpdates (t, u) = let a = arena u in let u' = u { arena =@@ -438,7 +453,7 @@ Just _ -> let nx = processItem x y in collisionHandler nx ys nys -handleCollisions :: (Double, Universe) -> (Double, Universe)+handleCollisions :: (Time, Universe) -> (Time, Universe) handleCollisions (t, u) = ( handleCollisionsLanceItems
Unit/Simple/Turret.hs view
@@ -17,6 +17,7 @@ import qualified AfterEffect.SimpleExplosion as SimpleExplosion import Data.Maybe import Sound.ALUT+import Common radialVelocity = pi/6 -- radians per second @@ -26,13 +27,13 @@ maxIntegrity = 2.0 -data Turret = Turret { turretAngle :: Double -- radians- , velocity :: (Double, Double)+data Turret = Turret { turretAngle :: Angle -- radians+ , velocity :: Velocity , center :: WrapPoint , idealTargetLocation :: Maybe WrapPoint , wrapMap :: WrapMap , launchTube :: [Projectile]- , sinceLastShot :: Double+ , sinceLastShot :: Time , integrity :: Double , animDefault0 :: Picture , resourceTracker :: ResourceTracker@@ -80,8 +81,8 @@ new :: ResourceTracker -> WrapMap -> WrapPoint- -> Double- -> Double+ -> Angle+ -> Angle -> Turret new rt wmap center' tAngle mAngle = let pic = fromMaybe@@ -153,7 +154,7 @@ (velocity self) ) -updateIdealTargetLocation :: Double -> Turret -> Turret+updateIdealTargetLocation :: Time -> Turret -> Turret updateIdealTargetLocation t self = self { idealTargetLocation = Just (M.idealNewLocation (wrapMap self) (center self)
Unit/Smart/ATank.hs view
@@ -19,6 +19,7 @@ import Universe hiding (wrapMap, resourceTracker) import qualified Universe as U import Sound.ALUT+import Common radialVelocity = pi/4 -- radians per second @@ -30,13 +31,13 @@ accelerationRate = 40 -data ATank = ATank { angle :: Double -- radians- , velocity :: (Double, Double)+data ATank = ATank { angle :: Angle -- radians+ , velocity :: Velocity , center :: WrapPoint , idealTargetLocation :: Maybe WrapPoint , wrapMap :: WrapMap , launchTube :: [Projectile]- , sinceLastShot :: Double+ , sinceLastShot :: Time , integrity :: Double , vision :: Maybe Arena , resourceTracker :: ResourceTracker@@ -84,7 +85,7 @@ new :: ResourceTracker -> WrapMap -> WrapPoint- -> Double+ -> Angle -> ATank new rt wmap center' angle' = ATank { center = center'@@ -123,7 +124,7 @@ | otherwise = 0.0 in self { angle = angle self + adj } -updateVelocity :: Double -> ATank -> ATank+updateVelocity :: Time -> ATank -> ATank updateVelocity t self = self { velocity = M.calcNewVelocity (velocity self)@@ -192,7 +193,7 @@ (center self) (M.center l)) -updateIdealTargetLocation :: Double -> ATank -> ATank+updateIdealTargetLocation :: Time -> ATank -> ATank updateIdealTargetLocation t self = self { idealTargetLocation = Just (M.idealNewLocation (wrapMap self) (center self)
Unit/Smart/Death.hs view
@@ -20,6 +20,7 @@ import Universe hiding (wrapMap, resourceTracker) import qualified Universe as U import Sound.ALUT+import Common radialVelocity = pi -- radians per second @@ -37,14 +38,14 @@ shotDelay_spread = 2.0 -data Death = Death { angle :: Double -- radians- , velocity :: (Double, Double)+data Death = Death { angle :: Angle -- radians+ , velocity :: Velocity , center :: WrapPoint , idealTargetLocation :: Maybe WrapPoint , wrapMap :: WrapMap , launchTube :: [Projectile]- , sinceLastShot_sniper :: Double- , sinceLastShot_spread :: Double+ , sinceLastShot_sniper :: Time+ , sinceLastShot_spread :: Time , integrity :: Double , vision :: Maybe Arena , resourceTracker :: ResourceTracker@@ -90,7 +91,7 @@ new :: ResourceTracker -> WrapMap -> WrapPoint- -> Double+ -> Angle -> Death new rt wmap center' angle' = Death { center = center'@@ -248,7 +249,7 @@ (center self) (M.center l)) -updateIdealTargetLocation :: Double -> Death -> Death+updateIdealTargetLocation :: Time -> Death -> Death updateIdealTargetLocation t self = self { idealTargetLocation = Just (M.idealNewLocation (wrapMap self) (center self)
Unit/Smart/Ninja.hs view
@@ -19,6 +19,7 @@ import Universe hiding (wrapMap, resourceTracker) import qualified Universe as U import Sound.ALUT+import Common radialVelocity = pi/2 -- radians per second @@ -34,13 +35,13 @@ shotDelay = 5.0 -data Ninja = Ninja { angle :: Double -- radians- , velocity :: (Double, Double)+data Ninja = Ninja { angle :: Angle -- radians+ , velocity :: Velocity , center :: WrapPoint , idealTargetLocation :: Maybe WrapPoint , wrapMap :: WrapMap , launchTube :: [Projectile]- , sinceLastShot :: Double+ , sinceLastShot :: Time , integrity :: Double , vision :: Maybe Arena , resourceTracker :: ResourceTracker@@ -87,7 +88,7 @@ new :: ResourceTracker -> WrapMap -> WrapPoint- -> Double+ -> Angle -> Ninja new rt wmap center' angle' = Ninja { center = center'@@ -129,7 +130,7 @@ | otherwise = 0.0 in self { angle = angle self + adj } -updateVelocity :: Double -> Ninja -> Ninja+updateVelocity :: Time -> Ninja -> Ninja updateVelocity t self = let thrustingVelocity = M.calcNewVelocity (velocity self)@@ -221,7 +222,7 @@ (M.velocity l) (M.velocity self)) -updateIdealTargetLocation :: Double -> Ninja -> Ninja+updateIdealTargetLocation :: Time -> Ninja -> Ninja updateIdealTargetLocation t self = self { idealTargetLocation = Just (M.idealNewLocation (wrapMap self) (center self)
Unit/Smart/Saucer.hs view
@@ -19,6 +19,7 @@ import Universe hiding (wrapMap, resourceTracker) import qualified Universe as U import Sound.ALUT+import Common radialVelocity = pi -- radians per second @@ -34,13 +35,13 @@ shotDelay = 0.10 -data Saucer = Saucer { angle :: Double -- radians- , velocity :: (Double, Double)+data Saucer = Saucer { angle :: Angle -- radians+ , velocity :: Velocity , center :: WrapPoint , idealTargetLocation :: Maybe WrapPoint , wrapMap :: WrapMap , launchTube :: [Projectile]- , sinceLastShot :: Double+ , sinceLastShot :: Time , integrity :: Double , vision :: Maybe Arena , resourceTracker :: ResourceTracker@@ -89,7 +90,7 @@ new :: ResourceTracker -> WrapMap -> WrapPoint- -> Double+ -> Angle -> Saucer new rt wmap center' angle' = Saucer { center = center'@@ -132,7 +133,7 @@ | otherwise = 0.0 in self { angle = angle self + adj } -updateVelocity :: Double -> Saucer -> Saucer+updateVelocity :: Time -> Saucer -> Saucer updateVelocity t self = let thrustingVelocity = M.calcNewVelocity (velocity self)@@ -226,7 +227,7 @@ , 5.498 ] -updateIdealTargetLocation :: Double -> Saucer -> Saucer+updateIdealTargetLocation :: Time -> Saucer -> Saucer updateIdealTargetLocation t self = self { idealTargetLocation = Just (M.idealNewLocation (wrapMap self) (center self)
Unit/Smart/Sniper.hs view
@@ -19,6 +19,7 @@ import Universe hiding (wrapMap, resourceTracker) import qualified Universe as U import Sound.ALUT+import Common radialVelocity = pi/6 -- radians per second @@ -34,13 +35,13 @@ shotDelay = 4.0 -data Sniper = Sniper { angle :: Double -- radians- , velocity :: (Double, Double)+data Sniper = Sniper { angle :: Angle -- radians+ , velocity :: Velocity , center :: WrapPoint , idealTargetLocation :: Maybe WrapPoint , wrapMap :: WrapMap , launchTube :: [Projectile]- , sinceLastShot :: Double+ , sinceLastShot :: Time , integrity :: Double , vision :: Maybe Arena , resourceTracker :: ResourceTracker@@ -88,7 +89,7 @@ new :: ResourceTracker -> WrapMap -> WrapPoint- -> Double+ -> Angle -> Sniper new rt wmap center' angle' = Sniper { center = center'@@ -127,7 +128,7 @@ | otherwise = 0.0 in self { angle = angle self + adj } -updateVelocity :: Double -> Sniper -> Sniper+updateVelocity :: Time -> Sniper -> Sniper updateVelocity t self = self { velocity = M.calcNewVelocity (velocity self)@@ -201,7 +202,7 @@ (M.velocity l) (M.velocity self)) -updateIdealTargetLocation :: Double -> Sniper -> Sniper+updateIdealTargetLocation :: Time -> Sniper -> Sniper updateIdealTargetLocation t self = self { idealTargetLocation = Just (M.idealNewLocation (wrapMap self) (center self)
Unit/Smart/Tank.hs view
@@ -19,6 +19,7 @@ import Universe hiding (wrapMap, resourceTracker) import qualified Universe as U import Sound.ALUT+import Common radialVelocity = pi/6 -- radians per second @@ -30,13 +31,13 @@ accelerationRate = 30 -data Tank = Tank { angle :: Double -- radians- , velocity :: (Double, Double)+data Tank = Tank { angle :: Angle -- radians+ , velocity :: Velocity , center :: WrapPoint , idealTargetLocation :: Maybe WrapPoint , wrapMap :: WrapMap , launchTube :: [Projectile]- , sinceLastShot :: Double+ , sinceLastShot :: Time , integrity :: Double , vision :: Maybe Arena , resourceTracker :: ResourceTracker@@ -84,7 +85,7 @@ new :: ResourceTracker -> WrapMap -> WrapPoint- -> Double+ -> Angle -> Tank new rt wmap center' angle' = Tank { center = center'@@ -123,7 +124,7 @@ | otherwise = 0.0 in self { angle = angle self + adj } -updateVelocity :: Double -> Tank -> Tank+updateVelocity :: Time -> Tank -> Tank updateVelocity t self = self { velocity = M.calcNewVelocity (velocity self)@@ -192,7 +193,7 @@ (center self) (M.center l)) -updateIdealTargetLocation :: Double -> Tank -> Tank+updateIdealTargetLocation :: Time -> Tank -> Tank updateIdealTargetLocation t self = self { idealTargetLocation = Just (M.idealNewLocation (wrapMap self) (center self)
Universe.hs view
@@ -10,6 +10,7 @@ ) import ResourceTracker import Item+import Common data Arena = Arena { lance :: Maybe Lance , lastFocus :: WrapPoint@@ -31,6 +32,8 @@ , delayRemaining :: Double , resourceTracker :: ResourceTracker , skipLevel :: Bool+ , levelMessageTimer :: Maybe Time+ , panelActivationTimer :: Time } blankArena width height =
Updating.hs view
@@ -3,10 +3,11 @@ import {-# SOURCE #-} AfterEffect ( AfterEffect ) import {-# SOURCE #-} Universe ( Arena ) --- Double is elapsed time in seconds+import Common+ class InternallyUpdating a where- preUpdate :: a -> Double -> a- postUpdate :: a -> Double -> a+ preUpdate :: a -> Time -> a+ postUpdate :: a -> Time -> a {- Objects that exist temporarily or that may die after being wounded a certain
edge.cabal view
@@ -7,7 +7,7 @@ -- The package version. See the Haskell package versioning policy -- (http://www.haskell.org/haskellwiki/Package_versioning_policy) for -- standards guiding when and how versions should be incremented.-Version: 0.8+Version: 0.8.2 -- A short (one-line) description of the package. Synopsis: Top view space combat arcade game@@ -23,7 +23,7 @@ Good luck commander! -- URL for the project homepage or repository.-Homepage: http://frigidcode.com+Homepage: http://frigidcode.com/code/edge -- The license under which the package is released. License: GPL-3@@ -72,6 +72,7 @@ Other-modules: Lance , Asteroid , BigAsteroid+ , Common , Trigonometry , Animation , Star
edge.hs view
@@ -48,5 +48,7 @@ , delayRemaining = 2.0 , resourceTracker = rt , skipLevel = False+ , levelMessageTimer = Nothing+ , panelActivationTimer = 0.0 }