Gravitation simulation

www.multimania.com/ilyasl…ation.html\rHere’s something I came up with messing with Newton’s equations. Not perfect at all but it’s a start : I’ve got the force field, and I lack inertia a little bit.\r\rpom 0]

Pom,\r When you see me tomorrow, send me this Fla if you wouldn’t mind, so i can study it and learn from it would ya? Nice job, kind of cool. I caught the ball a bunch of time, just wanted to let you know…\r\r\rpj\r:cool:

Well, the fla is a physics nightmare, since it deals with stuff I learned a while ago. So if you don’t know anything about physics, you’ll just see a lot of figures with no meaning. Actually, I’ve come to the point that I messed with the figures so much that they lost their meaning.

that is excellent. i have a lot of trouble keeping the ball on the screen.\r\rhave you thought about building one of those games where you choose angle and velocity, and try to hit you opponent through a field of planets, astroids, whatever, which affect the projectile?\r\rseems like you’ve already done the hard part.\r\rnice.

I don’t know if you guys remember the game “Scorch Earth” ‘the mother of all games’. it was a game where you opperated a tank and you need to shoot your opponents before they shoots you. you had to choose angle and velocity, a very cool trajectory (sp?) game.\r\rIt had some great options like…\r1. changing the strength of gravity\r2. wrap around screen\r3. rubber walls\r4. how windy (a horizontal gravity in effect)\r\rI guess what I am now asking is can it be done with flash and some gravity scripting, and help from you guys.\r\rMatt

Hey Supra, I’m very flattered by what you said. I kind of solved the escaping problem by adding one component in my acceleration formula, but it’s still very difficult to make it stay. Working on it hard !! Concerning your game, it sounds like a lot of trouble if your projectile hits one of the asteroids. As you can see, this makes the planet (it’s a planet by the way) go totally astray. I don’t know ?\rAnd Matt, you’ve just had the greatest idea of all times. My game was called gorillas, and it was running in dosshell. You were a monkey, and you had to send bananas on another monkey, and there were buildings to adver and stuff… Really cool. That’s a great project. I’d love it if you tried and made this, I’ll try on my side.\r\rpom\r\rwww.multimania.com/ilyasl…tion2.html

Sounds neat Pom. Can you show me the script for that asteroid thats a planet killer? Maybe I could use it fer my monster so he can spit out asteroids and kill Icerbergs monster, I have suped up Dans worm, turned him into a monster but he still has no teeth, well, actually only one, looks kinda like a dork.\r\rpj\r:cool:

OK, here’s a little explanation about it : (right click the link and save link as…)\rwww.multimania.com/ilyasl…ation2.fla\rIn the first frame, I define my functions :\r\rMovieClip.prototype.distance = function (a,b,c,d)\rreturns the distance between 2 clips of coordinates (a,b) and (c,d)\r\rMovieClip.prototype.angle = function (a,b)\rThe distance between two points has two components : on the x axis (a) and on the y axis (b). Based on that, you can find the angle between the 2 MC with the Math.atan function except it’s defined on [-pi/2;pi/2]\r\rMovieClip.prototype.force = function (g,m1,m2)\rgives the force applied to a MC, depending on the gravitationnal constant g, and the masses of the 2 objects\rstrengh = gm1m2/(rr) ;\rthat’s the gravitation\rstrenghx = (-strengh+1.4vv/r) * Math.cos(beta) ;\rThat’s the projection of gravitation + centripetal force on x axis\rstrenghy = (strengh+1.4vv/r) * Math.sin(beta) ;\rthe same on y axis\rIn frame two :\rthe red dot has the code :\r\ronClipEvent (enterFrame) {\rdistance (_x,_y,_root.clip2._x,_root.clip2._y) ; //between it and clip2\rangle(dx,dy) ; //find the angle\rforce (100,10,10) ; //get the force\rstartDrag ( this, true ); //you can move it\r}\rthe blue one gets :\ronClipEvent (load) { //get the coordinates of the MC to set up speed\rxold = _x ;\ryold = _y ;\r}\ronClipEvent (enterFrame) {\rxnew = _x +5 ;\rynew = _y -5 ;\rvelx = (xnew - xold) + 0.6_root.clip1.strenghx ; //speed at a given moment + strengh\rvely = (ynew - yold) + 0.6*_root.clip1.strenghy ;\rv = Math.sqrt(velx*velx+vely+vely) ; //real speed\r_x += velx ;//position\r_y += vely ;\rxold = xnew ;\ryold = ynew ;\r}\r\rYouhou !!!\r\rpom\rWelcome… to the real world, neo.