Finding vectors with two points
Posted
by
Christian Careaga
on Game Development
See other posts from Game Development
or by Christian Careaga
Published on 2013-06-27T00:46:30Z
Indexed on
2013/06/27
4:32 UTC
Read the original article
Hit count: 261
We're are trying to get the direction of a projectile but we can't find out how
For example:
[1,1] will go SE
[1,-1] will go NE
[-1,-1] will go NW
and [-1,1] will go SW
we need an equation of some sort that will take the player pos and the mouse pos and find which direction the projectile needs to go.
Here is where we are plugging in the vectors:
def update(self):
self.rect.x += self.vector[0]
self.rect.y += self.vector[1]
Then we are blitting the projectile at the rects coords.
© Game Development or respective owner