This repository has been archived on 2025-02-14. You can view files and clone it, but cannot push or open issues or pull requests.
LXCsGame/module/utils.py

24 lines
633 B
Python

import random
from module import WIDTH, BLOCK_SIZE, HEIGHT
# 生成地形
def generate_terrain():
world = []
ground_level = HEIGHT // BLOCK_SIZE // 2
for x in range(WIDTH // BLOCK_SIZE):
column = []
height = ground_level + random.randint(-3, 3)
for y in range(HEIGHT // BLOCK_SIZE):
if y > height + 2:
column.append("stone")
elif y == height:
column.append("grass")
elif y > height - 3:
column.append("dirt")
else:
column.append("air")
world.append(column)
return world