0
我正在尝试使用pyglet进行侧面滚动游戏,并且我设法绘制了背景,角色和一些地形。 (我对GUI的东西很新)问题是,当玩家移动角色时,地形是为了产生自身(比如像terraria这样的游戏),但是我没有办法做到这一点,但没有制作1000个副本精灵。你有什么想法可以解决这个问题吗?随意提问,如果我没有说清楚了:)如何在pyglet侧滚动器中创建随机无限地形?
编辑:我一直在做,到目前为止为每个地形像这样创建一个变量:
ground_1 = pyglet.sprite.Sprite(ground1, x=-100, y=200, batch = terrain)
ground = pyglet.sprite.Sprite(ground1, 0, y=200, batch = terrain)
ground2 = pyglet.sprite.Sprite(ground1, x=100, y = 200, batch = terrain)
ground3 = pyglet.sprite.Sprite(ground1, x=200, y = 200, batch = terrain)
ground4 = pyglet.sprite.Sprite(ground1, x=300, y = 200, batch = terrain)
ground5 = pyglet.sprite.Sprite(ground1, x=400, y = 200, batch = terrain)
ground6 = pyglet.sprite.Sprite(ground1, x=500, y = 200, batch = terrain)
ground7 = pyglet.sprite.Sprite(ground1, x=600, y = 200, batch = terrain)
ground8 = pyglet.sprite.Sprite(ground1, x=700, y = 200, batch = terrain)
ground9 = pyglet.sprite.Sprite(ground1, x=800, y = 200, batch = terrain)
ground10 = pyglet.sprite.Sprite(ground1, x=900, y = 200, batch = terrain)
我还创建了一个类眼看块是否对其有一棵树:
class block():
""" block """
def __init__(self,image,tree,grass,destroyed):
self.image = image
self.tree = tree
self.grass = grass
self.destroyed = destroyed
newGround1 = block(newGround,tree[treeR],grass[grassR],destroyed[destroyedR])
groundO = block(ground_1,False,False,False)
groundO1 = block(ground,True,False,False)
groundO2 = block(ground2,False,False,False)
groundO3 = block(ground3,False,False,False)
groundO4 = block(ground4,False,False,False)
groundO5 = block(ground5,False,False,False)
groundO6 = block(ground6,False,False,False)
groundO7 = block(ground7,False,False,False)
groundO8 = block(ground8,False,False,False)
groundO9 = block(ground9,False,False,False)
groundO10 = block(ground10,False,False,False)
但我在想,如果我不得不创建 ground2,ground3,ground4 ...所有我想要的地形或如果有一个更简单生成它的方式(可能无限制)
我编辑了它:) – user1237200 2012-04-13 22:26:47