get angle

This commit is contained in:
Frank DeMarco 2015-08-23 12:14:53 -04:00
parent 29c715fcc0
commit 69b8506069
1 changed files with 4 additions and 3 deletions

View File

@ -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