擅长:python、mysql、java
<p>污垢不显示,因为内环的范围错误,并且污垢瓷砖的y位置计算不正确。你知道吗</p>
<p>计算污垢开始的y水平面和必须被污垢覆盖的区域的高度:</p>
<pre><code>dirt_start_height = height_of_grass + grass.get_width()
all_dirt_height = height - dirt_start_height
</code></pre>
<p>在吸引污垢的嵌套循环中使用<code>dirt_start_height</code>和<code>all_dirt_height</code>:</p>
<pre><code>while run:
# [...]
dirt_start_height = height_of_grass + grass.get_width()
all_dirt_height = height - dirt_start_height
for x in range(int(width/dirt.get_width()) + 1):
for y in range(int(all_dirt_height / grass.get_height()) + 1):
screen.blit(dirt, (x*dirt.get_width(), dirt_start_height + y*dirt.get_height()))
</code></pre>