From: Darren Tanner Newsgroups: comp.os.msdos.djgpp Subject: Re: Worms and game physics Date: Thu, 19 Feb 1998 23:49:58 +0000 Distribution: world Message-ID: References: <199802192147 DOT OAA13214 AT mail DOT enol DOT com> NNTP-Posting-Host: vayona.demon.co.uk MIME-Version: 1.0 Lines: 37 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk In article <199802192147 DOT OAA13214 AT mail DOT enol DOT com>, Mark Crowder writes > ... > 2. For those of you who have played Worms, you've most likely > noticed that when the explosions go off, any worms that are within a > certain radius of the explosion go flying off in all directions. > Anybody know where I can find the formula for that? What you could do is find the grid reference point for both the centre of the explosion(x1,y1) and the 'worm'(or whatever),(x2,y2). Then the distance between the two could be found (((x2-x1)^2)+((y2-y1)^2)))^(1/2) The force applied to the 'worm' could then be reduced by this distance. eg: Force applied = strength_of_weapon - distance or Force applied = ((1/distance)+constant) * strength_of_weapon This second equation is preferable, I think. :) The inital direction for the force to be applied in would be the vector: ( x2-x1) ( y2-y1) The 'worm' could then be dealt with in the same way as a (heavy) projectile. > 3. Yes, another equation question :). What about the projectiles? > When I was writing my Space War game a few years ago I came upon the > sin()/cos() formula for rotating a point, which can also be used to > calculate velocity. Would I just use that formula in conjunction > with the downward (or upward ;) ) pull of gravity The equation final_velocity=initial_velocity+acceleration_due_to_G * Time_of_Flight could be used to find the downward (or upward) change in velocity. So if the object starts at rest and is thrown then the time in the air * the pull of G would give the velocity downwards due to G, and should be taken away from the verticle velocity due to the throw) Well I hope I've helped a bit. Sorry if it is a little patronising, but I didn't know how much you knew. -- Darren Tanner