Search:

Type: Posts; User: Norm

Page 1 of 2 1 2

Search: Search took 0.08 seconds.

  1. Replies
    73
    Views
    9,217

    Re: Pong game - Collision detection

    How do you know you want to change the y_inc value?
  2. Replies
    73
    Views
    9,217

    Re: Pong game - Collision detection

    Good luck learning java. You started a little late with so much to learn to get this done so soon.
  3. Replies
    73
    Views
    9,217

    Re: Pong game - Collision detection

    Then you are trying to run before learning to walk.

    Look in the code for &&. It is used in several places.
  4. Replies
    73
    Views
    9,217

    Re: Pong game - Collision detection

    Use the AND operator (&&) to connect all the conditions into a single condition.
  5. Replies
    73
    Views
    9,217

    Re: Pong game - Collision detection

    The tests for the location of the ball must all be true. Your 3 if tests were independent of each other.
  6. Replies
    73
    Views
    9,217

    Re: Pong game - Collision detection

    Can you explain in English what you are trying to write the code to test for?

    Your 3 independent if tests do not test the condition correctly.
  7. Replies
    73
    Views
    9,217

    Re: Pong game - Collision detection

    Can you describe the tests to be made for the ball at the same y values as the paddle?
    What is the purpose of the expression you posted? It gives 1 y value. The paddle has a top and a bottom.
  8. Replies
    73
    Views
    9,217

    Re: Pong game - Collision detection

    Forget about the paddle's moving for now.
    You x value for the paddle's right side looks reasonable. Now you need to see if the paddle's y values overlap where the ball is moving. The ball could go...
  9. Replies
    73
    Views
    9,217

    Re: Pong game - Collision detection

    The paddle's location is defined by the values of variables. Look at the diagram you drew on paper.

    detect one collision at a time: The ball moving to the left towards paddle1

    Don't write any...
  10. Replies
    73
    Views
    9,217

    Re: Pong game - Collision detection

    It allows you to easily change the way the code works. Say you want a longer, thinner paddle. Change the values of two variables and the new version works.
  11. Replies
    73
    Views
    9,217

    Re: Pong game - Collision detection

    Do NOT use 25. Use the variable that defines the value.
  12. Replies
    73
    Views
    9,217

    Re: Pong game - Collision detection

    Yes, look at the diagram you've drawn on paper and get the variable names from that.

    var += val is shorthand notation for var = var + val.
  13. Replies
    73
    Views
    9,217

    Re: Pong game - Collision detection

    Does that answer your question asked in post#43?
  14. Replies
    73
    Views
    9,217

    Re: Pong game - Collision detection

    What is the variable: x used for in the program? What happens visually when the value of x is changed?
  15. Replies
    73
    Views
    9,217

    Re: Pong game - Collision detection

    What does a change to the value of x do?
  16. Replies
    73
    Views
    9,217

    Re: Pong game - Collision detection

    Go to the paper and pencil diagram I asked you to draw. Label it with the variables that define the locations of the paddle and the ball. Then look at that drawing to get the variable names you...
  17. Replies
    73
    Views
    9,217

    Re: Pong game - Collision detection

    What visual thing do all those numbers represent?

    Now think in terms of the paddles. When would you want to change the sign of x_inc if the ball is moving to the left towards paddle1?
  18. Replies
    73
    Views
    9,217

    Re: Pong game - Collision detection

    Can you explain in English to show that you understand what the code is doing.
  19. Replies
    73
    Views
    9,217

    Re: Pong game - Collision detection

    The code is poorly written when it comes to meaningful variable names.

    When does the sign of x_inc change?
  20. Replies
    73
    Views
    9,217

    Re: Pong game - Collision detection

    It's not really 1, its the value of the variable: S. Change S's value and you'll see.

    When does the sign of S change from + to - and from - to +?
  21. Replies
    73
    Views
    9,217

    Re: Pong game - Collision detection

    x_inc gives what a -1?
    Can you explain what variable? How does x_inc give the other variable a -1?

    Think about how the position of the ball changes. What should happen when the ball gets to a...
  22. Replies
    73
    Views
    9,217

    Re: Pong game - Collision detection

    Describe the place where x's value is reversed using terms of the shapes, not numeric values,
    Do NOT code 790. Use the values of variables. I'm testing with a window that is 300x400 defined using...
  23. Replies
    73
    Views
    9,217

    Re: Pong game - Collision detection

    You left the assignment statement outside of the {}s


    if (..) {
    x_inc = -1*S ;
    System.out.println ("x_inc=" +x_inc);
    }

    Do you know what makes the value change and how that...
  24. Replies
    73
    Views
    9,217

    Re: Pong game - Collision detection

    Add {}s after the if and put the println inside the {}s
  25. Replies
    73
    Views
    9,217

    Re: Pong game - Collision detection

    The purpose of the println is to show you the values of variables as the code executes. How are the values of the variables used to control the logic of the execution? When is the if statement true?...
Results 1 to 25 of 36
Page 1 of 2 1 2