Search:

Type: Posts; User: Hokap

Page 1 of 2 1 2

Search: Search took 0.18 seconds.

  1. Replies
    73
    Views
    2,485

    Re: Pong game - Collision detection

    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...
  2. Replies
    73
    Views
    2,485

    Re: Pong game - Collision detection

    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;
  3. Replies
    73
    Views
    2,485

    Re: Pong game - Collision detection

    Guess its closed.

    Thanks for the help Norm.

    Even though I didn't get anything accomplished.
  4. Replies
    73
    Views
    2,485

    Re: Pong game - Collision detection

    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.
  5. Replies
    73
    Views
    2,485

    Re: Pong game - Collision detection

    No clue on how to use that. My knowledge of java programming is very low.
  6. Replies
    73
    Views
    2,485

    Re: Pong game - Collision detection

    How would I go about coding it?
  7. Replies
    73
    Views
    2,485

    Re: Pong game - Collision detection

    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. ...
  8. Replies
    73
    Views
    2,485

    Re: Pong game - Collision detection

    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 >=...
  9. Replies
    73
    Views
    2,485

    Re: Pong game - Collision detection

    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 ()?
  10. Replies
    73
    Views
    2,485

    Re: Pong game - Collision detection

    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...
  11. Replies
    73
    Views
    2,485

    Re: Pong game - Collision detection

    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...
  12. Replies
    73
    Views
    2,485

    Re: Pong game - Collision detection

    That means I have to change the

    g.setPaint( Color.black );
    g.fillRect( p1X, p1Y, 25, 60);

    values?
  13. Replies
    73
    Views
    2,485

    Re: Pong game - Collision detection

    Alright so I got

    if ( x >= 1PX + 25 ) - Not sure what else to put.
  14. Replies
    73
    Views
    2,485

    Re: Pong game - Collision detection

    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?
  15. Replies
    73
    Views
    2,485

    Re: Pong game - Collision detection

    The ball position
  16. Replies
    73
    Views
    2,485

    Re: Pong game - Collision detection

    Hmm? Don't understand that question.
  17. Replies
    73
    Views
    2,485

    Re: Pong game - Collision detection

    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,...
  18. Replies
    73
    Views
    2,485

    Re: Pong game - Collision detection

    When it touches the right side of paddle 1.
    I'm not sure what varibles to put in there, would I be using p1X ?
  19. Replies
    73
    Views
    2,485

    Re: Pong game - Collision detection

    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...
  20. Replies
    73
    Views
    2,485

    Re: Pong game - Collision detection

    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...
  21. Replies
    73
    Views
    2,485

    Re: Pong game - Collision detection

    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.
  22. Replies
    73
    Views
    2,485

    Re: Pong game - Collision detection

    When it goes to the right it gets 1 which adds to the x value, while going to the left gives it a -1
  23. Replies
    73
    Views
    2,485

    Re: Pong game - Collision detection

    x >= W - Halfballsize
    I know x_inc gives it a -1, but I don't understand how it does that.
  24. Replies
    73
    Views
    2,485

    Re: Pong game - Collision detection

    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...
  25. Replies
    73
    Views
    2,485

    Re: Pong game - Collision detection

    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.
Results 1 to 25 of 38
Page 1 of 2 1 2