[pygame] trajectory

2011-07-20 Thread Nathan BIAGINI
Hi everyone, i would like to know what are the common way to handle trajectory in a 2d game. In fact, i think of writing a tower defense game and i wonder how to handle the trajectory of the missile launch by the towers. I though of getting the pos of the tower and the target and create a vector

Re: [pygame] trajectory

2011-07-20 Thread Joe Ranalli
It depends what you're trying to do. If you draw the straight line between the tower and the enemy and use that vector to translate a bullet each tick, the bullets might miss the enemy. Think about it this way, the bullet moves 2 steps toward the enemy, then the enemy moves 1 step, then the

Re: [pygame] trajectory

2011-07-20 Thread Nathan BIAGINI
Ok. But all the calcul of how long the bullet will take to reach the target etc... will be made byn using vector? I mean, using a vector still viable? 2011/7/20 Joe Ranalli jrana...@gmail.com It depends what you're trying to do. If you draw the straight line between the tower and the enemy

Re: [pygame] trajectory

2011-07-20 Thread Joe Ranalli
Yes a vector is probably appropriate. On Wed, Jul 20, 2011 at 10:20 AM, Nathan BIAGINI nathan.o...@gmail.comwrote: Ok. But all the calcul of how long the bullet will take to reach the target etc... will be made byn using vector? I mean, using a vector still viable? 2011/7/20 Joe Ranalli

Re: [pygame] trajectory

2011-07-20 Thread Nathan BIAGINI
There is a pygame object to create a 2d vector? 2011/7/20 Joe Ranalli jrana...@gmail.com Yes a vector is probably appropriate. On Wed, Jul 20, 2011 at 10:20 AM, Nathan BIAGINI nathan.o...@gmail.comwrote: Ok. But all the calcul of how long the bullet will take to reach the target etc...

Re: [pygame] trajectory

2011-07-20 Thread Joe Ranalli
No, but what you're talking about doing isn't hard. If you're having trouble with it, you'll need to look into some elementary physics and trigonometry. On Wed, Jul 20, 2011 at 10:33 AM, Nathan BIAGINI nathan.o...@gmail.comwrote: There is a pygame object to create a 2d vector? 2011/7/20

Re: [pygame] trajectory

2011-07-20 Thread James Paige
Not built into pygame, but there is a good one on the pygame wiki: http://pygame.org/wiki/2DVectorClass On Wed, Jul 20, 2011 at 04:33:16PM +0200, Nathan BIAGINI wrote: There is a pygame object to create a 2d vector? 2011/7/20 Joe Ranalli jrana...@gmail.com Yes a vector is

Re: [pygame] trajectory

2011-07-20 Thread Jake b
You can define bullet speed in pixels per second. You can use euclid (it works), but I instead suggest numpy. Which has a vector( numpy.array ), and is useful for other game related things. Here's a stand-alone example, uses numpy for vector movement.

Re: [pygame] Blog posts on a pygame+pyopengl project

2011-07-20 Thread Jake b
Cool! I missed this email. I like the images, and diagrams. Are you planning on ability to edit or create a new world? Have you thought of doing a Terarria map viewer? (It's similar in a lot of ways, but from the side view its 2d only.) I found a few python interfaces to the map file: -