samples/13_path_finding_algorithms/05_dijkstra/app/main.rb
def cell_closest_to_mouse
    # Closest cell to the mouse in the first grid
    x = (inputs.mouse.point.x / grid.cell_size).to_i
    y = (inputs.mouse.point.y / grid.cell_size).to_i
    # Bound x and y to the grid
    x = grid.width - 1 if x > grid.width - 1
    y = grid.height - 1 if y > grid.height - 1
    # Return closest cell
    [x, y]
  end
# When the user grabs the star and puts their cursor to the far right
# and moves up and down, the star is supposed to move along the grid as well
# Finding the cell closest to the mouse helps with this
When the user grabs the star and puts their cursor to the far right
and moves up and down, the star is supposed to move along the grid as well
Finding the cell closest to the mouse helps with this
When the user grabs the star and puts their cursor to the far right and moves up and down the star is supposed to move along the grid as well Finding the cell closest to the mouse helps with this
def cell_closest_to_mouse
    x = (inputs.mouse.point.x / grid.cell_size).to_i
    y = (inputs.mouse.point.y / grid.cell_size).to_i
    x = grid.width - 1 if x > grid.width - 1
    y = grid.height - 1 if y > grid.height - 1
    [x, y]
  end
def cell_closest_to_mouse x = ( inputs . mouse . point . x / grid . cell_size ) . to_i y = ( inputs . mouse . point . y / grid . cell_size ) . to_i x = grid . width - 1 if x > grid . width - 1 y = grid . height - 1 if y > grid . height - 1 [ x , y ] end
When the user grabs the star and puts their cursor to the far right
and moves up and down, the star is supposed to move along the grid as well
Finding the cell closest to the mouse helps with this
When the user grabs the star and puts their cursor to the far right and moves up and down the star is supposed to move along the grid as well Finding the cell closest to the mouse helps with this
# Closest cell to the mouse in the first grid # Bound x and y to the grid # Return closest cell