<div>Hello Tutor,</div><div> </div><div>     I&#39;m having some trouble with a mathematical function in my code. I am attempting to create a realistic acceleration in an object, slower to speed up at its min and max speeds and fastest in the middle. To keep the math simpl(er), I just wrote this function for a parabola, which models the acceleration of the object. Y is the acceleration and X is the current speed of the object.</div>
<div> </div><div>Y = -.01X^2 * 1.45X</div><div> </div><div>Before I came up with this formula, I was using a very inefficient list method to do this. The old code is in italics. I still have it in the code because it works (sort of). The function is commented out because it doesn&#39;t work. It&#39;s also in bold, so you can see it easily.</div>
<div> </div><div>        if keys[pygame.K_UP] and self.dy &lt; (15 + self.speedMod):<br>            if self.dy &lt;= 0:<br>               <em> self.accelPoints += self.accelList[0]</em><br>                <strong>#self.dy += 1</strong><br>
            else:<br>                <em>self.accelPoints += self.accelList[self.dy]</em><br>                <strong>#self.accelPoints += ((-.1 * (self.dy * self.dy)) + (1.45 * self.dy))</strong><br>            if self.accelPoints &gt;= self.accelGoal:<br>
                self.dy += 1<br>                self.nety = self.dy<br>                self.accelPoints = 0</div><div> </div><div>I did a test, and for some reason, it seems like the output of the function is never saved into the self.accelPoints variable, because it always prints out as 0. (For those who don&#39;t want to do the math, when dy = 1, the function should output something close to 1.55) My best guess is that the accelPoints doesn&#39;t like the fact that the function outputs a double, but even when i make accelPoints a double (made it equal 0.01 instead of 0) it still didn&#39;t work. If you have any thoughts on the matter, please let me know. I most likely broke it in the most silly way imaginable. Thanks for reading.</div>
<div> </div><div>Greg</div>