コード例 #1
0
 def shieldcheck(self):
     if self.duration == 1:
         coll = pygame.sprite.spritecollide(self, ShieldGroup.shields, False, collide_meteor_shield)
         for shield in coll:
             if shield.kind == "cigar":
                 Sprite.kill(self)
                 pygame.draw.line(pygame.display.get_surface(), (255,0,0), self.rect.center, shield.rect.center, 3)
コード例 #2
0
ファイル: main.py プロジェクト: jackerma/CS112-Spring2012
    def update(self, dt):
        vx = self.vx
        vy = self.vy

        dt /= 1000.0
        dx = int(self.vx * dt)
        dy = int(self.vy * dt)
        self.rect.x += dx
        self.rect.y += dy

        if self.rect.left < self.bounds.left or self.rect.right > self.bounds.right:
            self.vx = -self.vx
            self.rect.x += -2 * dx

        if self.rect.top < self.bounds.top :
            self.vy = -self.vy
            self.rect.y += -2 * dy
        if self.rect.top > self.bounds.bottom+20:
            Sprite.kill(self)
            death_sub()

        if vx != self.vx or vy != self.vy:
            if vx != self.vx:
                vx = self.vx
                vy = -vy
            else:
                vx = -vx
                vy = self.vy
コード例 #3
0
ファイル: main.py プロジェクト: jwsander/CS112-Spring2012
    def update(self, dt):
        vx = self.vx
        vy = self.vy
        if randrange(60) == 0:
            self.vx = -self.vx

        if self.vx > 0:
            self.image = self.orig_image
        else:
            self.image = self.flipped_image

        dt /= 1000.0
        dx = int(self.vx * dt)
        dy = int(self.vy * dt)
        self.rect.x += dx
        self.rect.y += dy

        if self.rect.left < self.bounds.left or self.rect.right > self.bounds.right:
            self.vx = -self.vx
            self.rect.x += -2 * dx

        if self.rect.top < self.bounds.top:
            self.vy = -self.vy
            self.rect.y += -2 * dy
        if self.rect.top > self.bounds.bottom + 20:
            Sprite.kill(self)
            death_sub()

        if vx != self.vx or vy != self.vy:
            if vx != self.vx:
                vx = self.vx
                vy = -vy
            else:
                vx = -vx
                vy = self.vy
コード例 #4
0
ファイル: sprites.py プロジェクト: kakila/cavemen
    def update(self, current_time):
        '''The skeleton has three states (not implemented through a state machine): 
          * In free fall without touching any floor
          * Over some floor, being slowly buried. It scares the cavemen.
          * Deep into the ground. When the skeleton reaches this state it stops being a sprite and it becomes an fixed image. It also stops scaring the Cavemen.'''
        if hasattr(self,'current_floor'):
            #If it is here, then it means it is over some floor.
            if self.get_position()[1]<self.current_floor.get_position()[1]+5:
                #If the skeleton is not deep enough, it gets burried at a fixed rate
                if current_time>self.last_update+self.update_interval:
                    self.set_position([self.get_position()[0], self.get_position()[1]+1])
                    self.last_update=current_time
                    return
            else:
                #if the skeleton is deep enough, it stops scaring Cavemen and becomes a fixed image instead of a sprite.
                self.current_floor.death_toll-=1
                self.current_floor.image.blit(self.image, [self.rect[0]-self.current_floor.rect[0], self.rect[1]-self.current_floor.rect[1]])
                del self.body
                Basic_Actor.level.with_body.remove(self)
                Basic_Actor.level.all.remove(self)
                Basic_Actor.level.visible.remove(self)
                Sprite.kill(self)
        elif hasattr(self, 'body') and (self.body.get_velocity()-vec2d(0,0)).get_length()<0.01:
            #If the skeleton has a physical body and is not falling then it must mean it is over a floor, and gets attached to it, increasing its death_toll. It also removes its body so the physics engine doesn't affect it anymore. 
            floor_collisions=Basic_Actor.State_Machine.floor_collisions
            collision_data=floor_collisions.pop(self.id, None)
            if collision_data is None: return
            self.current_floor=self.get_sprite(collision_data[1])
            space=Basic_Actor.level.space
            space.remove_shape(self.shape)
            space.remove_body(self.body)

            self.current_floor.death_toll+=1
        else:
            return
コード例 #5
0
 def checkshield(self):
     coll = pygame.sprite.spritecollide(self, ShieldGroup.shields, False, collide_meteor_shield)
     for shield in coll:
         for shield in coll:
         #Turn into objects later on.
             if shield.kind == "cigar":
                 Sprite.kill(self)
                 pygame.draw.line(pygame.display.get_surface(), (255,0,0), self.rect.center, shield.rect.center, 3)
コード例 #6
0
ファイル: shmup.py プロジェクト: Werefriend/CS112-Spring2012
    def kill(self):
        burger2 = Burger(self.rect.x, self.rect.y, self.bounds)
        burger3 = Burger(self.rect.x, self.rect.y, self.bounds)

        for group in self.groups():
            group.add(burger2)
            group.add(burger3)

        Sprite.kill(self)
コード例 #7
0
    def kill(self):
        #self.explode = Surface(self.size)
        if self.kind == "rock":
            ImpactGroup.impacts.add(Impact (self.rect.center, self.bounds, 4, self.kind))
        if self.kind == "ice":
            ImpactGroup.impacts.add(IceImpact (self.rect.center, self.bounds, 30, self.kind, 0))
            ImpactGroup.impacts.add(IceImpact (self.rect.center, self.bounds, 30, self.kind, 1))
            ImpactGroup.impacts.add(IceImpact (self.rect.center, self.bounds, 30, self.kind, 2))
            ImpactGroup.impacts.add(IceImpact (self.rect.center, self.bounds, 30, self.kind, 3))

            
        Sprite.kill(self)
コード例 #8
0
 def update(self):
     enemies = p.sprite.spritecollide(self, self.__opposite__, False)
     if not enemies or all (type(enemy) == Bullet for enemy in enemies):
         switcher = {
             'l': 4,
             'r': -4
         }
         self.rect.move_ip(switcher.get(self.getSide()), 0)
     else:
         enemy = p.sprite.spritecollideany(self, self.__opposite__)
         enemy.setLife(enemy.getLife() - self.__dmg__)
         spt.kill(self)
コード例 #9
0
ファイル: ships.py プロジェクト: jwsander/CS112-Spring2012
    def update(self, dt):
        dt /= 1000.0
        dx = int(self.vx * dt)
        dy = int(self.vy * dt)
        self.rect.x += dx
        self.rect.y += dy

        if self.rect.left < self.bounds.left or self.rect.right > self.bounds.right:
            self.vx = -self.vx
            self.rect.x += -2 * dx

        if self.rect.top < self.bounds.top :
            self.vy = -self.vy
            self.rect.y += -2 * dy
        if self.rect.top > self.bounds.bottom+20:
            Sprite.kill(self)
コード例 #10
0
ファイル: main.py プロジェクト: jwsander/CS112-Spring2012
    def update(self):
        dt = min(self.min_dt, self.clock.get_time())
        self.ships.update(dt)
        self.xplos.update(dt)
        self.bullets.update(dt)

        for xplo in self.xplos:
            pygame.sprite.spritecollide(xplo, self.ships, True, collide_xplo_ship)

        for bullet in self.bullets:
            for ship in self.ships:
                if pygame.sprite.collide_rect(bullet, ship):
                    ship.kill()
                    Sprite.kill(bullet)
                    self.score += 1

        for spawner in self.spawners:
            spawner.update(dt)
コード例 #11
0
ファイル: sprites.py プロジェクト: ezequielp/cavemen
    def update(self, current_time):
        '''The skeleton has three states (not implemented through a state machine): 
          * In free fall without touching any floor
          * Over some floor, being slowly buried. It scares the cavemen.
          * Deep into the ground. When the skeleton reaches this state it stops being a sprite and it becomes an fixed image. It also stops scaring the Cavemen.'''
        if hasattr(self, 'current_floor'):
            #If it is here, then it means it is over some floor.
            if self.get_position(
            )[1] < self.current_floor.get_position()[1] + 5:
                #If the skeleton is not deep enough, it gets burried at a fixed rate
                if current_time > self.last_update + self.update_interval:
                    self.set_position(
                        [self.get_position()[0],
                         self.get_position()[1] + 1])
                    self.last_update = current_time
                    return
            else:
                #if the skeleton is deep enough, it stops scaring Cavemen and becomes a fixed image instead of a sprite.
                self.current_floor.death_toll -= 1
                self.current_floor.image.blit(self.image, [
                    self.rect[0] - self.current_floor.rect[0],
                    self.rect[1] - self.current_floor.rect[1]
                ])
                del self.body
                Basic_Actor.level.with_body.remove(self)
                Basic_Actor.level.all.remove(self)
                Basic_Actor.level.visible.remove(self)
                Sprite.kill(self)
        elif hasattr(self, 'body') and (self.body.get_velocity() -
                                        vec2d(0, 0)).get_length() < 0.01:
            #If the skeleton has a physical body and is not falling then it must mean it is over a floor, and gets attached to it, increasing its death_toll. It also removes its body so the physics engine doesn't affect it anymore.
            floor_collisions = Basic_Actor.State_Machine.floor_collisions
            collision_data = floor_collisions.pop(self.id, None)
            if collision_data is None: return
            self.current_floor = self.get_sprite(collision_data[1])
            space = Basic_Actor.level.space
            space.remove_shape(self.shape)
            space.remove_body(self.body)

            self.current_floor.death_toll += 1
        else:
            return
コード例 #12
0
 def kill(self):
     #self.explode = Surface(self.size)          
     Sprite.kill(self)
コード例 #13
0
 def kill(self):
     ImpactGroup.impacts.add(FireImpact (self.rect.center, self.bounds, 60, self.kind))
     Sprite.kill(self)
コード例 #14
0
 def kill(self):
     ImpactGroup.impacts.add(RadiationImpact (self.rect.center, self.bounds, 300, self.kind))
     Sprite.kill(self)
コード例 #15
0
ファイル: hotspot.py プロジェクト: ag-python/pyzzle
 def kill(self):
     del Hotspot.rows[self.id]
     Sprite.kill(self)
コード例 #16
0
 def kill(self):    
     Sprite.kill(self)
コード例 #17
0
ファイル: event.py プロジェクト: manucouto1/PyGame_5Gatos
 def kill(self):
     self.observer.activate_maniac()
     Sprite.kill(self)
コード例 #18
0
 def kill(self):
     log.debug('stripe getting killed')
     Sprite.kill(self)
     controller = mvcState.GetController()
     controller.gameEventListeners.remove(self)
コード例 #19
0
 def kill(self):
     Game.current.play("bust.wav")
     Sprite.kill(self)
コード例 #20
0
 def remove_from_groups(self):
     Sprite.kill(self)
コード例 #21
0
 def kill(self):
     neighborhood.ignore(self)
     Sprite.kill(self)
コード例 #22
0
 def kill(self):
     Sprite.kill(self)
コード例 #23
0
ファイル: character.py プロジェクト: ceronman/twsitemall
	def on_death(self):
		self.world_map.tiles[self.tile_index] = None
		Sprite.kill(self)
コード例 #24
0
ファイル: character.py プロジェクト: ceronman/twsitemall
	def on_death(self):
		Sprite.kill(self)
コード例 #25
0
 def kill(self):
     Sprite.kill(self)
     Ship.death_count.inc()
     return self.explosion_type(self)
コード例 #26
0
 def kill(self):
     Sprite.kill(self)
     controller = mvcState.GetController()
     controller.gameEventListeners.remove(self)
     controller.mouseListeners.remove(self)
コード例 #27
0
 def update(self):
     if self.__life__ < 1:
         spt.kill(self)
コード例 #28
0
ファイル: event.py プロジェクト: manucouto1/PyGame_5Gatos
 def kill(self):
     self.observer.add_point()
     Sprite.kill(self)
コード例 #29
0
ファイル: event.py プロジェクト: manucouto1/PyGame_5Gatos
 def kill(self):
     self.observer.add_life()
     Sprite.kill(self)
コード例 #30
0
ファイル: objects.py プロジェクト: sjbrown/steam_jet_blower
	def kill( self ): 
		log.debug( 'stripe getting killed' )
		Sprite.kill(self)
		controller = mvcState.GetController()
		controller.gameEventListeners.remove(self)
コード例 #31
0
 def kill(self):
     ImpactGroup.impacts.add(IceImpact (self.rect.center, self.bounds, 30, self.kind, 0))
     ImpactGroup.impacts.add(IceImpact (self.rect.center, self.bounds, 30, self.kind, 1))
     ImpactGroup.impacts.add(IceImpact (self.rect.center, self.bounds, 30, self.kind, 2))
     ImpactGroup.impacts.add(IceImpact (self.rect.center, self.bounds, 30, self.kind, 3))
     Sprite.kill(self)
コード例 #32
0
 def kill(self):
     ImpactGroup.impacts.add(RockImpact (self.rect.center, self.bounds, 4, self.kind))
     Sprite.kill(self)
コード例 #33
0
ファイル: objects.py プロジェクト: sjbrown/steam_jet_blower
	def kill( self ):
		Sprite.kill( self )
		controller = mvcState.GetController()
		controller.gameEventListeners.remove( self )
		controller.mouseListeners.remove( self )
コード例 #34
0
ファイル: main.py プロジェクト: jlevey3/CS112-Spring2012
 def kill(self):
     xplo = self.explosion_type(self.rect.center, self.explosion_radius)
     Explosion.group.add(xplo)
     Sprite.kill(self)
コード例 #35
0
 def kill(self):
     xplo = self.explosion_type(self.rect.center, self.explosion_radius)
     Explosion.group.add(xplo)
     Sprite.kill(self)
コード例 #36
0
 def kill(self):
     for col in self.grid:
         for i in range(len(col)):
             if col[i]:
                 col[i].kill()
     Sprite.kill(self)
コード例 #37
0
 def kill(self):
     Sprite.kill(self)
     Ship.death_count.inc()
     return self.explosion_type(self)