This is the main focus of the question:
For BlockX = 0 To 900 Step 30 'Try to carve out Hills
GraphicsWindow.BrushColor = "SkyBlue"
depth = Math.GetRandomNumber(5)
GraphicsWindow.FillRectangle(BlockX,BlockY,30,depth*30)
EndFor
And the whole program:
GraphicsWindow.Clear()
GraphicsWindow.CanResize = 0
GraphicsWindow.BackgroundColor = "SkyBlue"
gw = GraphicsWindow.Width
gh = GraphicsWindow.Height
gw = 900
gh = 600
For BlockX = 0 To 900 Step 30
For BlockY = 420 to 270 Step -30
b = Math.GetRandomNumber(2)
If b = 1 Then 'Stone
GraphicsWindow.DrawImage("C:\AllVersions\Versions\v0.4\SBCraft\assets\rock.png",BlockX,BlockY)
EndIf
If b = 2 Then 'Dirt
GraphicsWindow.DrawImage("C:\AllVersions\Versions\v0.4\SBCraft\assets\dirt.png",BlockX,BlockY)
EndIf
EndFor
EndFor
For BlockX = 0 To 900 Step 30 'Grass Layer
BlockY = 240
GraphicsWindow.DrawImage("C:\AllVersions\Versions\v0.4\SBCraft\assets\grass.png",BlockX,BlockY)
EndFor
For BlockX = 0 To 900 Step 30 'Try to carve out Hills
GraphicsWindow.BrushColor = "SkyBlue"
depth = Math.GetRandomNumber(5)
GraphicsWindow.FillRectangle(BlockX,BlockY,30,depth*30)
EndFor
Explanation: I found a very simple Minecraft clone online, and I'm trying to expand to it by adding a terrain generator. The terrain generator supports 3 blocks dirt, grass, and stone. For the bottom 6 layers, dirt and stone randomly generate, and a layer of grass on top. The main focus of this question is the last For statement. For each column, a random number is selected. The random number selected is how many blocks are deleted in each column. But this makes very jagged and unnatural terrain. Is there some weird trigonometric thing I can do to make hills / natural terrain, or another way?
Aucun commentaire:
Enregistrer un commentaire