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


Python Entity.update方法代码示例

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


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

示例1: update

# 需要导入模块: from Entity import Entity [as 别名]
# 或者: from Entity.Entity import update [as 别名]
 def update(*args):
     self = args[0]
     width = args[1]
     height = args[2]
     Entity.update(self, width, height)
     self.animate()
     self.changed = False
开发者ID:KRHS-GameProgramming-2014,项目名称:Shamwow,代码行数:9,代码来源:PowerDownPotato.py

示例2: update

# 需要导入模块: from Entity import Entity [as 别名]
# 或者: from Entity.Entity import update [as 别名]
	def update(self,t=0):
		Entity.update(self,t)
		#print t, self.rect.topleft, self._speed 
		if self.jumping:
			# if the jumping flag is true,
			# call the jump function
			self.setSpeed('x',-14.0)
			self.jumping = False
		else:
			self.setSpeed('x',self._speed[1]+t/50.0)	
			if self.rect.top >= 230: # if you hit the top, reset the vel so it
				self.setSpeed('x',0.0) # doesn't get stuck up at the top

		# limit duration of post damage invincibility (2500 ms)
		if self._invincible_time > 0:
			self._invincible_time -= t
			
			# On average, turn invisible for every other frame
			if ((self._invincible_time /100)%2) == 0:
				self.image = self._invisible_pic
			else:
				self.image = self._images[0]
		
		if self.rect.left < 0:
			self.rect.left = 0
		elif self.rect.right > 930:
			self.rect.right = 930
开发者ID:rokthewok,项目名称:ECE2524-Final-Project,代码行数:29,代码来源:player.py

示例3: update

# 需要导入模块: from Entity import Entity [as 别名]
# 或者: from Entity.Entity import update [as 别名]
	def update(self,t=0):
		Entity.update(self,t)
		#print t, self.rect.topleft, self._speed 
		if self.jumping:
			# if the jumping flag is true,
			# call the jump function
			self.setSpeed('x',-14.0)
			self.jumping = False
		else:
			self.can_jump = True
			self.setSpeed('x',self._speed[1]+t/50.0)	
			if self.rect.top >= 230:
				self.setSpeed('x',0.0)

		# limit duration of post damage invincibility (2500 ms)
		if self._invincible == True:
			if self._invincible_time < 2500:
				self._invincible_time += t
				if ((self._invincible_time /100)%2) == 0:
					self.image = self._invisible_pic
				else:
					self.image = self._images[0]
			else:
				self._invincible = False
				self._invincible_time = 0
开发者ID:cabotzj,项目名称:ECE2524-Final-Project,代码行数:27,代码来源:player.py

示例4: update

# 需要导入模块: from Entity import Entity [as 别名]
# 或者: from Entity.Entity import update [as 别名]
	def update(self,t=0):
		Entity.update(self,t)
		if self.rect.right < 0:
			self._wrap_count += 2
			self.rect.left = 1024
			self.rect.top = 300*random()
			self.setSpeed(-8.0*random()-10.0-self._wrap_count*random(),0.0)
		print self._speed
开发者ID:cabotzj,项目名称:ECE2524-Final-Project,代码行数:10,代码来源:enemy.py

示例5: update

# 需要导入模块: from Entity import Entity [as 别名]
# 或者: from Entity.Entity import update [as 别名]
 def update(self, world):
     if self.impactDestroy:
         collisions = Entity.update(self, world)
         for i in collisions:
             if i:
                 world.projectiles.remove(self)
         return collisions
     else:
         return Entity.update(self, world)
开发者ID:CHAZICLE,项目名称:supercram,代码行数:11,代码来源:Projectile.py

示例6: update

# 需要导入模块: from Entity import Entity [as 别名]
# 或者: from Entity.Entity import update [as 别名]
 def update(self, session):    
     if self.impactDestroy:
         collisions = Entity.update(self, session.worlds[session.activeWorld])
         for i in collisions:
             if i:
                 session.worlds[session.activeWorld].projectiles.remove(self)
         return collisions
     else:
         return Entity.update(self, session.worlds[session.activeWorld])
开发者ID:SuperCram,项目名称:supercram,代码行数:11,代码来源:Projectile.py

示例7: update

# 需要导入模块: from Entity import Entity [as 别名]
# 或者: from Entity.Entity import update [as 别名]
 def update(self, world):
     Entity.update(self, world)
     for p in world.players:
         if self.rect.colliderect(p.rect):
             p.weapon = self.contents
             newWep = random.choice(const.weapons)
             while newWep == p.weapon:
                 newWep = random.choice(const.weapons)
             self.contents = newWep
             self.momentum = [0,0]
             ##########################################
             self.rect.topleft = [500,200]
开发者ID:CHAZICLE,项目名称:supercram,代码行数:14,代码来源:Crate.py

示例8: update

# 需要导入模块: from Entity import Entity [as 别名]
# 或者: from Entity.Entity import update [as 别名]
 def update(self, session):
     Entity.update(self, session.worlds[session.activeWorld])
     for p in session.worlds[session.activeWorld].players:
         if self.rect.colliderect(p.rect):
             p.weapon = self.contents
             newWep = random.choice(const.weapons)
             while newWep == p.weapon:
                 newWep = random.choice(const.weapons)
             self.contents = newWep
             self.momentum = [0,0]
             zone = random.choice(session.worlds[session.activeWorld].crateSpawnZones)
             x = random.randint(zone[0], zone[1])
             y = random.randint(zone[2], zone[3])
             self.rect.center = [x,y]
开发者ID:SuperCram,项目名称:supercram,代码行数:16,代码来源:Crate.py

示例9: update

# 需要导入模块: from Entity import Entity [as 别名]
# 或者: from Entity.Entity import update [as 别名]
    def update(self, world):
        
#Check if colliding with a projectile ie has been hit, and deals damage accordingly
        for proj in world.projectiles:
            if self.rect.colliderect(proj.rect):
                proj.hitEnemy(world)
                world.projectiles.remove(proj)
                self.health -= proj.damage

#Kill if health <= 0
        self.image.fill((255,0,0))
        if self.health <= 0:
############################
            world.enemies.remove(self)

#Call superclass update, returns true if enemy has hit a wall and reverses direction of travel
        if Entity.update(self, world)[0]:
            self.facingRight = not self.facingRight

#Select speed, dir based on facingRight and rage
        if self.facingRight and not self.rage:
            self.momentum[0] = const.enemySpeed
        elif self.facingRight:
            self.momentum[0] = const.rageSpeed
        elif not self.facingRight and not self.rage:
            self.momentum[0] = -const.enemySpeed
        elif not self.facingRight and self.rage:
            self.momentum[0] = -const.rageSpeed
        else:
            self.momentum[1] = 0
开发者ID:CHAZICLE,项目名称:supercram,代码行数:32,代码来源:Enemy.py

示例10: update

# 需要导入模块: from Entity import Entity [as 别名]
# 或者: from Entity.Entity import update [as 别名]
	def update(self, t=0):
		Entity.update(self,t)
		#if power up goes off left side of screen, setReady and send next random power up
		if self.rect.right < 0:
			self.setReady()
开发者ID:rokthewok,项目名称:ECE2524-Final-Project,代码行数:7,代码来源:powerup.py

示例11: update

# 需要导入模块: from Entity import Entity [as 别名]
# 或者: from Entity.Entity import update [as 别名]
 def update(self):
     Entity.update(self)
     self.recalcVerts()
开发者ID:jl111,项目名称:Hack_2015,代码行数:5,代码来源:Asteroid.py

示例12: update

# 需要导入模块: from Entity import Entity [as 别名]
# 或者: from Entity.Entity import update [as 别名]
    def update(self, session):
####
    
        for e in session.worlds[session.activeWorld].eList:
            if e.type == KEYDOWN:
                if e.key not in self.keysDown:
                    self.keysDown.append(e.key)
            elif e.type == KEYUP:
                if e.key in self.keysDown:
                    self.keysDown.remove(e.key)

    #Check if on ground
        self.onGround = self.checkOnGround(session.worlds[session.activeWorld].clips)
       
    #Get Left/Right keys
        if K_LEFT in self.keysDown: l = True
        else: l = False
        if K_RIGHT in self.keysDown: r = True
        else: r = False

    #Jumping
        #If on ground and jump key hit, start jump
        if self.onGround and (K_UP in self.keysDown or K_z in self.keysDown):
            self.jumping = True
            self.jumpStart = self.rect.bottom
        if self.jumping:
        #Check if below min jump height
            if self.rect.bottom >= (self.jumpStart - (const.minJump)):
                self.momentum[1] = -const.playerJumpSpeed
        #Check if below max jump height
            elif self.rect.bottom > (self.jumpStart - const.maxJump) and (K_UP in self.keysDown or K_z in self.keysDown):
                self.momentum[1] = -const.playerJumpSpeed
            else:
                self.jumping = False      
        
    #Horizontal movement
        if l and r:
            self.momentum[0] = 0
        elif l:
            self.momentum[0] = -const.playerSpeed
        elif r:
            self.momentum[0] = const.playerSpeed
        else:
            self.momentum[0] = 0
            
    #Superclass - updates position, checks collisions
        collisions = Entity.update(self, session.worlds[session.activeWorld])
        if self.jumping and collisions[1]:
            self.jumping = False

        if session.multiplayer:
            pass   
        else:                
    #Shooting
            if self.weapon.rapidFire == False:
                for e in session.worlds[session.activeWorld].eList:
                    if e.type == KEYDOWN and e.key == K_x:
                        self.weapon.shoot(self, session.worlds[session.activeWorld])
            else:
                if K_x in self.keysDown:
                    self.weapon.shoot(self, session.worlds[session.activeWorld])

    #Check if collided with any enemies
            for enemy in session.worlds[session.activeWorld].enemies:
                if self.rect.colliderect(enemy.rect):
    ###############################
                    self.rect.topleft = (400, 100)
                    self.momentum = [0,0]
    
    #Check if collided with any playerIntact projectiles
            for proj in session.worlds[session.activeWorld].projectiles:
                if proj.playerInteract and self.rect.colliderect(proj.rect):
    ###############################
                    self.rect.topleft = (400, 100)
                    self.momentum = [0,0]
    
    #Update facing direction
        if self.momentum[0] > 0:
            self.facingRight = True
        elif self.momentum[0] < 0:
            self.facingRight = False
    
            
            
开发者ID:SuperCram,项目名称:supercram,代码行数:83,代码来源:Player.py

示例13: update

# 需要导入模块: from Entity import Entity [as 别名]
# 或者: from Entity.Entity import update [as 别名]
	def update(self,t=0):
		Entity.update(self,t)
开发者ID:cabotzj,项目名称:ECE2524-Final-Project,代码行数:4,代码来源:health.py

示例14: update

# 需要导入模块: from Entity import Entity [as 别名]
# 或者: from Entity.Entity import update [as 别名]
 def update(self):
     Entity.update(self)
     self.lifespan-=1
     if self.lifespan<=0:
         self.markedForDeletion = True
开发者ID:jl111,项目名称:Hack_2015,代码行数:7,代码来源:Laser.py


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