Search:

Type: Posts; User: 123099

Search: Search took 0.12 seconds.

  1. Replies
    21
    Views
    2,490

    Re: Help with KeyListener and graphics

    Thank you all for your help.
    I've finally finished my project.
    Thanks a lot for all your help!
  2. Replies
    21
    Views
    2,490

    Re: Help with KeyListener and graphics

    The problem was this line:


    if(ball.getX() - (ball.getDiameter()/2)<p1.getX() + p1.getWidth() || ball.getX() + (ball.getDiameter()/2)> p1.getX()){

    The expression was always true because i...
  3. Replies
    21
    Views
    2,490

    Re: Help with KeyListener and graphics

    From the debugging I found the problem.
    It always draws the ball at x - 0, y-1 and it never changes although the other functions are executed till the end.
    The problem was that I've sent to the...
  4. Replies
    21
    Views
    2,490

    Re: Help with KeyListener and graphics

    I'm always doing this, and when I did this all the ball methods execute normally till the end, but it just wont show on the screen.
    And the results after modifying the code again were that the ball...
  5. Replies
    21
    Views
    2,490

    Re: Help with KeyListener and graphics

    Oh right, I was using it before I have modified the code.
    Ill check it and I'll post the results.
  6. Replies
    21
    Views
    2,490

    Re: Help with KeyListener and graphics

    But the problem is, that I'm also using the drawMe function inside the class itself, thus I'll need to send a Graphics object within the class itself also each time I'm using the drawMe() function....
  7. Replies
    21
    Views
    2,490

    Re: Help with KeyListener and graphics

    Here is the code.
    But I have a problem, the ball won't draw, although it moves.
    Main Class:


    /*
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    ...
  8. Replies
    21
    Views
    2,490

    Re: Help with KeyListener and graphics

    never mind solved this bu sending the main object to the racket class through the racket's constructor.
    But if you have a better way to solve this please share.
  9. Replies
    21
    Views
    2,490

    Re: Help with KeyListener and graphics

    ok thanks, but now I have another problem.
    How can I use the reapint method through the Racket class without causing a recursion?
    The problem is that I need to create a new Main object and then use...
  10. Replies
    21
    Views
    2,490

    Re: Help with KeyListener and graphics

    I've changed the code as you said, but the rackets still refuse to move
    this is the new codes(not a lot of difference)
    Main:


    /*
    * To change this template, choose Tools | Templates
    * and...
  11. Replies
    21
    Views
    2,490

    Re: Help with KeyListener and graphics

    Main:


    /*
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    */

    package pongnew;
  12. Replies
    21
    Views
    2,490

    Help with KeyListener and graphics

    I'm making a small pong game, in which there are 2 rackets - 1 of them is moved y the up and down arrows by the user.
    Now, the problem is that when I'm pressing the up and down keys the racket won't...
Results 1 to 12 of 12