• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

A problem in my PONG game code

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
The moth suit and wings road is much more exciting than taxes. Or this tiny ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic