當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。