Advertisement
marlosgama

Untitled

Apr 14th, 2020
580
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.29 KB | None | 0 0
  1. def to_direction(start_x, start_y, target_x, target_y)
  2.   radians = Math.atan2(target_x - start_x, target_y - start_y)
  3. end
  4.  
  5. # cima (8)
  6. p to_direction(2, 1, 2, 0)
  7. # baixo (2)
  8. p to_direction(2, 1, 2, 3)
  9. # esquerda (4)
  10. p to_direction(2, 1, 0, 1)
  11. # direita (6)
  12. p to_direction(2, 1, 3, 1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement