get angle
This commit is contained in:
parent
29c715fcc0
commit
69b8506069
|
@ -6,11 +6,12 @@ from pygame.mixer import get_num_channels, Channel
|
|||
from pygame.locals import *
|
||||
|
||||
def get_step(start, end, speed):
|
||||
x0, y0 = start
|
||||
x1, y1 = end
|
||||
angle = atan2(x1 - x0, y1 - y0)
|
||||
angle = get_angle(start, end)
|
||||
return speed * sin(angle), speed * cos(angle)
|
||||
|
||||
def get_angle(start, end):
|
||||
return atan2(end[0] - start[0], end[1] - start[1])
|
||||
|
||||
def get_endpoint(start, angle, magnitude):
|
||||
"""clockwise, 0 is up"""
|
||||
x0, y0 = start
|
||||
|
|
Loading…
Reference in New Issue