samples/13_path_finding_algorithms/03_breadcrumbs/app/main.rb
# This method processes user input every tick
# Any method with "1" is related to the first grid
# Any method with "2" is related to the second grid
This method processes user input every tick
Any method with "1" is related to the first grid
Any method with "2" is related to the second grid
This method processes user input every tick Any method with " 1 " is related to the first grid Any method with " 2 " is related to the second grid
def input
    if inputs.mouse.up
      state.current_input = :none
    elsif star_clicked?
      state.current_input = :star
    end
    if mouse_inside_grid?
      unless grid.target == cell_closest_to_mouse
        grid.target = cell_closest_to_mouse
      end
      if state.current_input == :star
        unless grid.star == cell_closest_to_mouse
          grid.star = cell_closest_to_mouse
        end
      end
    end
  end
def input if inputs . mouse . up state . current_input = :none elsif star_clicked? state . current_input = :star end if mouse_inside_grid? unless grid . target == cell_closest_to_mouse grid . target = cell_closest_to_mouse end if state . current_input == :star unless grid . star == cell_closest_to_mouse grid . star = cell_closest_to_mouse end end end end
This method processes user input every tick
Any method with "1" is related to the first grid
Any method with "2" is related to the second grid
This method processes user input every tick Any method with " 1 " is related to the first grid Any method with " 2 " is related to the second grid
# The program has to remember that the user is dragging an object # even when the mouse is no longer over that object # So detecting input and processing input is separate # detect_input # process_input