Jump to content

  • Log In with Google      Sign In   
  • Create Account


#Actualincertia

Posted 20 October 2012 - 09:18 PM

here is the code I am using

if(right_paddle>=-220)
  {
  right_paddle=-right_paddle_vel;
  }
  if(right_paddle<=220)
  {
  right_paddle+=right_paddle_vel;
  }


Your paddle appears to be doing the following:
If your paddle position is greater than -220, it's position will be set to -right_paddle_vel. I'm going to assume right_paddle_vel is less than 220, so it seems as if it will be stuck there.
Otherwise, we will keep moving it at a speed of right_paddle_vel.

Maybe you want to do this.

if(paddle_y > ball_y){
  paddle_y -= vel;
}
else if(paddle_y < ball_y){
  paddle_y += vel;
}

where vel is some positive number.

#3incertia

Posted 20 October 2012 - 09:16 PM

here is the code I am using

if(right_paddle>=-220)
  {
  right_paddle=-right_paddle_vel;
  }
  if(right_paddle<=220)
  {
  right_paddle+=right_paddle_vel;
  }


Your paddle appears to be doing the following:
If it is at the bottom of the screen, it's position will be set to -right_paddle_vel.
Otherwise, we will keep moving it at a speed of right_paddle_vel.

Maybe you want to do this.

if(paddle_y > ball_y){
  paddle_y -= vel;
}
else if(paddle_y < ball_y){
  paddle_y += vel;
}

where vel is some positive number.

#2incertia

Posted 20 October 2012 - 09:16 PM

here is the code I am using

if(right_paddle>=-220)
  {
  right_paddle=-right_paddle_vel;
  }
  if(right_paddle<=220)
  {
  right_paddle+=right_paddle_vel;
  }


Your paddle appears to be doing the following:
If it is at the bottom of the screen, it's position will be set to -right_paddle_vel.
Otherwise, we will keep moving it at a speed of right_paddle_vel.

Maybe you want to do this.

[code=auto:0]
if(paddle_y > ball_y){
paddle_y -= vel;
}
else if(paddle_y < ball_y){
paddle_y += vel;
}
[code=auto:0]

where vel is some positive number.

#1incertia

Posted 20 October 2012 - 09:16 PM

here is the code I am using

if(right_paddle>=-220)
  {
  right_paddle=-right_paddle_vel;
  }
  if(right_paddle<=220)
  {
  right_paddle+=right_paddle_vel;
  }


Your paddle appears to be doing the following:
If it is at the bottom of the screen, it's position will be set to -right_paddle_vel.
Otherwise, we will keep moving it at a speed of right_paddle_vel.

Maybe you want to do this.

[source lang="cpp"]if(paddle_y > ball_y){ paddle_y -= vel;}else if(paddle_y < ball_y){ paddle_y += vel;}[/source]

where vel is some positive number.

PARTNERS