本文整理汇总了Python中inventory.Inventory.draw方法的典型用法代码示例。如果您正苦于以下问题:Python Inventory.draw方法的具体用法?Python Inventory.draw怎么用?Python Inventory.draw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类inventory.Inventory
的用法示例。
在下文中一共展示了Inventory.draw方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Game
# 需要导入模块: from inventory import Inventory [as 别名]
# 或者: from inventory.Inventory import draw [as 别名]
class Game():
def __init__(self, gru_file=None):
self.compiler = Compiler()
if gru_file:
self.stream = self.compiler.decompile(gru_file)
else:
self.stream = self.compiler.compile(None)
self.metadata = self.stream.metadata
self.flags = Flags(self.stream)
self.wheel = Wheel(config)
self.title = Title(config)
self.inventory = Inventory(self.stream, self.flags, config)
self.combiner = Combiner(self.stream, self.flags, self.inventory)
self.page = Page(config, self.flags, self.combiner, self.inventory)
self.state = State(self.stream, self.flags, self.inventory, self.wheel, self.combiner, self.title, self.page)
if self.metadata.has_key("start"):
start = self.metadata["start"]
self.state.update(start)
else:
self.state.update("start")
def draw(self, tick):
self.inventory.draw()
self.wheel.draw()
self.title.draw()
self.page.draw(tick)
示例2: Team
# 需要导入模块: from inventory import Inventory [as 别名]
# 或者: from inventory.Inventory import draw [as 别名]
class Team(pygame.sprite.Group):
"""
This is the team class, which is the owner of a group of snails.
Several snails together form a team.
"""
def __init__(self, name):
"""
Constructor to create a team of snails
@param name: The name of the team, which will displayed in various locations
@return: Team object.
"""
pygame.sprite.Group.__init__(self)
self.name = name
""" The name of the team"""
self.hasTurn = False
self.isAlive = True
self.orderedSnailList = []
self.gravity_direction = None
self.inventory = Inventory(self.name)
cannon = Cannon("Cannon", 20)
balloonLauncher = BalloonLauncher("Balloon", 30)
self.inventory.addWeapon(balloonLauncher)
self.inventory.addWeapon(cannon)
self.active_weapon = cannon
self.colorIndex = None
def update(self, *args):
"""
Call the update of all the objects the team currently manages, this can include weapon, inventory and snails.
@param *args: Pass all the arguments to the the update of the sprites.
"""
pygame.sprite.Group.update(self,*args)
self.checkAlive()
if(self.inventory.visible and self.hasTurn):
tempWeapon = self.inventory.update(args[0])
if(not None == tempWeapon):
self.active_weapon = tempWeapon
if(not None == self.active_weapon):
self.active_weapon.update(*args)
def draw(self, surface):
"""
Draw all the objects the team currently manages, this can include weapon, inventory and snails.
@param surface: This is the surface created in the game class
"""
for sprite in self:
sprite.draw(surface)
#draw the inventory if team has turn
if(self.hasTurn):
self.active_weapon.draw(surface)
self.inventory.draw(surface)
if self.hasTurn and not None == self.active_weapon:
for snail in self.orderedSnailList:
if snail.hasTurn == True:
self.active_weapon.snail_rect = snail.rect
def addSnails(self, numberOfSnails):
"""
Add a number of snails to the teams, this creates snails objects.
"""
for i in range(0, numberOfSnails):
snail = Snail(self)
snail.id = i
self.add(snail)
self.orderedSnailList.append(snail)
self.orderedSnailList[len(self.orderedSnailList) - 1].hasTurn = True
def setGravity(self, direction):
"""
Set the gravity direction for the team
@param direction: An integer representing a value. Use enums.Direction.
"""
self.gravity_direction = direction
for s in self.sprites():
s.gravity_direction = direction
def setTeamImage(self, imageNumber):
"""
sets the image of the team using a number
the sprite's folder contains snails with 4 different colors
the number given will be used to select a different snail
"""
self.colorIndex = imageNumber
#.........这里部分代码省略.........