Skip to main content
deleted 180 characters in body; edited title
Source Link
House
  • 73.5k
  • 17
  • 188
  • 276

Finding vectors with 2two points (python)

0 down vote favorite Im helping my friend out with a pygame but we are stuck

so wereWe're are trying to get the direction of a projectile but we cantcan't find out how

forFor 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.

hereHere is where we are plugging in the vectors:

def update(self):

    self.rect.x += self.vector[0]
    self.rect.y += self.vector[1]

thenThen we are blitting the projectile at the rects coords

if you want to see all the code here is the repo

https://github.com/linkey11/Necromonster.

Finding vectors with 2 points (python)

0 down vote favorite Im helping my friend out with a pygame but we are stuck

so were are trying to get the direction of a projectile but we cant 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

if you want to see all the code here is the repo

https://github.com/linkey11/Necromonster

Finding vectors with two points

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.

Source Link
Serial
  • 238
  • 3
  • 14

Finding vectors with 2 points (python)

0 down vote favorite Im helping my friend out with a pygame but we are stuck

so were are trying to get the direction of a projectile but we cant 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

if you want to see all the code here is the repo

https://github.com/linkey11/Necromonster