Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

#ActualJDCAce

Posted 29 September 2012 - 08:12 PM

Thanks a bunch for the help, guys! Looking at it now, yes, the Rectangles should be created only once. That wasn't a very good idea on my part. As for you suggestion, EngineProgrammer:

- The ball has a velocity(X,Y) and a position(X,Y) as type: double or float. Each update you do m_Position += m_Velocity; So the ball moves depending on his velocity.
- Create 1 Hitregion(Rectangle) for 1 paddle
- When the hitregion of the paddle and the ball return true...
- Calculate a vector from the center of the paddle and the center of the ball.
- Merge that vector and the velocity of the ball.
- (This depends on how the vector is calculated) you might need to reverse the X-value of the new velocity so the ball goes the other way.


... I don't know what a vector is. (I know what a vector in physics is, but I don't know anything about them in gaming/programming terms.) I'll go look it up and try out your suggestion! However, what do you mean "merge the vectors?" Is merging something I'll learn about when looking up vectors?

Also, in response to Pyrodrgn, I do have a Paddle class and a Ball class. I'm still getting used to making my own objects like this, and I'm still not very good at deciding what each class should be in charge of.

#3JDCAce

Posted 29 September 2012 - 08:10 PM

Thanks a bunch for the help, guys! Looking at it now, yes, the Rectangles should be created only once. That wasn't a very good idea on my part. As for you suggestion, EngineProgrammer:

- The ball has a velocity(X,Y) and a position(X,Y) as type: double or float. Each update you do m_Position += m_Velocity; So the ball moves depending on his velocity.
- Create 1 Hitregion(Rectangle) for 1 paddle
- When the hitregion of the paddle and the ball return true...
- Calculate a vector from the center of the paddle and the center of the ball.
- Merge that vector and the velocity of the ball.
- (This depends on how the vector is calculated) you might need to reverse the X-value of the new velocity so the ball goes the other way.


... I don't know what a vector is. (I know what a vector in physics is, but I don't know anything about them in gaming/programming terms.) I'll go look it up and try out your suggestion! However, what do you mean "merge the vectors?" Is merging something I'll learn about when looking up vectors?

#2JDCAce

Posted 29 September 2012 - 08:09 PM

Thanks a bunch for the help, guys! Looking at it now, yes, the Rectangles should be created only once. That wasn't a very good idea on my part. As for you suggestion, EngineProgrammer:

- The ball has a velocity(X,Y) and a position(X,Y) as type: double or float. Each update you do m_Position += m_Velocity; So the ball moves depending on his velocity.
- Create 1 Hitregion(Rectangle) for 1 paddle
- When the hitregion of the paddle and the ball return true...
- Calculate a vector from the center of the paddle and the center of the ball.
- Merge that vector and the velocity of the ball.
- (This depends on how the vector is calculated) you might need to reverse the X-value of the new velocity so the ball goes the other way.


... I don't know what a vector is. (I know what a vector in physics is, but I don't know anything about them in gaming/programming terms.) I'll go look those up and try out your suggestion! However, what do you mean "merge the vectors?" Is merging something I'll learn about when looking up vectors?

#1JDCAce

Posted 29 September 2012 - 06:59 PM

Thanks a bunch for the help, guys! Looking at it now, yes, the Rectangles should be created only once. That wasn't a very good idea on my part. As for you suggestion, EngineProgrammer:

- The ball has a velocity(X,Y) and a position(X,Y) as type: double or float. Each update you do m_Position += m_Velocity; So the ball moves depending on his velocity.
- Create 1 Hitregion(Rectangle) for 1 paddle
- When the hitregion of the paddle and the ball return true...
- Calculate a vector from the center of the paddle and the center of the ball.
- Merge that vector and the velocity of the ball.
- (This depends on how the vector is calculated) you might need to reverse the X-value of the new velocity so the ball goes the other way.


... I don't know what a Hitregion or a vector is. (I know what a vector in physics is, but I don't know anything about them in gaming/programming terms.) I'll go look those up and try out your suggestion! However, what do you mean "merge the vectors?" Is merging something I'll learn about when looking up vectors?

PARTNERS