• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

A problem in my PONG game code

 
max wang
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


I change the code, PONG game works. But there is a new problem, the hit score and misses score must show in the title bar of frame. mp.setTitle("Pong Demo"+"hit="+hit+"misses:"+misses); cannot show the score. The problem is that I cannot send the hit and misses variable to the frames. when they change.

[ May 27, 2008: Message edited by: max wang ]
[ May 27, 2008: Message edited by: max wang ]
 
Darryl Burke
Bartender
Posts: 5125
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Comments:

Key events are received only by the focus owner, for this kind of application you would be better served by using key bindings.
The Java Tutorials: How to Use Key Bindings.

What key listener do you add to DrawPanel dp? Did you really mean to add a new KeyCnt()? What is the code in that class? since you didn't post it.

At two places in the code posted, you have else without if. The purpose of posting code is defeated if the code posted has syntax errors. (except where the problem is the syntax error)

And when all else is sorted out, you're going to discover that the down arrow moves the paddle up and vice versa
 
max wang
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Darryl , I made a mistake on post in stead of the source code. I try to fix according to your comment. Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic