How do you know you want to change the y_inc value?
Type: Posts; User: Norm
How do you know you want to change the y_inc value?
Good luck learning java. You started a little late with so much to learn to get this done so soon.
Then you are trying to run before learning to walk.
Look in the code for &&. It is used in several places.
Use the AND operator (&&) to connect all the conditions into a single condition.
The tests for the location of the ball must all be true. Your 3 if tests were independent of each other.
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.
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.
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...
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...
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.
Do NOT use 25. Use the variable that defines the value.
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.
Does that answer your question asked in post#43?
What is the variable: x used for in the program? What happens visually when the value of x is changed?
What does a change to the value of x do?
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...
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?
Can you explain in English to show that you understand what the code is doing.
The code is poorly written when it comes to meaningful variable names.
When does the sign of x_inc change?
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 +?
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...
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...
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...
Add {}s after the if and put the println inside the {}s
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?...