def loop(self): if self.timer.is_time(): self.destroy() return # all collision logic of the bullet is here if self.update_position(): return collide_object = collision_tools.is_colliding(self.collision_obj, self.position, self.collision_obj) if collide_object is not None: if isinstance(collide_object.get_parent(), wall_obj.Wall): self.position = self.collision_obj.move_to_edge( collide_object, self.direction) self.set_direction( reflect( self.direction, collide_object.get_colliding_surface_angle( self.collision_obj))) # print(self.direction, collide_object.get_colliding_surface_angle(self.collision_obj)) # print(self.direction) elif isinstance(collide_object.get_parent(), panzer_obj.Panzer): tank = collide_object.get_parent() if tank is not self.player.get_panzer(): self.player.add_score(1) tank.destroy() self.destroy() elif collide_object.is_solid(): self.destroy()
def update(self): self.collision_object.set_position(self.fire_position) self.break_points = [self.fire_position] l = 1 d = 10 while l < self.length: self.collision_object.set_position( calculate_directional_position( self.direction, self.collision_object.get_position(), d)) collide_obj = collision_tools.is_colliding( self.collision_object, self.collision_object.get_position(), self.collision_object) if collide_obj is not None and isinstance( collide_obj, collision_tools.CollisionFixRectangle): pos = position_class.Position( self.collision_object.move_to_edge(collide_obj, self.direction)) self.break_points.append(pos) self.direction = reflect( self.direction, collide_obj.get_colliding_surface_angle( self.collision_object)) l += d self.break_points.append( position_class.Position(self.collision_object.get_position()))
def loop(self): if self.timer.is_time(): self.destroy() return if self.update_position(): return collide_object = collision_tools.is_colliding(self.collision_obj, self.position, self.collision_obj) if collide_object is not None: if isinstance(collide_object.get_parent(), wall_obj.Wall): self.position = self.collision_obj.move_to_edge( collide_object, self.direction) self.set_direction( reflect( self.direction, collide_object.get_colliding_surface_angle( self.collision_obj))) self.flag_lock = False self.choose_timer.set_duration(1) self.choose_timer.set_timer() elif isinstance(collide_object.get_parent(), panzer_obj.Panzer): tank = collide_object.get_parent() if tank is not self.player.get_panzer(): self.player.add_score(1) tank.destroy() self.destroy() return elif collide_object.is_solid(): self.destroy() if self.choose_timer.is_time(): self.chosen_player = self.choice() self.flag_lock = True if self.flag_lock: if not self.chosen_player.killed: self.set_direction( get_direction( self.position, self.chosen_player.get_panzer().get_position())) else: self.chosen_player = None self.flag_lock = False self.choose_timer.set_timer()
def loop(self): if self.timer.is_time(): self.destroy() return # all collision logic of the bdistance(p, list_temp[0])ullet is here if self.update_position(): return collide_object = collision_tools.is_colliding(self.collision_obj, self.position, self.collision_obj) if collide_object is not None: if isinstance(collide_object.get_parent(), wall_obj.Wall): self.position = self.collision_obj.move_to_edge( collide_object, self.direction) self.set_direction( reflect( self.direction, collide_object.get_colliding_surface_angle( self.collision_obj))) self.add_collision_point(self.position) elif collide_object.is_solid(): self.destroy()