From 47cb7b6abda067738205c2dcf579fa8807a54936 Mon Sep 17 00:00:00 2001 From: Yann Herklotz Date: Sat, 2 Jan 2021 20:19:24 +0000 Subject: Update colours and looks --- src/Vivant.hs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Vivant.hs b/src/Vivant.hs index a3973a5..001b463 100644 --- a/src/Vivant.hs +++ b/src/Vivant.hs @@ -268,7 +268,7 @@ pixelRenderer n x y = createTerrain :: [[Float]] createTerrain = - fmap (\y -> fmap (\x -> fromIntegral (pixelRenderer 0 x y) / 15) [0..63]) [0..63] + fmap (\y -> fmap (\x -> fromIntegral (pixelRenderer 0 x y) / 20) [0..63]) [0..63] initResources :: IO Game initResources = do @@ -313,7 +313,7 @@ castV3 (V3 a b c) = GL.Vector3 a b c draw :: Game -> IO () draw game@(Game {gameProgram = Just p, gameVao = Just v, gameTerrain = Just t}) = do tick <- ticks - GL.clearColor $= GL.Color4 1 1 1 1 + GL.clearColor $= GL.Color4 0.2 0.2 0.2 1 GL.clear [GL.ColorBuffer, GL.DepthBuffer] GL.currentProgram $= gameProgram game @@ -327,7 +327,7 @@ draw game@(Game {gameProgram = Just p, gameVao = Just v, gameTerrain = Just t}) cameraPosition = cameraPos camera targetPosition = cameraPosition ^+^ cameraFront camera viewMatrix = lookAt cameraPosition targetPosition (cameraUp camera) - projectionMatrix = perspective (toRadians 45) (640 / 480) 0.1 1000 + projectionMatrix = perspective (toRadians 45) (640 / 480) 0.1 200 poke (gameViewP game) viewMatrix poke (gameProjectionP game) projectionMatrix @@ -336,7 +336,9 @@ draw game@(Game {gameProgram = Just p, gameVao = Just v, gameTerrain = Just t}) GL.glUniformMatrix4fv projection 1 1 (castPtr (gameProjectionP game)) ourColorLoc <- GL.uniformLocation p "light_pos" - GL.uniform ourColorLoc $= castV3 (cameraPos (gameCamera game)) + GL.uniform ourColorLoc $= + (GL.Vector3 (0::Float) (32 * sin (fromIntegral tick / 2000)) (16 * (abs $ cos (fromIntegral tick / 2000)))) + --castV3 (cameraPos (gameCamera game)) render $ terrainRenderer t -- cgit