Okay so I am learning how to make games and stuff in java and I am using processing in that i am trying to generate a ellipse that will move constantly when fired, how I am animating is in draw() function I check for the condition when it should be fired and when the condition is true I draw the ellipse and change it new coordinates constantly. Currently my game is running at 30 fps and when I change the ellipse coordinates by small margin it moves slow but since the subsequent coordinates where ball will generate is so close it will generate close giving this slow but smooth animation, contrary to make it faster I have to increase the coordinates which give the fast but choppy animation. I am so lost as to how we actually make it faster without compromising the animation quality.
my structure looks like this
public float speed = 100;
public static final int FPS = 30;
public void draw(){
// conditions to check
if (tank.isTankfired()){
removeprojectile(tank.projectilestartX(), tank.projectilestartY());
fill(255, 0, 0); // Set the fill color to red
ellipse(tank.projectilestartX(), tank.projectilestartY(), 10, 10);
tank.setprojectilestartX(tank.projectilestartX()+speed/FPS);
tank.setprojectilestartY(tank.projectilestartY()-speed/FPS);
}
}
with this method it changes the x and y coordinate constantly and if I increase the speed it makes the distance between the next ellipse whereever it will be drawn more rather than generating it faster and since program is running at 30 fps it now looks choppy. I am new learning processing so any guidance to how it is actually handled would be grateful.
Srijan Chaudhary is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.