| shenagxthy | Date: Thursday, 20 Jun 2013, 12:11:47 | Message # 1 |
|
Lieutenant general
Group: Users
Messages: 676
Status: Offline
| <a href=http://www.coastclothing2.co.uk/red-coast-goddess-maxi-dress-p-77.html>Red Coast Goddess Maxi Dress</a> <a href=http://www.coastclothing2.co.uk/wine-coast-palladium-dress-p-125.html>Wine Coast Palladium Dress</a> <a href=http://www.coastclothing2.co.uk/brown-black-coast-miami-print-jersey-dress-p-87.html>Brown Black Coast Miami Print Jersey Dress</a>
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 <>Positiontarget <>tCollision t0 ] Positionbullet <>t0 ] ] So you need also another constraint: 锘?D game algorithm to calculate a bullet needed speed to hit target 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. 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. 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.) 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 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. Distance<v>u]= +Sqrt<>(VxUx)^2 + (VxVy)^2 ] Further, the distance is given by 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. 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. 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.
http://oakleysunglasses2sale.webs.com/
|
| |
|
|