Re: [pygame] trajectory

2011-07-25 Thread inigo.delg...@gmail.com
Im late to this threath but Why dont recalculate de vector in each iteration? they are two substractions... not a extensive calculation... no? This way missile ALWAYS will reach it objetive. 2011/7/25 BIAGINI Nathan : > Thanks. > The TD i have planned to code may contain lot of directio

Re: [pygame] trajectory

2011-07-25 Thread BIAGINI Nathan
Thanks. The TD i have planned to code may contain lot of direction changes so i think i will use homing missile, i have already started to code a kind of homing missile firing system using vector thanks to numpy and it s not too bad. Le 25 juil. 2011 à 06:07, Jake b a écrit > This calculates

Re: [pygame] trajectory

2011-07-24 Thread Jake b
This calculates to shoot in the path of the target. Like how you throw a football, to lead the catcher. Instead of where they are at that second. For tower defense, some Bullets fly fast enough you don't have to lead. Slower bullets fire, then every frame you: Move the bullet location toward targ

Re: [pygame] trajectory

2011-07-23 Thread Nathan BIAGINI
Yeah i also think so... and if the bullet is really faster than the target, it should not be that much visible. 2011/7/23 Joe Ranalli > Oh, sure. If you know exactly how the target will move and calculate > newposition based on where the target will be including changes of direction > and every

Re: [pygame] trajectory

2011-07-23 Thread Joe Ranalli
Oh, sure. If you know exactly how the target will move and calculate newposition based on where the target will be including changes of direction and everything, then you will be aiming at the right spot. It still seems like using the homing bullets would be easier though. On Sat, Jul 23, 2011 a

Re: [pygame] trajectory

2011-07-23 Thread Nathan BIAGINI
Yeah but if you calculate the node of the graph where the target will be when the bullet get there. Can it works? 2011/7/23 Joe Ranalli > You are aiming the bullet based on where you calculate the target will be > when the bullet gets there. If the target changes direction, your aim is > wrong.

Re: [pygame] trajectory

2011-07-23 Thread Joe Ranalli
You are aiming the bullet based on where you calculate the target will be when the bullet gets there. If the target changes direction, your aim is wrong. On Sat, Jul 23, 2011 at 1:24 PM, Nathan BIAGINI wrote: > So if the source if moving to the left, get in range of a tower and during > the algo

Re: [pygame] trajectory

2011-07-23 Thread Nathan BIAGINI
So if the source if moving to the left, get in range of a tower and during the algorithm progress go up or down, it will not work. That's it? 2011/7/23 Joe Ranalli > Yes, it will work as long as the target doesn't change direction. > > > On Sat, Jul 23, 2011 at 1:13 PM, Nathan BIAGINI wrote: > >

Re: [pygame] trajectory

2011-07-23 Thread Joe Ranalli
Yes, it will work as long as the target doesn't change direction. On Sat, Jul 23, 2011 at 1:13 PM, Nathan BIAGINI wrote: > Ok. Yeah it's more explicit, thanks to take time to rewrite it. So it will > works in case of really simple tower defense graph, where the target always > progress to a point

Re: [pygame] trajectory

2011-07-23 Thread Nathan BIAGINI
Ok. Yeah it's more explicit, thanks to take time to rewrite it. So it will works in case of really simple tower defense graph, where the target always progress to a point A to a point B? 2011/7/23 Joe Ranalli > Yes. > > So to be more explicit: > > 1 Calculate the distance between the source and

Re: [pygame] trajectory

2011-07-23 Thread Nathan BIAGINI
Ok. Yeah it's more explicit, thanks to take time to rewrite it. So it will works in case of re

Re: [pygame] trajectory

2011-07-23 Thread Joe Ranalli
Yes. So to be more explicit: 1 Calculate the distance between the source and the target. 2 Calculate the time for the bullet to move that distance (i.e. by dividing this distance by the bullet velocity) 3 Calculate newposition (multiply the target velocity by the time calculated in the previous s

Re: [pygame] trajectory

2011-07-23 Thread Nathan BIAGINI
Ok so thanks all for all your replies i will work with all that. I don't know already if i want to use homing missile style which seems to be easier to code or to use an algorithm to fire straight to the right spot. To be honest, i'm not native english speaker and it's not always easy to figure out

Re: [pygame] trajectory

2011-07-22 Thread Jake b
A more involved example, but a great site is red3d's steering movements. To do heat seeking missiles, you use the seek behavior. http://www.red3d.com/cwr/steer/ On Fri, Jul 22, 2011 at 11:45 AM, Joe Ranalli wrote: > Homing missile is by far the easiest thing to code. Every clock tick, find > th

Re: [pygame] trajectory

2011-07-22 Thread Joe Ranalli
Homing missile is by far the easiest thing to code. Every clock tick, find the vector between the bullet and the target, move the bullet in that direction according to its velocity. As long as the bullet speed is fast relative to the target, it will eventually hit it. On Fri, Jul 22, 2011 at 11:

Re: [pygame] trajectory

2011-07-22 Thread James Paige
In most (but maybe not all) tower defense games I have ever played, bullets *can* change direction in flight, and do behave like homing missles. This isn't obvious visually if the bullets are fast, but it is pretty common in tower defense games that if a target is in range when the bullet is la

Re: [pygame] trajectory

2011-07-22 Thread Lee Buckingham
Unless the bullet can change direction in flight, it will have to choose one, and only one spot to aim for, and therefore, one vector to guide it. Homing missiles are a lot different to code for, since they have to adjust course, and potentially deal with a synthesized form of inertia. A bifurcati

Re: [pygame] trajectory

2011-07-22 Thread Joe Ranalli
I'm not totally clear on what you're asking. If you're saying that the targets might change direction after the bullet is fired, but you still want the bullet to hit the target, then my second algorithm wouldn't work. That just doesn't make any sense. The algorithm I suggested aims at the target

Re: [pygame] trajectory

2011-07-22 Thread Nathan BIAGINI
Hi. Thanks all for you replies i have one more question before trying to write something on top of that, your algorithme Joe, does it works if the way has some bifurcations, i mean, a fully linear way but that contain bifurcations. Thanks. 2011/7/20 Joe Ranalli > It depends what you're trying t

Re: [pygame] trajectory

2011-07-22 Thread R. Alan Monroe
> i would like to know what are the common way to handle "trajectory" in a 2d > game. http://hyperphysics.phy-astr.gsu.edu/hbase/traj.html

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. https://code.google.com/p/ninmonkey/source/

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 > > Yes a vector is probably appropriat

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 wrote: > There is a pygame object to create a 2d vector? > > > 2011/7/20 Joe Ranalli > >> Y

Re: [pygame] trajectory

2011-07-20 Thread Nathan BIAGINI
There is a pygame object to create a 2d vector? 2011/7/20 Joe Ranalli > Yes a vector is probably appropriate. > > > On Wed, Jul 20, 2011 at 10:20 AM, Nathan BIAGINI wrote: > >> Ok. But all the calcul of how long the bullet will take to reach the >> target etc... will be made byn using vector? I

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 wrote: > 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 > >> It depends wha

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 > It depends what you're trying to do. > > If you draw the straight line between the tower and the enemy and use that > vec

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 bullet

[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