这是问题的主要焦点:
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
整个程序:
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
说明:我在网上找到了一个非常简单的 Minecraft 克隆,我正在尝试通过添加地形生成器来扩展它。地形生成器支持 3 块泥土、草和石头。底部 6 层随机生成泥土和石头,顶部有一层草。这个问题的主要焦点是最后一个 For 语句。对于每一列,选择一个随机数。选择的随机数是每列删除多少块。但这会造成非常参差不齐和不自然的地形。我可以做一些奇怪的三角函数来制作山丘/自然地形,还是其他方式?