def update(*args):
     self = args[0]
     width = args[1]
     height = args[2]
     Entity.update(self, width, height)
     self.animate()
     self.changed = False
示例#2
0
	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
示例#3
0
	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
示例#4
0
	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
示例#5
0
 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)
示例#6
0
 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])
示例#7
0
 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]
示例#8
0
 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]
示例#9
0
    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
示例#10
0
 def update(self, session):
     if Entity.update(self, session.worlds[session.activeWorld]) != (False, False):
         session.worlds[session.activeWorld].projectiles.remove(self)
         session.worlds[session.activeWorld].effects.append(Explosion(self.rect.center, 100))
     else:
         if self.momentum[0] > 0:
             self.momentum[0] += 1
         elif self.momentum[0] < 0:
             self.momentum[0] -= 1
示例#11
0
 def update(self, world):
     if Entity.update(self, world) != (False, False):
         world.projectiles.remove(self)
         world.effects.append(Explosion(self.rect.center, 100))
     else:
         if self.momentum[0] > 0:
             self.momentum[0] += 1
         elif self.momentum[0] < 0:
             self.momentum[0] -= 1
示例#12
0
 def update(self, session):
     prevMomentum = self.momentum[0]
     collisions = Entity.update(self, session.worlds[session.activeWorld])
     if collisions == (True, False):
         if not self.hasBounced:
             self.momentum[0] = -prevMomentum
             self.hasBounced = True
         else:
             session.worlds[session.activeWorld].projectiles.remove(self)
     elif collisions != (False, False):
         
         session.worlds[session.activeWorld].projectiles.remove(self)
示例#13
0
    def update(self, world):
        prevMomentum = self.momentum[0]
        collisions = Entity.update(self, world)
        if collisions == (True, False):
            if not self.hasBounced:
                self.momentum[0] = -prevMomentum
                self.hasBounced = True
            else:
                world.projectiles.remove(self)
        elif collisions != (False, False):

            world.projectiles.remove(self)
示例#14
0
	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()
示例#15
0
 def update(self):
     Entity.update(self)
     self.recalcVerts()
示例#16
0
    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
    
            
            
示例#17
0
	def update(self,t=0):
		Entity.update(self,t)
示例#18
0
文件: Laser.py 项目: jl111/Hack_2015
 def update(self):
     Entity.update(self)
     self.lifespan-=1
     if self.lifespan<=0:
         self.markedForDeletion = True
示例#19
0
	def update(self, t=0):
		Entity.update(self,t)
		if self.rect.right < 0:
			self.setReady()