File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes can not move the paddle in this program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "can not move the paddle in this program" Watch "can not move the paddle in this program" New topic
Author

can not move the paddle in this program

komaravolu raju
Greenhorn

Joined: Oct 25, 2010
Posts: 11
Hello friends.

Now, I am trying to write a program for ball breaker game.
I have read some pages in after searching google.com and found, instead of using ball (round), we can also use the squares.
So, trying to write the code.
here is the code

Now, the issue is that I want to add some keyboard events to the paddle and make it move.
I tried to add the action Listeners to to it and the paddle is not working.



can any one help me how to do it???
More over when the ball touches the ground, the game should be over and
Lester Burnham
Rancher

Joined: Oct 14, 2008
Posts: 1337
You're not adding a KeyListener anywhere. There should be an "addKeyListener(this)" statement in the MyBall constructor.
komaravolu raju
Greenhorn

Joined: Oct 25, 2010
Posts: 11
I am sorry. I did not notice it...
thanks for your help.
I did that.

But, after adding the action listener, I could move the paddle only 1 time in both left and right.
and please let me know how to approach for other questions.

thanks in advance.
Lester Burnham
Rancher

Joined: Oct 14, 2008
Posts: 1337
But, after adding the action listener, I could move the paddle only 1 time in both left and right.

That's explained by this code:

Hitting the left/right keys moves the paddle to an absolute position; what it should do is to move it to a position relative to the current one (which you would have to track in some variable).
komaravolu raju
Greenhorn

Joined: Oct 25, 2010
Posts: 11
Thanks for your support.
I got up to the movement of the paddle and displaying the bricks in the screen.

But, I could not manage to make the bricks vanish when they are each one is hit by the ball.

here is the code for that.




can any one give me some suggestion......
That would be of great help...

komaravolu raju
Greenhorn

Joined: Oct 25, 2010
Posts: 11
oh..

finally I have done the game..
and from there, I have also done the target bouncer game also with the same concept...

thanks for your support..



 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: can not move the paddle in this program