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


Python Unit.update方法代码示例

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


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

示例1: update

# 需要导入模块: from unit import Unit [as 别名]
# 或者: from unit.Unit import update [as 别名]
	def update(self, time):
		self.applyForceFrom(-0.1, self.player.getPos())
		
		Unit.update(self, time)
		
		angle = math.atan2(self.player.getY() - self.getY(), \
							self.player.getX() - self.getX())
		self.setH(angle * 180 / math.pi)
开发者ID:tom-anesta,项目名称:team-conventions,代码行数:10,代码来源:droneEnemy.py

示例2: update

# 需要导入模块: from unit import Unit [as 别名]
# 或者: from unit.Unit import update [as 别名]
	def update(self, time):
		"""Run all major player operations each frame"""
		#check for weapon switch key
		if self.controlScheme.keyDown(SWITCH):
			if not self.switchPressed:
				self.switchWeapon()
				self.switchPressed = True
		else:
			self.switchPressed = False
		
		self.targetEnemy()
		
		#check for attack keys
		if self.controlScheme.keyDown(PUSH) and not self.controlScheme.keyDown(PULL):
			self.attack(PUSH, time)
			#include sound
			#self.electricSound.play()
			if self.electricSound.status() is not self.electricSound.PLAYING:
				#self.electricSound.setTime(self.electricSound.getTime())#reset to the current time and play it from there
				self.electricSound.setVolume(.1)
				self.electricSound.play()
		elif self.controlScheme.keyDown(PULL) and not self.controlScheme.keyDown(PUSH):
			self.attack(PULL, time)
			#include sound
			#self.magnetSound.setLoop(True)
			if self.magnetSound.status() is not self.magnetSound.PLAYING:
				#self.magnetSound.setTime(self.magnetSound.getTime())
				self.magnetSound.play()
				
		else:
			self.sustainedAttack = False
			#self.target = None
			if self.electricSound.status() == self.electricSound.PLAYING:
				#self.electricSound.setTime(float(0))#for some reason this is not resetting the time
				self.electricSound.stop()
			if self.magnetSound.status() == self.magnetSound.PLAYING:
				#self.magnetSound.setTime(float(0))#for some reason this is not resetting the time
				self.magnetSound.stop()
				
		#i am of the opinion that sound is somehow completely borked here
		
		#automatically regenerate energy
		self.energy += self.energyRegen * time
		self.energy = min(self.maxEnergy, self.energy)
		
		self.move(time)
		Unit.update(self, time)
开发者ID:tom-anesta,项目名称:team-conventions,代码行数:49,代码来源:player.py

示例3: update

# 需要导入模块: from unit import Unit [as 别名]
# 或者: from unit.Unit import update [as 别名]
	def update(self, time):
		Unit.update(self, time)
开发者ID:tom-anesta,项目名称:team-conventions,代码行数:4,代码来源:enemy.py

示例4:

# 需要导入模块: from unit import Unit [as 别名]
# 或者: from unit.Unit import update [as 别名]
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:
                sys.exit()
            elif event.key == pygame.K_z:
                trooper.action()
            elif event.key == pygame.K_UP:
                cursor.update('up')
            elif event.key == pygame.K_DOWN:
                cursor.update('down')
            elif event.key == pygame.K_LEFT:
                cursor.update('left')
            elif event.key == pygame.K_RIGHT:
                cursor.update('right')

    cursor_x, cursor_y = cursor.get_location()

    
    
    trooper.update( cursor_x, cursor_y )
    background.draw()        
    trooper.draw()
    cursor.draw()
    pygame.display.flip()

    moveflag = 0
    clock.tick(FPS)
开发者ID:ltsissykitty,项目名称:Game,代码行数:32,代码来源:Game.py


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