import pygame
import blocks
import random
class World:
def __init__(self):
self.tile_list = []
TILESIZE = 20
minStoneHeight = 1
maxStoneHeight = 8
x = 0
y = 0
height = 10
width = 100
for x in range(width):
minHeight = height - 1
maxHeight = height + 2
height = random.randrange(minHeight, maxHeight)
minStoneSpawnDistance = height - minStoneHeight
maxStoneSpawnDistance = height - maxStoneHeight
totalStoneSpawnDistance = random.randrange(minStoneHeight, maxStoneHeight)
for y in range(height):
if y < totalStoneSpawnDistance:
t = blocks.stoneBlock(x*20, y*20 + 100)
self.tile_list.append(t)
else:
t = blocks.dirtBlock(x*20, y*20 + 100)
self.tile_list.append(t)
if(totalStoneSpawnDistance == height):
t = blocks.stoneBlock(x*20, y*20 + 100)
self.tile_list.append(t)
else:
self.tile_list.append(t)
t = blocks.stoneBlock(x*20, y*20+100)
def draw(self, screen):
for tile in self.tile_list:
tile.draw(screen)
这是我在pygame中用于程序地形生成的代码。我根据C#for Unity的脚本改编了它。问题是pygames网格orgin位于左上角,unitys位于左下角。我想知道如何才能让我的地形不被颠倒
这是个问题。您必须在应用程序循环而不是事件循环中移动播放器:
相关问题 更多 >
编程相关推荐