当前位置: 首页>>代码示例>>Python>>正文


Python Avatar.Avatar类代码示例

本文整理汇总了Python中Avatar.Avatar的典型用法代码示例。如果您正苦于以下问题:Python Avatar类的具体用法?Python Avatar怎么用?Python Avatar使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Avatar类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: delete

 def delete(self):
     try:
         self.DistributedAvatar_deleted
     except:
         self.DistributedAvatar_deleted = 1
         Avatar.delete(self)
         DistributedActor.delete(self)
开发者ID:CalebSmith376,项目名称:src,代码行数:7,代码来源:DistributedAvatar.py

示例2: __init__

    def __init__(self, cr):

        try:
            return None
        except:
            self.DistributedAvatar_initialized = 1

        Avatar.__init__(self)
        DistributedActor.__init__(self, cr)
        self.hpText = None
        self.hp = None
        self.maxHp = None
开发者ID:ponyboy837,项目名称:Toontown-2003-Server,代码行数:12,代码来源:DistributedAvatar.py

示例3: setName

    def setName(self, name):
        try:
            self.node().setName('%s-%d' % (name, self.doId))
            self.gotName = 1
        except:
            pass

        return Avatar.setName(self, name)
开发者ID:CalebSmith376,项目名称:src,代码行数:8,代码来源:DistributedAvatar.py

示例4: setName

    def setName(self, name):
        try:
            self.node().setName(name)
            # NF
            # Appends name and ID, but why???
            #self.node().setName('%s-%d' % (name, self.doId))
            self.gotName = 1
        except:
            pass

        return Avatar.setName(self, name)
开发者ID:nate97,项目名称:src,代码行数:11,代码来源:DistributedAvatar.py

示例5: __init__

 def __init__(self,plyr,parent=None):
     #Bot __init__ is given starthealth, parent class
     self.bot = __import__(plyr).Bot(parent.STARTHEALTH,self)
     self.name = self.bot.getName()
     self.imagesDict = self.bot.getImages()
     self.parent = parent
     self.VERSION = self.parent.VERSION
     self.botmodifiers = BotModifiers(self.name)
     self.botstats = BotStats(self.name,self.botmodifiers)
     self.__position = [0,0]
     self.__ids = [0,0,0,0,0]
     self.resetStats()
     self.avatar = Avatar(self.name,self.__position,self.imagesDict)
开发者ID:lovi9573,项目名称:BotWars,代码行数:13,代码来源:Wrappers.py

示例6: getName

 def getName(self):
     return Avatar.getName(self)
开发者ID:CalebSmith376,项目名称:src,代码行数:2,代码来源:DistributedAvatar.py

示例7: TxtButton

            b = TxtButton(bot,(x,0),self.notificationsGroup)
            b.setFontSize(32)
            self.botsDict[bot]= b
            self.notificationsGroup.add(self.botsDict[bot])
            x +=75
  
if __name__ == "__main__":
    import Queue
    gui = ServerGui()
    q = Queue.Queue()
    
    #Create a list of avatars to pull from
    avs = []
    for b in range(0,21):
        a = "av" + str(b)
        av = Avatar(a,(random.randint(0,800),random.randint(0,600)))
        print "init queuing: ", av
        av.stance = Stance("Fire",random.choice(("Burning","Piercing")))
        avs.append(av)
    i = 0
    # Fill the queue with init requests
    for l in range(0,7):
        q.put( pickle.dumps( ["init",-1,[avs[i],avs[i+1],avs[i+2]]] ) )
        i = i +3
        
    #Fiill the queue with updateBot requests
    av = Avatar("av19", [200,200])
    av.stance = Stance("Fire",random.choice(("Burning","Piercing")))
    #av.heal = random.choice((True,False))
    q.put( pickle.dumps( ["updateBot", -1, [av]]))    
    p = [500,300]
开发者ID:lovi9573,项目名称:BotWars,代码行数:31,代码来源:gui.py

示例8: BotWrapper

class BotWrapper(object):
    """Provides access to user bot methods and keeps meta-data for user bots"""
    
    def __init__(self,plyr,parent=None):
        #Bot __init__ is given starthealth, parent class
        self.bot = __import__(plyr).Bot(parent.STARTHEALTH,self)
        self.name = self.bot.getName()
        self.imagesDict = self.bot.getImages()
        self.parent = parent
        self.VERSION = self.parent.VERSION
        self.botmodifiers = BotModifiers(self.name)
        self.botstats = BotStats(self.name,self.botmodifiers)
        self.__position = [0,0]
        self.__ids = [0,0,0,0,0]
        self.resetStats()
        self.avatar = Avatar(self.name,self.__position,self.imagesDict)
        
    #def addEnemy(self,enemy):
    #    self.bot.addEnemy(enemy)
        
    def addPoints(self,n):
        self.botstats.add("points",n)
    
    #args: Damage object
    #Return: integer health
    def adjustHealth(self,damage):
        return self.bot.adjustHealth(damage)
    
    #args: string command
    #Return: none
    #executes user inputted commands
    def command(self,command):
        print "COMMAND: ",command," , made it to the botwrapper of: ",self.name
        self.bot.command(command)       
    #args integer round number
    #Return: none    
    def endRound(self,roundnumber):
        self.bot.endRound(roundnumber)
        if self.bot.getHealth() <= 0:
            self.__stance = "OUT!!"
    
    #args: none
    #return: none        
    def endGame(self):
        self.botstats.endgame()
        mod = self.botstats.getNextModifier()
        while mod:
            self.botmodifiers.adjustModifier(*mod)
            mod = self.botstats.getNextModifier()
            
    def getAvatar(self):
        self.avatar.stance = self.getStance()
        self.avatar.setPosition(self.__position)
        self.avatar.health = self.getHealth()
        self.avatar.enemies = self.getEnemies()
        self.avatar.modifiers = self.botmodifiers.getModifiers(True)
        try:
            self.avatar.color = self.bot.getColor()
        except AttributeError:
            self.avatar.color = (255,255,255)
        return copy.copy(self.avatar)
    
    #args: none
    #Return: list of enemies' names    
    def getEnemies(self):
        return self.bot.getEnemies()
    
    #args: none
    #Return: integer health    
    def getHealth(self):
        return self.bot.getHealth()
    
    
    def getIds(self):
        return self.__ids
    
    #args: none
    #Return: float angle to look    
    def getLookDirection(self):
        return self.bot.getLookDirection()
 
    
    def getModifier(self,name):
        return self.botmodifiers.getModifier(name)
    
    def getMoveDirection(self):
        return self.bot.getMoveDirection()
    
    #args: none
    #Return: string name
    def getName(self):
        return self.name
    
    def getPosition(self):
        return self.__position

    #args: none
    #Return: Stance object
    def getStance(self):
        if self.__stance:
#.........这里部分代码省略.........
开发者ID:lovi9573,项目名称:BotWars,代码行数:101,代码来源:Wrappers.py

示例9: main

def main():
	pygame.init()
	pygame.font.init()

	size = width, height = 800,600
	screen = pygame.display.set_mode(size)
	pygame.display.set_caption("Juego")
	clock = pygame.time.Clock()
	gameState =  GameState()

	#creating all sprites
	allSprites = pygame.sprite.Group()
	enemies =  pygame.sprite.Group()
	players = pygame.sprite.Group()

	#creating all game objects
	background =  BackgroundVScrolling(width,height)
	avatar = Avatar(width,height)
	scoreboard = ScoreBoard(width,height)

	for i in range(5):
		enemy =  Enemy((width,height))
		enemy.randomTopPosition()
		enemy.randomSpeed(x=0)
		enemy.moving = True
		enemies.add(enemy)
		allSprites.add(enemy)

	allSprites.add(avatar)
	players.add(avatar)
	avatar.allSprites = allSprites

	#Game loop
	while 1:
		for event in pygame.event.get():
			if event.type == pygame.QUIT: sys.exit()
			if event.type == pygame.KEYDOWN:
				if event.key == pygame.K_ESCAPE:
					gameState.togglePause()	
		screen.fill(colors["black"])
		milliseconds = clock.tick()  # milliseconds passed since last frame
		gameState.update()

		#these are not a sprites properly
		#Other shapes or sprites
		background.draw(screen,gameState)	

		#sprites
		players.update(gameState)
		enemies.update(gameState)

		colisionList = pygame.sprite.spritecollide(avatar, enemies, False)
		if avatar.blink == False:
			for enemy in colisionList:
				enemy.randomTopPosition()
				enemy.randomSpeed()
				enemies.add(enemy)
				allSprites.add(enemy)
				avatar.startBlink()
				gameState.lives -=1

		allSprites.draw(screen) #draws all sprites
		scoreboard.draw(screen,gameState)
		pygame.display.flip()
开发者ID:adrfrank,项目名称:python_tarea_10,代码行数:64,代码来源:main.py


注:本文中的Avatar.Avatar类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。