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\$
1
  • \$\begingroup\$ This is way too vague, you should post some snippets of code (not the whole program). \$\endgroup\$
    – o0'.
    Mar 30, 2012 at 15:56

2 Answers 2

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\$
1
  • \$\begingroup\$ This does not appear to really address the asker's issue. \$\endgroup\$
    – user1430
    Jan 9, 2014 at 4:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .