本文整理汇总了Python中Polygon.Polygon.draw方法的典型用法代码示例。如果您正苦于以下问题:Python Polygon.draw方法的具体用法?Python Polygon.draw怎么用?Python Polygon.draw使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Polygon.Polygon
的用法示例。
在下文中一共展示了Polygon.draw方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from Polygon import Polygon [as 别名]
# 或者: from Polygon.Polygon import draw [as 别名]
class Level:
"Level Base class"
def __init__(self,score,time):
"Initialises resources and start level"
self.background=pygame.image.load("sprites/sky.jpg")
self.background.convert() #for blitting more faster
self.screen=Constants.SCREEN
self.score = score
self.display_items = pygame.sprite.Group()
self.timeclock = GameTime((0.05,0.05),time)
self.display_items.add(self.timeclock,self.score)
self.time_speed=pygame.time.Clock()
self.time=0.0
self.quit = False
self.pause = False
self.start = False
self.completed = False
self.gameover = False
self.message = None
self.polygon=Polygon(self)
self.event_manager = EventManager(self)
self.on_enter()
def get_score_object(self):
return self.score
def set_score_object(self, score_object):
self.score = score_object
def on_enter(self):
self.screen.blit(self.background, (0, 0))
pygame.display.flip()
self.start = True
self.pause = True
self.timeclock.delete_timer()
self.message = MessageBox(self,3000)
self.display_items.add(self.message)
def on_exit(self):
self.display_items.remove(self.timeclock)
del self.polygon
del self.timeclock
if self.completed == False: #end of game, so music fadeout
pygame.mixer.music.fadeout(500)
f = FadeTransition(500,Constants.FADECOLOR,"to")
del f
def run(self):
while 1:
self.time+=self.time_speed.tick(Constants.FPS)
if self.gameover and (not self.pause):
self.pause = True
self.polygon.reset()
self.timeclock.delete_timer()
self.message = MessageBox(self,4000)
self.display_items.add(self.message)
if self.completed and (not self.pause):
self.pause = True
self.polygon.reset()
self.timeclock.delete_timer()
self.message = MessageBox(self,4000)
self.display_items.add(self.message)
self.polygon.set_alive(False)
self.polygon.reset()
if self.quit:
self.on_exit()
if self.gameover == True:
h = HighScores()
h.insert_HighScores(Constants.PLAYERNAME,str(self.score.get_score()))
hlist = HighScores().get_HighScores()
if len(hlist)<5 or self.score.get_score() > hlist[4].get_points():
h.flush()
pygame.event.clear()
highscores = HighScoresMenu("sprites/sky.jpg")
highscores.run()
return False
else:
return
self.event_manager.run()
self.screen.blit(self.background, (0, 0))
self.display_items.update()
self.display_items.draw(self.screen)
self.atoms.update()
self.atoms.draw(self.screen)
#.........这里部分代码省略.........