   Help with keeping something up in the air
  I have made a simple flash game where you mouse over a hamburger and try to keep it from hitting a person that will eat it. My physhics for the hamburger are horrible. I don't know any math really and it just keeps going in the same direction without any unpredicability. If you want to see the game its HEREAlso here is my code for the physics.function sendSandwhichUp(){if(sandwhich._y >= 0 && (sandwhich._y + sandwhich._height) <= 400)sandwhich._y -= 10;sandwhich._x += howMuchX;if(sandwhich._x <= 0){howMuchX = 15;}else if(sandwhich._x + sandwhich._width >= 550){howMuchX = -15;}localCount++;if(localCount == howManyTimes){clearInterval(intID);goingThrough = false;}}sandwich is the object I am trying to apply phsysics too. howMuchX is how much for it to move left or right. it will always move up the same amount. localCount is how many times this function will be called until it reaches howManyTimes and then it will stop the function interval. goingThrough is a boolean which tells that the function is already going and you can't run it until it already has stopped. I was thinking that I could make a class or whatever and have velocities. Then depending on where you hit the sandwhich it will calculate the velocity. I guess thats the part I need help on. If anyone can help me or show me some math or some tutorials it would be greatly appreciated. Thanks.   
  Can anyone help me out with some information? Even what to search for on google would help. Everything I search for I don't understand to even know if it's the thing I need. Thanks   ;  Not really sure, but for starters, you need to have the coords of the intersection between the hamburger and the mouse. So, if the intersection is on the left half of the burger then you want it to go right, if the intersection is on the right, you want the burger to go left.Hopefully this will give you something to do while someone properly answers your questions.Edit:: of course, doing it my way, you could say: okay, the closer the intersection is to the middle line, the less the x component will be, and the further from the middle line, the greater the x component of the velocity.So, this means that the closer you hit the burger to the middle, it will go more up than to the side, and if you hit it on the edge, it will move more to the side.   ;  How would I know where the mouse is relative to the burger? Would I need to subract the width and height of the movie from both objects and then decide where the mouse is. If it's less than halfway move the burger right, if its more move the burger left. Also how much should I move the burger? Should I always apply gravity or when it is in the air do some velocity calculation? Can anyone point me in the right direction of where to learn the math for this specific problem. I have been around to math sites and I don't know what to look for.   ;Quote:Original post by cptrnetHow would I know where the mouse is relative to the burger? Would I need to subract the width and height of the movie from both objects and then decide where the mouse is. If it's less than halfway move the burger right, if its more move the burger left.Yes.Quote:Original post by cptrnet Should I always apply gravity or when it is in the air do some velocity calculation? Can anyone point me in the right direction of where to learn the math for this specific problem. I have been around to math sites and I don't know what to look for. As long as your object is in the air, gravitiy should apply.Velocity should Always be calculated.This is not the correct equations of motion, but its good enough for a game:while(1){Accel=gravityvelocity=velocity+time*accelposition=position+velocity*time}