Because whenever it hits the paddle box, it goes down every time. I'm wondering if theres a way that the ball hits the paddle makes it go up or down. But if it requires a bit more work I guess I'll...
Type: Posts; User: Hokap
Because whenever it hits the paddle box, it goes down every time. I'm wondering if theres a way that the ball hits the paddle makes it go up or down. But if it requires a bit more work I guess I'll...
Yeah I'm slacked a bit.
But I solved it
{
if ( x <= p1X+p1Width && x >=p1X)
if (y >=p1Y && y <= p1Y+p1Height ) {
x_inc = 1*S;
y_inc = 1*S;
Guess its closed.
Thanks for the help Norm.
Even though I didn't get anything accomplished.
It was just a code I found that created a paddle.
Oh well, guess I'll send the code like this, only have two hours left before submitting time.
No clue on how to use that. My knowledge of java programming is very low.
How would I go about coding it?
I'm trying to make it so when the ball hits the paddle, it bounces off it. I read about the intersect code but I'm not sure how that works.
So the whole of the paddle should make it bounce back. ...
So the code should look something like
if ( x >= p1X+p1Width+HALF_BALL_SIZE ) x_inc = -1*S;
if ( y >= p1Y+p1Height+p1Width+HALF_BALL_SIZE ) y_inc = -1*S;
if ( y >=...
Then the y value would be
p1Y + p1Height
Would I need to write seperate things for the x and y values? Or could they be incased in the same ()?
Well I know it has to hit the right side of the left paddle.
This would require p1X + p1Width since that would equate to the top right side of it.
Do I have to also include the pPU? Since it is...
Still can't get around how to collide with the ball and paddle.
I've changed the rect to
g.setPaint( Color.black );
g.fillRect( p1X, p1Y, p1Width, p1Height);
Not sure how the format for...
That means I have to change the
g.setPaint( Color.black );
g.fillRect( p1X, p1Y, 25, 60);
values?
Alright so I got
if ( x >= 1PX + 25 ) - Not sure what else to put.
Was wondering what the += means.
Also how would I get started on collision detecting the paddle and the ball?
Is it similar to the layout of the wall collision?
The ball position
Hmm? Don't understand that question.
X variables for paddle is p1X , Y is p1Y.
Ball position is x and y?
Also what does this part mean?
x += x_inc;
y += y_inc;
Thanks for the help btw. Might as well learn how to understand it,...
When it touches the right side of paddle 1.
I'm not sure what varibles to put in there, would I be using p1X ?
if ( x >= W-B-HALF_BALL_SIZE ) x_inc = -1*S;
if x is greater or equal to the width - border offset - halfballsize, it would then call forth x_inc and multiply S by -1. Therefore creating a making...
if ( x >= W-B-HALF_BALL_SIZE ) -1
if ( x <= 0+B+HALF_BALL_SIZE ) 1
When either of these conditions are met.
Yeah I was given it and had to make a pong game, the only parts I added were the...
Oh is that what S is for....... Yeah I changed S to 5 and when it hit a wall it sped up.
The S changes depending on the condition that is met I'm guessing.
As it is -1 or 1 * S.
When it goes to the right it gets 1 which adds to the x value, while going to the left gives it a -1
x >= W - Halfballsize
I know x_inc gives it a -1, but I don't understand how it does that.
Ermm
Is it, if x is greater than the width - border offset - hall ball size it changes direction? and gives -1 values to x until it reaches the other side
So if x > 790 it reverses and gives x...
if ( x >= W-B-HALF_BALL_SIZE ) x_inc = -1*S {System.out.println (x_inc)}; ?
Did that and I just see 1 when its moving to the right, and -1 when its moving to the left.