Hello,
This was in my Drafts and a late response… it may still be helpful to some.
It is because the math is exceeding the maximum value of an integer at some point in the code:
https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html
This code shows what happens to y1
when millis()
(an integer) is greater than 14654:
The above code shows where the point of concern is in the code.
You are using millis()/1000
for time.
Consider using this floating point division in your code along with floating point math throughout:
float t = millis()/1000.0; // Result is floating point
Use this if you intend to use integer math with 1 sec increments:
float t = millis()/1000; // Result is an integer
Your code will look much cleaner and identifiable as the equation to a parabola:
float y = 20*t*t -100*t+ 200;
:)