File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

can not move the paddle in this program

 
komaravolu raju
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1337
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're not adding a KeyListener anywhere. There should be an "addKeyListener(this)" statement in the MyBall constructor.
 
komaravolu raju
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1337
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic