modify world generation rule
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import random
|
||||
from module import WIDTH, BLOCK_SIZE, HEIGHT
|
||||
from module.block import StoneBlock, GrassBlock, DirtBlock, AirBlock, Block
|
||||
from module.block import StoneBlock, GrassBlock, DirtBlock, AirBlock, Block, BedrockBlock
|
||||
|
||||
|
||||
# 生成地形
|
||||
@@ -9,17 +9,29 @@ def generate_terrain() -> list[list[Block]]:
|
||||
ground_level = HEIGHT // BLOCK_SIZE // 2
|
||||
|
||||
for x in range(WIDTH // BLOCK_SIZE):
|
||||
#
|
||||
# AIR BLOCK
|
||||
# height ============================= GRASS BLOCK
|
||||
# 4 DIRT BLOCK
|
||||
# +5 =============================
|
||||
# STONE BLOCK
|
||||
# max ============================= BEDROCK BLOCK
|
||||
#
|
||||
column = []
|
||||
height = ground_level + random.randint(-3, 3)
|
||||
for y in range(HEIGHT // BLOCK_SIZE):
|
||||
if y > height + 2:
|
||||
column.append(StoneBlock(x, y))
|
||||
if y < height:
|
||||
block = AirBlock(x, y)
|
||||
elif y == height:
|
||||
column.append(GrassBlock(x, y))
|
||||
elif y > height - 3:
|
||||
column.append(DirtBlock(x, y))
|
||||
block = GrassBlock(x, y)
|
||||
elif height < y < height + 5:
|
||||
block = DirtBlock(x, y)
|
||||
elif y == HEIGHT // BLOCK_SIZE - 1:
|
||||
block = BedrockBlock(x, y)
|
||||
else:
|
||||
column.append(AirBlock(x, y))
|
||||
block = StoneBlock(x, y)
|
||||
column.append(block)
|
||||
|
||||
world.append(column)
|
||||
|
||||
return world
|
||||
Reference in New Issue
Block a user