本文整理汇总了Python中Deck.Deck.populate方法的典型用法代码示例。如果您正苦于以下问题:Python Deck.populate方法的具体用法?Python Deck.populate怎么用?Python Deck.populate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Deck.Deck
的用法示例。
在下文中一共展示了Deck.populate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: DeckBuilder
# 需要导入模块: from Deck import Deck [as 别名]
# 或者: from Deck.Deck import populate [as 别名]
class DeckBuilder(window.Window):
is_event_handler = True #: enable pyglet's events
def __init__(self, *args, **kwargs):
platform = pyglet.window.get_platform()
display = platform.get_default_display()
screen = display.get_default_screen()
template = pyglet.gl.Config(double_buffer=True)
config = screen.get_best_config(template)
context = config.create_context(None)
window.Window.__init__(self, resizable=True, width=WINWIDTH, height=WINHEIGHT, caption="REZD:" + str(VERSION), context=context)
self.baseDeck = Deck() # used to lookup cards basically a reference instead of using a database. Basically don't remove / add cards
self.baseDeck.populate('assets/cardlist.xml')
self.newdeck = Deck()
self.selectedCard = None
self.runnerbaselist = []
self.corpbaselist = []
for card in self.baseDeck.deck:
if card.playertype == "Runner":
self.runnerbaselist.append(card.name)
else:
self.corpbaselist.append(card.name)
self.runnerbaselist.sort()
self.corpbaselist.sort()
# kytten stuff
self.theme = kytten.Theme(os.path.join(os.getcwd(), 'theme'), override={
"gui_color": [64, 128, 255, 255],
"font_size": 14
})
self.theme2 = kytten.Theme(self.theme, override={
"gui_color": [61, 111, 255, 255],
"font_size": 12
})
def main_loop(self):
self.batch = pyglet.graphics.Batch()
self.register_event_type('on_update')
pyglet.clock.schedule(self.update_kytten)
self.fps = pyglet.clock.ClockDisplay()
self.generateMenu()
while not self.has_exit: # main loop
#self.push_handlers(self.on_mouse_release)
self.clear()
clock.tick()
self.dispatch_events()
self.batch.draw()
self.drawSelectedCard()
self.drawNewDeckList()
self.fps.draw()
self.flip() #flip to the other opengl buffer
def drawNewDeckList(self):
count = 0
iter = 0
offsetx = self.width/2+200
offsety = self.height - 50
for card in self.newdeck.deck:
if count < 35:
pyglet.text.Label(card.name, font_name="Arial", font_size=14,x=offsetx,y=offsety-(count*25), color=(255,255,255,255)).draw()
else:
pyglet.text.Label(card.name, font_name="Arial", font_size=14,x=offsetx+250,y=offsety-(iter*25), color=(255,255,255,255)).draw()
iter = iter + 1
count = count + 1
total = len(self.newdeck.deck)
pyglet.text.Label("Total: " + str(total), font_name="Arial", font_size=16,x=self.width/2+100,y=self.height-50, color=(255,255,255,255)).draw()
def drawSelectedCard(self):
if self.selectedCard != None:
if self.selectedCard.sprite == None or self.selectedCard.image == None:
self.selectedCard.image = pyglet.image.load(self.selectedCard.imageloc)
self.selectedCard.sprite = Sprite(self.selectedCard.image) #, batch=self.batch2)
self.selectedCard.loadImg()
self.selectedCard.sprite.position = (self.width/4, self.height/2)
self.selectedCard.sprite.draw()
def update_kytten(self,dt):
self.dispatch_event('on_update', dt)
def on_select(self, choice):
if choice == "New Runner Deck":
self.create_new_runner_deck_dialog()
elif choice == "New Corporation Deck":
self.create_new_corp_deck_dialog()
elif choice == "Save":
self.create_save_dialog()
elif choice == "Load":
self.create_load_dialog()
elif choice == "Clear Deck":
self.newdeck.deck = []
self.selectedCard = None
elif choice == "Quit":
self.quitGame()
else:
if DEBUG: print "Unexpected menu selection: %s" % choice
def create_save_dialog(self):
#.........这里部分代码省略.........