本文整理汇总了Python中layer.Layer.fill方法的典型用法代码示例。如果您正苦于以下问题:Python Layer.fill方法的具体用法?Python Layer.fill怎么用?Python Layer.fill使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类layer.Layer
的用法示例。
在下文中一共展示了Layer.fill方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: GameMenu
# 需要导入模块: from layer import Layer [as 别名]
# 或者: from layer.Layer import fill [as 别名]
class GameMenu(State):
def __init__(self, *args, **kwargs):
State.__init__(self, *args, **kwargs)
self.state_vars["MENU"] = self
self.surface = None
self.clock = None
self.controls = None
self.font = None
self.exit = False
self.buttons = None
self.setup()
def setup(self):
self.surface = Layer(GameConfig.SCREEN_SIZE)
self.surface.fill(GameConfig.MENU_COLOR)
self.clock = pygame.time.Clock()
self.controls = EventControl({
pygame.QUIT: self.quit,
pygame.MOUSEMOTION: self.mouse_movement_event
})
self.font = pygame.font.Font(None, GameConfig.MENU_FONT_SIZE)
self.buttons = [
self.font.render("Start", True, GameConfig.MENU_TEXT_COLOR),
self.font.render("Options", True, GameConfig.MENU_TEXT_COLOR),
self.font.render("Exit", True, GameConfig.MENU_TEXT_COLOR)
]
def run(self):
while not self.exit:
self.clock.tick(GameConfig.FRAMES_PER_SECOND)
self.controls.poll_event()
self.draw_menu()
Layer.update()
return None
def draw_menu(self):
offset = 0
for button in self.buttons:
self.surface.blit(button, ((self.surface.get_width() - button.get_width()) / 2,
(self.surface.get_height() - button.get_height()) / 2 + offset))
offset += button.get_height() + GameConfig.MENU_TEXT_OFFSET
def mouse_movement_event(self, event):
for button in self.buttons:
if button.get_rect(left=self.surface.get_width() - 100).collidepoint(event.pos):
print button
def quit(self, event):
self.exit = True