本文整理汇总了Python中pyglet.sprite.Sprite.color方法的典型用法代码示例。如果您正苦于以下问题:Python Sprite.color方法的具体用法?Python Sprite.color怎么用?Python Sprite.color使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyglet.sprite.Sprite
的用法示例。
在下文中一共展示了Sprite.color方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: on_draw
# 需要导入模块: from pyglet.sprite import Sprite [as 别名]
# 或者: from pyglet.sprite.Sprite import color [as 别名]
def on_draw(self):
from pyglet.sprite import Sprite
if not self.initialized:
self.initialized = True
self.init_gl()
width, height = self.get_size()
x_max = width // 32 + 1
y_max = height // 32 + 1
gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
gl.glEnable(gl.GL_BLEND)
fov = towel.FieldOfVision(self.passable.__contains__)
fov.place_viewer(self.player, self.player_view)
x, y = self.player
x_offset = x - x_max // 2
y_offset = y - y_max // 2
x_range = range(0, x_max + 1)
y_range = range(0, y_max + 1)
self.clear()
batch = pyglet.graphics.Batch()
sprites = []
player_screen_pos = None
for iy in y_range:
for ix in x_range:
p = (ix + x_offset, iy + y_offset)
image = None
color = (255, 255, 255)
if fov.is_visible(p):
if p in self.passable:
image = self.image_floor
else:
image = self.image_wall
self.remembered[p] = image
else:
image = self.remembered.get(p, None)
color = (128, 128, 128)
if image:
sprite = Sprite(image, ix*32, iy*32, batch=batch)
sprite.color = color
sprites.append(sprite)
if p == self.player:
player_screen_pos = (ix*32, iy*32)
batch.draw()
if player_screen_pos:
self.image_player.blit(*player_screen_pos)
self.invalid = False