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)
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
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
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
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)
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)
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)
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)
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)
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)
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
def kill(self): #self.explode = Surface(self.size) Sprite.kill(self)
def kill(self): ImpactGroup.impacts.add(FireImpact (self.rect.center, self.bounds, 60, self.kind)) Sprite.kill(self)
def kill(self): ImpactGroup.impacts.add(RadiationImpact (self.rect.center, self.bounds, 300, self.kind)) Sprite.kill(self)
def kill(self): del Hotspot.rows[self.id] Sprite.kill(self)
def kill(self): Sprite.kill(self)
def kill(self): self.observer.activate_maniac() Sprite.kill(self)
def kill(self): log.debug('stripe getting killed') Sprite.kill(self) controller = mvcState.GetController() controller.gameEventListeners.remove(self)
def kill(self): Game.current.play("bust.wav") Sprite.kill(self)
def remove_from_groups(self): Sprite.kill(self)
def kill(self): neighborhood.ignore(self) Sprite.kill(self)
def on_death(self): self.world_map.tiles[self.tile_index] = None Sprite.kill(self)
def on_death(self): Sprite.kill(self)
def kill(self): Sprite.kill(self) Ship.death_count.inc() return self.explosion_type(self)
def kill(self): Sprite.kill(self) controller = mvcState.GetController() controller.gameEventListeners.remove(self) controller.mouseListeners.remove(self)
def update(self): if self.__life__ < 1: spt.kill(self)
def kill(self): self.observer.add_point() Sprite.kill(self)
def kill(self): self.observer.add_life() Sprite.kill(self)
def kill( self ): log.debug( 'stripe getting killed' ) Sprite.kill(self) controller = mvcState.GetController() controller.gameEventListeners.remove(self)
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)
def kill(self): ImpactGroup.impacts.add(RockImpact (self.rect.center, self.bounds, 4, self.kind)) Sprite.kill(self)
def kill( self ): Sprite.kill( self ) controller = mvcState.GetController() controller.gameEventListeners.remove( self ) controller.mouseListeners.remove( self )
def kill(self): xplo = self.explosion_type(self.rect.center, self.explosion_radius) Explosion.group.add(xplo) Sprite.kill(self)
def kill(self): for col in self.grid: for i in range(len(col)): if col[i]: col[i].kill() Sprite.kill(self)