I'm having some trouble with vectors and vector math in a small "battle simulation" program. There are 15 "guys" on each side of the screen, at different X/Y positions. I cannot get the guys to shoot at the correct angle when they choose which enemy they want to shoot at. Currently I have this to determine the bullets path once they shoot. This code is in regards to the bullet rect, and the destination X/Y positions.
diff = (self.startX - self.destX, self.startY - self.destY)
distance = math.sqrt(diff[0]**2 + diff[1]**2)
diff_norm = (diff[0] / distance, diff[1] / distance)
self.rect.x -= diff_norm[0]
self.rect.y -= diff_norm[1]
But this just has the bullets all going to the top left(ish) of the screen. the big blue/white squares are the guys, randomly moving about, and the little white squares are the bullets.
http://gyazo.com/8f219a6b0b561b72bcccdea7e325c51a (It's better to view the gif in mp4 format by clicking the "..." in the top right)
Some don't move, some fly straight up...what's happening here?