My Math Forum incease speed and changing direction.

 Algebra Pre-Algebra and Basic Algebra Math Forum

 February 9th, 2012, 04:00 PM #1 Newbie   Joined: Feb 2012 Posts: 2 Thanks: 0 incease speed and changing direction. hey i'm a game developer not so good in maths so i thought i come ask some advice here... what i basically need is a formula that can increase in both positive and negative with using one variable that changes from minus to plus. my code is this speed +=1 speed= -speed the problem here off course is that is does the following on update: speed = 5 + 1 5+1 = -(5+1) which is good (my object changes direction and goes 1 faster) then the second time speed = -6 +1 -5 = 5 my direction changes but my speed goes down one... now is there a way i can get the number increased in the part where it says speed = -6 +1 so it results in - 7 and the next run would be 7+1 and so on...? don't even know if this is a stupid question or not i just can't figure out how to get it to work with in one formula... so any pointers are welcome thx J.
 February 9th, 2012, 04:17 PM #2 Senior Member     Joined: Jul 2010 From: St. Augustine, FL., U.S.A.'s oldest city Posts: 12,211 Thanks: 520 Math Focus: Calculus/ODEs Re: incease speed and changing direction. Instead of adding 1 to the current speed, you could add abs(speed)/speed so that if speed < 0 then -1 is added and if speed > 0 then +1 is added. Note: abs(x) = |x|, the absolute value function. Your programming language should have that intrinsic function.
 February 10th, 2012, 07:10 AM #3 Newbie   Joined: Feb 2012 Posts: 2 Thanks: 0 Re: incease speed and changing direction. thanks! it has this Mathf.Abs didn't think of looking in the mathf functions, grrr stupido!

 Tags changing, direction, incease, speed

 Thread Tools Display Modes Linear Mode

 Similar Threads Thread Thread Starter Forum Replies Last Post Chikis Elementary Math 25 January 31st, 2014 09:48 AM Melody2 Physics 2 October 28th, 2013 04:44 PM Aimee-D Advanced Statistics 1 July 26th, 2012 05:10 AM C42711 Algebra 0 October 30th, 2011 01:06 PM RMG46 Algebra 1 July 5th, 2010 10:36 PM

 Contact - Home - Forums - Cryptocurrency Forum - Top