<s> import pyglet <EOL> import util <EOL> class PhysicalObject ( pyglet . sprite . Sprite ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , * args , ** kwargs ) : <EOL> super ( PhysicalObject , self ) . __init__ ( * args , ** kwargs ) <EOL> self . velocity_x , self . velocity_y = <NUM_LIT:0.0> , <NUM_LIT:0.0> <EOL> self . reacts_to_bullets = True <EOL> self . is_bullet = False <EOL> self . dead = False <EOL> self . new_objects = [ ] <EOL> self . event_handlers = [ ] <EOL> def update ( self , dt ) : <EOL> """<STR_LIT>""" <EOL> self . x += self . velocity_x * dt <EOL> self . y += self . velocity_y * dt <EOL> self . check_bounds ( ) <EOL> def check_bounds ( self ) : <EOL> """<STR_LIT>""" <EOL> min_x = - self . image . width / <NUM_LIT:2> <EOL> min_y = - self . image . height / <NUM_LIT:2> <EOL> max_x = <NUM_LIT> + self . image . width / <NUM_LIT:2> <EOL> max_y = <NUM_LIT> + self . image . height / <NUM_LIT:2> <EOL> if self . x < min_x : <EOL> self . x = max_x <EOL> if self . y < min_y : <EOL> self . y = max_y <EOL> if self . x > max_x : <EOL> self . x = min_x <EOL> if self . y > max_y : <EOL> self . y = min_y <EOL> def collides_with ( self , other_object ) : <EOL> """<STR_LIT>""" <EOL> if not self . reacts_to_bullets and other_object . is_bullet : <EOL> return False <EOL> if self . is_bullet and not other_object . reacts_to_bullets : <EOL> return False <EOL> collision_distance = self . image . width * <NUM_LIT:0.5> * self . scale + other_object . image . width * <NUM_LIT:0.5> * other_object . scale <EOL> actual_distance = util . distance ( self . position , other_object . position ) <EOL> return ( actual_distance <= collision_distance ) <EOL> def handle_collision_with ( self , other_object ) : <EOL> if other_object . __class__ is not self . __class__ : <EOL> self . dead = True </s>
