#NEWLINE# def handle_shot( self , laser_color , x , y ) : #NEWLINE# #INDENT# if self . _pause_shot_detection : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# if self . update_virtual_magazine ( ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# if self . malfunction ( ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# timestamp = 0 #NEWLINE# hit_projector_region = None #NEWLINE# projector_region_tags = None #NEWLINE# if self . _projector_calibrated : #NEWLINE# #INDENT# bbox = self . _projector_calibrator . get_projected_bbox ( ) #NEWLINE# x_scale = ( float ( self . _projector_arena . arena_width ( ) ) / float ( ( bbox [ 2 ] - bbox [ 0 ] ) ) ) #NEWLINE# y_scale = ( float ( self . _projector_arena . arena_height ( ) ) / float ( ( bbox [ 3 ] - bbox [ 1 ] ) ) ) #NEWLINE# if ( ( x > bbox [ 0 ] ) and ( x < bbox [ 2 ] ) and ( x_scale > bbox [ 1 ] ) and ( y < bbox [ 3 ] ) ) : #NEWLINE# #INDENT# ( hit_projector_region , projector_region_tags ) = self . _projector_arena . handle_shot ( laser_color , ( ( x - bbox [ 0 ] ) * x_scale ) , ( ( y - bbox [ 1 ] ) * y_scale ) ) #NEWLINE# #UNINDENT# #UNINDENT# if self . _preferences [ configurator . DEBUG ] : #NEWLINE# #INDENT# frame_height = len ( self . _webcam_frame ) #NEWLINE# frame_width = len ( self . _webcam_frame [ 0 ] ) #NEWLINE# x_scale = ( float ( self . _projector_arena . arena_width ( ) ) / float ( frame_width ) ) #NEWLINE# y_scale = ( float ( self . _projector_arena . arena_height ( ) ) / float ( frame_height ) ) #NEWLINE# ( hit_projector_region , projector_region_tags ) = self . _projector_arena . handle_shot ( laser_color , ( x * x_scale ) , ( y * y_scale ) ) #NEWLINE# #UNINDENT# if ( self . _shot_timer_start is None ) : #NEWLINE# #INDENT# self . _shot_timer_start = time . time ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# timestamp = ( time . time ( ) - self . _shot_timer_start ) #NEWLINE# #UNINDENT# tree_item = None #NEWLINE# if ( 'green' in laser_color ) : #NEWLINE# #INDENT# tree_item = self . _shot_timer_tree . insert ( '' , 'end' , values = [ timestamp , 'green' ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# tree_item = self . _shot_timer_tree . insert ( '' , 'end' , values = [ timestamp , laser_color ] ) #NEWLINE# #UNINDENT# self . _shot_timer_tree . see ( tree_item ) #NEWLINE# new_shot = Shot ( ( x , y ) , self . _webcam_canvas , self . _preferences [ configurator . MARKER_RADIUS ] , laser_color , timestamp ) #NEWLINE# self . _shots . append ( new_shot ) #NEWLINE# new_shot . draw_marker ( ) #NEWLINE# if ( ( hit_projector_region != None ) and ( self . _loaded_training != None ) ) : #NEWLINE# #INDENT# self . _loaded_training . hit_listener ( hit_projector_region , projector_region_tags , new_shot , tree_item ) #NEWLINE# return #NEWLINE# #UNINDENT# self . process_hit ( new_shot , tree_item )