Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 11 Nov 2008
Offline Last Active Feb 04 2016 06:23 PM

Posts I've Made

In Topic: Still confused about "static"

07 October 2012 - 12:51 AM

I think I'm starting to understand. Thanks!

In Topic: Pong Hit Detection

01 October 2012 - 02:49 PM

I agree, ShadowValence. I worked on my coding and I think it's a lot cleaner and a bit more efficient now. Like I said, I found the math elsewhere, so I won't claim that as mine, but after a lot of working, I think I understand it. Also, as EngineProgrammer suggested, I made only one Rectangle per paddle (and one per ball), and saved the values in the respective class (ie, leftPaddle.rectangle). I added an Update() method to the Paddle class in which the values of the rectangle are updated, using rectangle.X and rectangle.Y, instead of creating a whole new rectangle each Update().

This project really has turned out to be a valuable learning experience, and I can't thank all of you enough!


In Topic: Pong Hit Detection

30 September 2012 - 08:00 PM

Thank you very much, EngineProgrammer! I think this will still be tough, but you've given me a great head start!

UPDATE: It works! Using some math I found elsewhere, I got my program to run flawlessly! Now for my next project: Randomly-dropped power-ups!

In Topic: Pong Hit Detection

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 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.

In Topic: Starting Puzzle With Solution

23 September 2012 - 10:05 AM

Those sound like good starting points. Thanks for the help! I just Googled procedural map generation, and it looks just like what I needed.