Movement "lagging" VS smoothness

I am mnodeling an aircraft. For now I would like to put aside the physics part of the program. However, I have the following issue - it is as if the object is not moving smoothly but rather in steps that I can notice. May be it is just me, but maybe there are other things I do not consider.

PVector velocity, acceleration, location;
PVector friction; //the force of friction
PVector fricAcc; // the acc due to friction

float k = 0.03; // the coeff of friction
float angle = 2; //the step with which the angle is changed

float mass = 1; //the mass
float maxEngineForce = 0.1; //the masimum frust force

void setup() {
  frameRate (70); //have no idea whether this part works at all

  location     = new PVector (100,100);
  velocity     = new PVector (0,0);
  acceleration = new PVector (0,maxEngineForce/mass);

  friction = new PVector (0,0);
  fricAcc = new PVector (0,0);

  size (1000,1000);


void draw () {
background (40);

fill (50);
ellipse (location.x, location.y, 50,50);

//calculating movement
location.add (velocity);
velocity.add (acceleration);

//calculating the force of friction F = -kv
friction.set (-velocity.x, -velocity.y);
friction.mult (k);

//calculating the acc due to friction a = F/m
fricAcc.set (friction.x, friction.y);
fricAcc.mult (1/mass);
velocity.add (fricAcc);

//showing the vector of acceleration
 pushMatrix ();
     translate (location.x, location.y);
     PVector show = new PVector (acceleration.x, acceleration.y);
     show.mult (1000);

     line (0,0, show.x, show.y);


//changing the direction of the acceleration
void keyPressed () {

  if (key == 'w') {

  if (key == 'a') {
  acceleration.rotate (radians(angle));

  if (key == 'd') {
  acceleration.rotate (radians(-angle));

println (angle); //needed for debugging



  • Answer ✓

    Have you to tried to make the program print the frameRate? If the frameRate is below 12 you brain sees each frame ås å picture, and 12 or more frames second is so fast the brain just assumes it's movement.

    Setting the frameRate will have no effect if setting is slowing the programme down. When setting the frameRate you are only setting an upper limit.

Sign In or Register to comment.