aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Resources.hs20
-rw-r--r--maps/goliath_height.pngbin0 -> 15565 bytes
-rw-r--r--maps/goliath_terrain.pngbin0 -> 2849 bytes
-rw-r--r--maps/kingofhill_height.pngbin13921 -> 0 bytes
-rw-r--r--maps/kingofhill_terrain.pngbin1101 -> 0 bytes
5 files changed, 14 insertions, 6 deletions
diff --git a/Resources.hs b/Resources.hs
index 9f0806f..e5cb528 100644
--- a/Resources.hs
+++ b/Resources.hs
@@ -94,7 +94,8 @@ data Resources = Resources {
dDown :: GLfloat,
waterArray :: ArrIO.IOArray (Int,Int) GLfloat,
headBob :: GLfloat,
- mode :: CameraMode
+ mode :: CameraMode,
+ threadDiff :: Double
}
getSpeed :: Resources -> GLfloat
@@ -160,6 +161,7 @@ firstPerson res =
in do
return $ ((setHeadBob.(+ jitter)) <..> headBob) $
if (newh+0.3 > droph) then
+ setSpeedFactor 0.03 $
setRPosition (CameraPosition (Vec3 (x,newh+0.2,y)) (th + (asin dx) * speed * 15) (ph - (asin dy) * speed * 15)) $
setDDown 0 res
else
@@ -245,7 +247,6 @@ eventHandle event res = do
let getY (Vec3 (_,y,_)) = y in
return $
setPositionUpdate firstPerson $
- setSpeedFactor 0.03 $
setMode FirstPerson $
(setDDown <..> (negate . getY . resourcesVelocity)) res
KeyUp (Keysym SDLK_e _ _) ->
@@ -266,7 +267,9 @@ eventHandle event res = do
return res
KeyDown (Keysym SDLK_SPACE _ _) -> do
- return $ setDDown (-0.2) res
+ return $
+ setDDown (-0.2) $
+ setSpeedFactor 0.05 res
KeyDown (Keysym SDLK_LSHIFT _ _) -> do
return $ setSpeedMultiplier 4 res
@@ -315,13 +318,17 @@ displayHandle resources = do
SDL.glSwapBuffers
time2 <- getPOSIXTime
- let diff = 0.033 - (time2 - time1)
+ let diff = threadDiff resources - (realToFrac $ time2 - time1)
when (diff > 0) (threadDelay $ round $ diff * 1000000)
time3 <- getPOSIXTime
+ let fps = realToFrac $ 1 / (time3 - time1) :: Double
- putStr $ printf "FPS: %.2f\r" (realToFrac $ 1/ (time3 - time1) :: Double)
+ putStr $ printf "FPS: %.2f\r" fps
- return resources
+ return $
+ if' (fps < 30)
+ ((setThreadDiff.(subtract 0.0001)) <..> threadDiff)
+ ((setThreadDiff.(+0.0001)) <..> threadDiff) resources
cameraToEuclidian :: CameraPosition -> Vec3 GLfloat
cameraToEuclidian (CameraPosition _ ph th) = V.normalize $ Vec3 $ toEuclidian (1,ph,th)
@@ -576,6 +583,7 @@ makeResources surf builder forestB jungleB water arr waterarr = do
<*> pure waterarr
<*> pure 0
<*> pure Oracle
+ <*> pure 0.033
printErrors :: String -> IO ()
printErrors ctx =
diff --git a/maps/goliath_height.png b/maps/goliath_height.png
new file mode 100644
index 0000000..557922b
--- /dev/null
+++ b/maps/goliath_height.png
Binary files differ
diff --git a/maps/goliath_terrain.png b/maps/goliath_terrain.png
new file mode 100644
index 0000000..e3eb9ab
--- /dev/null
+++ b/maps/goliath_terrain.png
Binary files differ
diff --git a/maps/kingofhill_height.png b/maps/kingofhill_height.png
deleted file mode 100644
index b548cf2..0000000
--- a/maps/kingofhill_height.png
+++ /dev/null
Binary files differ
diff --git a/maps/kingofhill_terrain.png b/maps/kingofhill_terrain.png
deleted file mode 100644
index 39b6d0e..0000000
--- a/maps/kingofhill_terrain.png
+++ /dev/null
Binary files differ