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


Python Character.update方法代码示例

本文整理汇总了Python中Character.Character.update方法的典型用法代码示例。如果您正苦于以下问题:Python Character.update方法的具体用法?Python Character.update怎么用?Python Character.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Character.Character的用法示例。


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

示例1: update

# 需要导入模块: from Character import Character [as 别名]
# 或者: from Character.Character import update [as 别名]
    def update(self):
        Character.update(self)

        if self.attack_time > 0:
            self.image = self.attack_anim[self.attack_time//12]
            self.rect.x += 23
            self.attack_time -= 1
开发者ID:grace7190,项目名称:FAITHAGE,代码行数:9,代码来源:Cid.py

示例2: Game

# 需要导入模块: from Character import Character [as 别名]
# 或者: from Character.Character import update [as 别名]
class Game(object):

    def __init__(self):
        self.TITLE = "TEST (by zeeisl)"
        self.WIDTH = 800
        self.HEIGHT = 600
        
        self.controller = Controller()
        
        # game things
        self.char = Player("res//hero.png")
        self.map = Map()
        
        self.char1 = Character("res//hero.png", 100, 100, 32, 32)
        
    def key_input(self, event):
        self.controller.getButtonStates(event)
        self.char.key_input(event)
    
    def update(self, delta):
        self.map.update()
        self.char.update(self.char1)
        self.char1.update()
    
    def render(self, screen):
        self.map.render(screen)
        self.char.render(screen)
        self.char1.render(screen)
开发者ID:gia2api,项目名称:froscon,代码行数:30,代码来源:Game.py

示例3: __init__

# 需要导入模块: from Character import Character [as 别名]
# 或者: from Character.Character import update [as 别名]
class Game:
	"""Classe que representa o jogo"""
	def __init__(self):
		self.pilha = [] #pilha usada para o desfazer
		self.win = False #True caso tenha finalizado o mapa
		self.fase = 0 #id do mapa que está em jogo
		self.screen = None #Tela principal do jogo
		self.map = None #Map em jogo
		self.person = None #Personagem
			
	def init(self):
		"""Método para iniciar o jogo completo"""
		#inicia a janela 'invisível'
		self.screen = pygame.display.set_mode((1,1),NOFRAME,32)
		
		
		#cria uma instancia para o mapa
		self.map = Map(self.screen)
		pygame.display.set_icon(self.map._getGraf('!'))
		#cria personagem 
		self.person = Character(self.map,self.screen)

		#incia mapa self.fase
		self.mapInit()
		
		#Comeca o jogo
		self.screen = self.update()
		
		
		#laço principal do jogo
		while True:		
			for event in pygame.event.get():
				if event.type == QUIT:
					self.exit()
				if event.type == KEYDOWN:
					
					#movimentos do personagem
					if event.key == K_UP: #cima
						self.win,s = self.person.up()
						self.pushPilha(s)
					elif event.key == K_DOWN: #baixo
						self.win,s = self.person.down()
						self.pushPilha(s)
					elif event.key == K_LEFT: #esquerda
						self.win,s = self.person.left()
						self.pushPilha(s)
					elif event.key == K_RIGHT: #direita
						self.win,s = self.person.right()
						self.pushPilha(s)
						
					elif event.key == K_w: #ganha
						self.win = True
					elif event.key == K_r: #reincia o mapa
						self.mapInit()
						self.screen = self.update()
						
					elif event.key == K_z and pygame.key.get_mods() & KMOD_CTRL: #ctrl + z
						self.desfazer()
						self.screen = self.update()
				
			pygame.display.flip()
			if self.win:
				self.fase = (self.fase+1) % 16
				self.mapInit()
				self.screen = self.update()
	#end init
	
	
	def pushPilha(self,s):
		"""Método adiciona o último estado do jogo a pilha do desfazer. Adiciona no máximo 5 estados.
			obj.pushPilha(estado)
			estado ->  (['mapa'],(x,y))
		"""
		if len(self.pilha) > 5:
			del self.pilha[0]
		self.pilha.append(s)
		
	def popPilha(self):
		"""Método pop do desfazer"""
		if len(self.pilha) > 0:
			return self.pilha.pop()
		return None
		
	def desfazer(self):
		"""Recupera os estados salvos na pilha para desfazer o jogo"""
		ns = self.popPilha()
		if ns:
			self.map._str = ns[0]
			self.map._pos = ns[1]
			self.map.draw()
			
		
	def mapInit(self):
		"""Inicia um mapa"""
		#Marca estado com não vitorioso
		self.win = False
		#zera a pilha do desfazer
		self.pilha = []
		#define o mapa de inicio
		self.map.setID(self.fase)
#.........这里部分代码省略.........
开发者ID:clebertavares,项目名称:boxworld,代码行数:103,代码来源:Game.py

示例4: update

# 需要导入模块: from Character import Character [as 别名]
# 或者: from Character.Character import update [as 别名]
	def update(self, time, scene):
		if self.damageCooldown > 0:
			self.damageCooldown -= 15	
		Character.update(self, time, scene)
开发者ID:dgalaktionov,项目名称:Aleph,代码行数:6,代码来源:Enemy.py

示例5: update

# 需要导入模块: from Character import Character [as 别名]
# 或者: from Character.Character import update [as 别名]
 def update(self):
     Character.update(self)
     if self.attacking:
         self.attack_time += 1
开发者ID:grace7190,项目名称:FAITHAGE,代码行数:6,代码来源:Shana.py


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