So after racking my brain, I've concluded Im a retard having forgotten everything I learned in high school about how to calculate Linear Acceleration.
First problem: RMXP doest use Linear Acceleration directly. It uses Exponential Acceleration.
IE: 2 to the power of @move_speed
Thus, in order to find a Delta (how much to change the speed each frame) one must first get the Velocity. Simple enough, v1 = 2**@move_speed
Increase the Velocity by Delta
v1 += delta
Pretty easy so far. Now, to convert that back into a number that XP uses, it has to be an Exponent. Also fairly simple. @move_speed = Math.log(v1)
Oh wait, this version of Ruby isnt using a Base 2 Logarithm. It uses "Natural Logarithm" which is a base of 2.77, whatever the fuck that means. Newer versions of Ruby do have log2 built in, but not in the current build that XP uses.
Well, alright, guess I'll have to plug in method for calculating a Base 2 Logarythm.
def logBase(n, x)
return Math.log(x) / Math.log(n)
end
Great. Now I can get a Log Base of 2 (because XP uses 2 to the power of @move_speed, and LogBase2 should tell us what Exponent 2 needs to be in order to result in X)
What I want to do:
def acceleration(new_speed)
// Calculate Time and derive Delta with Time
@acceleration_counter = time
end
alias accelerate_update_move update_move
def update_move
if @acceleration_counter > 1
@move_speed = logBaxe(2, 2**@move_speed + @delta)
@acceleration_counter -= 1
end
# Call Original
accelerate_update_move
end
(Note: Not real code, Im stuck figuring out Time and Delta)
Problem: I dont have a clue how to find Delta with the given information. I know we have two speeds (using exponents), the current @move_speed, and the new one to be accelerated to. Distance I am using 128 based on @real_x and @real_y. Time I think should be half the difference of current speed and new speed, could be wrong on that too. Hell, I dont even remember how to rearrange simple algebraic formulas to solve for any of this.
Any suggestions from you Math Jeaniuses?