From 0a7a882f8fd6b02d2cb521a79a73e0f100e13801 Mon Sep 17 00:00:00 2001 From: Jonas Betzendahl Date: Thu, 24 Apr 2014 12:44:58 +0200 Subject: [PATCH] Now generates a different unique map each time. --- src/Map/Creation.hs | 24 ------------------------ src/Map/Graphics.hs | 6 +++--- src/Map/Types.hs | 2 +- 3 files changed, 4 insertions(+), 28 deletions(-) diff --git a/src/Map/Creation.hs b/src/Map/Creation.hs index 8f302c2..04d018d 100644 --- a/src/Map/Creation.hs +++ b/src/Map/Creation.hs @@ -69,27 +69,3 @@ heightToTerrain GrassIslandMap y | y < 10 = Hill | otherwise = Mountain heightToTerrain _ _ = undefined - -type Seed = (XCoord, ZCoord) - --- | Add lakes on generated Map from (possible) Seeds noted before. --- --- TODO: implement and erode terrain on the way down. -addLakes :: PlayMap -> [Seed] -> PlayMap -addLakes = undefined - -gaussMountain :: Int -> PlayMap -> PlayMap -gaussMountain seed mp = aplByPlace (liftUp c) (\(_,_) -> True) mp - where - g = mkStdGen seed - c = head $ randomRs (bounds mp) g - fi = fromIntegral - htt = heightToTerrain - - -- TODO: Fix Lambda to True with sensible function, maybe rework giveNeighbourhood in Map.Map - liftUp :: (Int, Int) -> Node -> Node - liftUp (gx,gz) (Full (x,z) y _ b pl pa r s) = let y_neu = max y e - in (Full (x,z) y_neu (htt GrassIslandMap y_neu) b pl pa r s) - where e = gauss3Dgeneral 10.0 (fi gx) (fi gz) 5.0 5.0 (fi x) (fi z) - liftUp (gx, gz) (Minimal (x,z)) = Full (x,z) e (htt GrassIslandMap e) BFlag NoPlayer NoPath Plain [] - where e = gauss3Dgeneral 10.0 (fi gx) (fi gz) 5.0 5.0 (fi x) (fi z) diff --git a/src/Map/Graphics.hs b/src/Map/Graphics.hs index 2a35ea9..bf1dcfe 100644 --- a/src/Map/Graphics.hs +++ b/src/Map/Graphics.hs @@ -31,6 +31,7 @@ import Linear import Map.Types import Map.StaticMaps import Map.Creation +import Map.Combinators type Height = Float @@ -58,7 +59,7 @@ convertToGraphicsMap :: PlayMap -> GraphicsMap convertToGraphicsMap mp = array (bounds mp) [(i, graphicsyfy (mp ! i))| i <- indices mp] where graphicsyfy :: Node -> MapEntry - graphicsyfy (Minimal _ ) = (0, Grass) + graphicsyfy (Minimal _ ) = (1.0, Grass) graphicsyfy (Full _ y t _ _ _ _ _ ) = (y, t) lineHeight :: GLfloat @@ -89,8 +90,7 @@ fgVertexIndex = (ToFloat, mapVertexArrayDescriptor 3 7) --vertex after normal getMapBufferObject :: IO (BufferObject, NumArrayIndices) getMapBufferObject = do - let mountains = [(gaussMountain 123456), (gaussMountain 31415926), - (gaussMountain 101514119), (gaussMountain 0)] + mountains <- mnt myMap' <- return $ convertToGraphicsMap $ convertToStripeMap $ aplAll mountains mapEmpty ! myMap <- return $ generateTriangles myMap' len <- return $ fromIntegral $ P.length myMap `div` numComponents diff --git a/src/Map/Types.hs b/src/Map/Types.hs index d3fe76c..66ddb4a 100644 --- a/src/Map/Types.hs +++ b/src/Map/Types.hs @@ -68,5 +68,5 @@ data TileType = Ocean -- TODO: Record Syntax data Node = Full (XCoord, ZCoord) YCoord TileType BuildInfo PlayerInfo PathInfo ResInfo StorInfo - | Minimal (XCoord, ZCoord) -- defaults to empty green grass node on height 0 + | Minimal (XCoord, ZCoord) -- defaults to empty green grass node on height 1 deriving (Show)