| shenagxthy | Date: Saturday, 22 Jun 2013, 09:21:50 | Message # 1 |
|
Lieutenant general
Group: Users
Messages: 676
Status: Offline
| <a href=http://www.coastdresses2uk.co.uk/coast-white-black-dianna-dress-uk-p-49.html>Coast White Black Dianna Dress UK</a> <a href=http://www.coastdresses2uk.co.uk/apricot-coast-chantilly-dress-uk-p-79.html>Apricot Coast Chantilly Dress UK</a> <a href=http://www.coastdresses2uk.co.uk/apricot-coast-hortenese-dress-uk-p-13.html>Apricot Coast Hortenese Dress UK</a>
So you need also another constraint: Probably for it to look good, the bullet would start at the outside of the originSprite (or some defined radius, though I guess starting from the originSprite center would also work), but its bullet center would try hit into the center of the targetSprite or so. Note there's no gravity or anything in this world. (Perhaps I should have my sprites variables using angle and velocity but right now I'm using speedX and speedY.) From Eq 2, you can see that for a given SpeedXtarget there exist infinite solutions (as already pointed out in other answers) for t and SpeedXbullet, so I think your specifications are not complete. 锘?D game algorithm to calculate a bullet needed speed to hit target Sjoerd, to given an example, there will be a static sprite, let call it the shooter, and an incoming moving sprite, let call it a mover. The shooter has a certain distance at which it starts seeing the enemy mover, and it "knows" the enemy speed, and it then tries to fire a shot. Philipp Lenssen Jul 9 '10 at 9:37 Distance<v>u]= +Sqrt<>(VxUx)^2 + (VxVy)^2 ] From the distance between the origin of the bullet and the intersection point (and the previously calculated time) you can calculate the speed of the bullet. Further, the distance is given by I have a rather simple bird'sview 2D game where tower sprites defend against incoming moving sprites by shooting a bullet at them. so I have the objects originSprite, targetSprite and bulletSprite, all with these type of values, and I need to set the right bulletSprite speed values. If you set a fixed direction, you simply intersect the two lines of the bullet and the target. From the distance between the current point of the target and the intersection point (and the target's speed) you can calculate the time the target will take to reach this intersection point. Which still permits infinite solutions, but bounded by an upper value for the Collision time, given by the fact that the target may abandon the range. I guess (as stated in a commentary I made in another answer) thinking in a "tower defense" kind of game, that your bullets have a limited range. If solving the system of linear equations is consuming too much CPU time when you are doing this in realtime (which it might, depending on how many bullets are in flight at the same time), you can probably precompute a set of solutions and only solve the corner cases in realtime. Assuming your targets will move with a known speed, calculate a result based on (say) eight different directions that they could approach from (N,NE,E,etc). When the shooter detects a target, simply look up whether you have a result precomputed for a target with that speed and bearing. If not, calculate it. bta Jul 9 '10 at 20:42 Distance <>Positiontarget <>tCollision t0 ] Positionbullet <>t0 ] ]
http://oakleysunglasses2sale.webs.com/
|
| |
|
|