1
\$\begingroup\$

I am programming a 2D sidescroller in python and pygame and am having trouble making a bullet go farther than just farther than the player. The bullet travels straight to the ground after i fire it. How, in python code using pygame do I make the bullet go farther. If you need code, here is the method that handles the bullet firing:

    self.xv += math.sin(math.radians(self.angle)) * self.attrs['speed']
    self.yv += math.cos(math.radians(self.angle)) * self.attrs['speed']
    self.rect.left += self.xv
    self.rect.top += self.yv
\$\endgroup\$
  • \$\begingroup\$ This is way too vague, you should post some snippets of code (not the whole program). \$\endgroup\$ – o0'. Mar 30 '12 at 15:56
1
\$\begingroup\$

It's unclear what happens to the bullet.

Does it have the same speed as the player? In that case, obviously the bullet should have a greater speed.

Does it disappears just after it appeared? Maybe you misplaced it and collided with the player.

\$\endgroup\$
0
\$\begingroup\$

There is a 2D physics engine that integrates nicely with PyGame. It is called PyMunk and uses the Chipmunk 2D physics engine. You might want to use it if you do something more with physics in your games.

\$\endgroup\$
  • \$\begingroup\$ This does not appear to really address the asker's issue. \$\endgroup\$ – Josh Jan 9 '14 at 4:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.