coder0xff wrote:
Got some suggestions for ya. If you are just trying to make pointtwo move towards the mouse (and it looks like the further away it is the less aggressively it accelerates as you have it now? is it supposed to be like gravity? lemme know cause the equation's completely different). This equation makes it move fast if it's far away, and slows as it approaches the mouse, and is correctly integrated over time if you have loss of frame rate.
If you are trying to do a system where momentum is preserved and force is used to accelerate the point towards the mouse and then decelerate so that it stops when it reaches the mouse, it's a little more difficult (unless you know how).
Also, you may want to look into the function math.atan2(y, x). It automagically determines which quadrant you're in so you don't have to do all that extra stuff you got at the end there.
I'm definitely going to look into math.atan2 thanks
basically, this creates two points, the first point moves at a specified speed always directly at the mouse, the second point does the same but it always moves towards the first invisible point, this second point is where the actual object is. This makes the ball follow the mouse, but not directly, it takes time to make wide turns instead of just going straight at the mouse. It's like a three car train. its based off constantly updating the x and y value of the ball so that its "vector" or hypotenuse is. It works, the problem is that the "train cars" can go on top of each other. I'm redoing it by updating the angle of movement and basing the x y off that, instead of making a "train" which should fix it I think. I've got all the math down on paper but haven't typed it up yet.
this doesn't change the speed based off the distance of the mouse because of the use of "proportion", however i plan on implementing that in the game, which is a prototype for a soon to be iphone game. if i can prove my concept in lua on LOVE (
http://www.love2d.org ) then i'll start on the iphone version