changed map a bit
This commit is contained in:
parent
ae304ddc5c
commit
1bbf900ec4
@ -3,5 +3,32 @@ where
|
||||
|
||||
import Map.Types
|
||||
|
||||
-- | Generate a new Map of given Type and Size
|
||||
--
|
||||
-- TODO:
|
||||
-- 1. Should take Size -> Type -> Playmap
|
||||
-- 2. plug together helper-functions for that terraintype
|
||||
newMap :: Int -> Int -> PlayMap
|
||||
newMap = undefined
|
||||
|
||||
|
||||
-- | Basic Terrain-Generator. Will not implement "abnormal" Stuff for given Biome
|
||||
-- (like Deserts on Grass-Islands or Grass on Deserts)
|
||||
--
|
||||
-- TODO: Implement Desert-Generator
|
||||
heightToTerrain :: MapType -> YCoord -> TileType
|
||||
heightToTerrain GrassIslandMap y
|
||||
| y < 0.1 = Ocean
|
||||
| y < 1 = Beach
|
||||
| y < 5 = Grass
|
||||
| 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 -> [Seeds] -> PlayMap
|
||||
addLakes m s = undefined
|
||||
|
@ -88,7 +88,7 @@ fgVertexIndex = (ToFloat, mapVertexArrayDescriptor 3 7) --vertex after normal
|
||||
|
||||
getMapBufferObject :: IO (BufferObject, NumArrayIndices)
|
||||
getMapBufferObject = do
|
||||
myMap' <- return $ convertToGraphicsMap $ convertToStripeMap mapCenterMountain
|
||||
myMap' <- return $ convertToGraphicsMap $ convertToStripeMap mapNoise
|
||||
! myMap <- return $ generateTriangles myMap'
|
||||
len <- return $ fromIntegral $ P.length myMap `div` numComponents
|
||||
putStrLn $ P.unwords ["num verts in map:",show len]
|
||||
|
@ -3,9 +3,10 @@ where
|
||||
|
||||
import Map.Types
|
||||
import Data.Array
|
||||
import Map.Creation (heightToTerrain)
|
||||
|
||||
-- general 3D-Gaussian
|
||||
gauss3Dgeneral :: Floating q =>
|
||||
gauss3Dgeneral :: Floating q =>
|
||||
q -- ^ Amplitude
|
||||
-> q -- ^ Origin on X-Achsis
|
||||
-> q -- ^ Origin on Z-Achsis
|
||||
@ -18,7 +19,7 @@ gauss3Dgeneral amp x0 z0 sX sZ x z = amp * exp(-(((x-x0)^(2 :: Integer)/(2 * sX^
|
||||
|
||||
-- specialised 3D gaussian with an origin on 100/100, an amplitude of 15 and two sigmas of 15
|
||||
gauss3D :: Floating q =>
|
||||
q -- ^ X-Coordinate
|
||||
q -- ^ X-Coordinate
|
||||
-> q -- ^ Z-Coordinate
|
||||
-> q -- ^ elevation on coordinate in quesion
|
||||
gauss3D = gauss3Dgeneral 15 100.0 100.0 15.0 15.0
|
||||
@ -36,14 +37,39 @@ mapCenterMountain :: PlayMap
|
||||
mapCenterMountain = array ((0,0),(199,199)) nodes
|
||||
where
|
||||
nodes = water ++ beach ++ grass ++ hill ++ mountain
|
||||
water = [((a,b), (Full (a,b) 0.0 Ocean BNothing NoPlayer NoPath Plain [])) | a <- [0..199], b <- [0..199], (m2d (a,b)) > 95]
|
||||
water = [((a,b), (Full (a,b) 0.0 Ocean BNothing NoPlayer NoPath Plain [])) | a <- [0..199], b <- [0..199], (m2d (a,b)) > 95]
|
||||
beach = [((a,b), (Full (a,b) (g2d a b) Beach BNothing NoPlayer NoPath Plain [])) | a <- [0..199], b <- [0..199], (m2d (a,b)) <= 95, (m2d (a,b)) > 75]
|
||||
grass = [((a,b), (Full (a,b) (g2d a b) Grass BNothing NoPlayer NoPath Plain [])) | a <- [0..199], b <- [0..199], (m2d (a,b)) <= 75, (m2d (a,b)) > 25]
|
||||
hill = [((a,b), (Full (a,b) (g2d a b) Hill BNothing NoPlayer NoPath Plain [])) | a <- [0..199], b <- [0..199], (m2d (a,b)) <= 25, (m2d (a,b)) > 10]
|
||||
mountain = [((a,b), (Full (a,b) (g2d a b) Mountain BNothing NoPlayer NoPath Plain [])) | a <- [0..199], b <- [0..199], (m2d (a,b)) <= 10]
|
||||
|
||||
|
||||
g2d :: Int -> Int -> Float
|
||||
g2d x y = gauss3D (fromIntegral x) (fromIntegral y)
|
||||
|
||||
m2d :: (Int,Int) -> Int
|
||||
m2d (x,y) = mnh2D (x,y) (100,100)
|
||||
|
||||
-- small helper for some hills. Should be replaced by multi-layer perlin-noise
|
||||
-- TODO: Replace as given in comment.
|
||||
_noisyMap :: (Floating q) => q -> q -> q
|
||||
_noisyMap = \x y -> gauss3Dgeneral 15 100.0 100.0 15.0 15.0 x y
|
||||
+ gauss3Dgeneral 5 10.0 10.0 10.0 10.0 x y
|
||||
+ gauss3Dgeneral 5 150.0 120.0 10.0 10.0 x y
|
||||
+ gauss3Dgeneral 5 50.0 75.0 10.0 10.0 x y
|
||||
|
||||
-- generates a noisy map
|
||||
-- TODO: add real noise to a simple pattern
|
||||
mapNoise :: PlayMap
|
||||
mapNoise = array ((0,0),(199,199)) nodes
|
||||
where
|
||||
nodes = [((a,b), (Full
|
||||
(a,b)
|
||||
(height a b)
|
||||
(heightToTerrain GrassIslandMap $ height a b)
|
||||
BNothing
|
||||
NoPlayer
|
||||
NoPath
|
||||
Plain
|
||||
[])) | a <- [0..199], b <- [0..199]]
|
||||
where
|
||||
height a b = (_noisyMap (fromIntegral a) (fromIntegral b))
|
||||
|
Loading…
Reference in New Issue
Block a user