Pong游戏与图形类和继承问题

时间:2013-02-28 23:08:22

标签: eclipse inheritance graphics pong

我已经开设了这个实验课,可以创建一个像乒乓球一样的游戏,并且我已经将以下链接中相应的.java文件放在了pastebin上:

Ball.javahttp://pastebin.com/VMg75i8U

Block.javahttp://pastebin.com/T7GCTh4z

BallTestTwo.javahttp://pastebin.com/gZgR8d2J

Tester.javahttp://pastebin.com/fG5f5zZR

Locatable.javahttp://pastebin.com/GE77PLJk

我的问题是我已经让这些块运行得很好,因为我可以运行Tester.java并将球线注释掉并得到我想要的结果。但是,当我在没有注释球线的情况下运行它时,我会得到错误并且只是一个空白的白色画布。

如果您需要澄清最终结果应该是什么,这里是实验室描述的文档文档的链接。 https://docs.google.com/file/d/0B_ifaCiEZgtcTVFPX0t2Mzhzczg/edit?usp=sharing https://docs.google.com/file/d/0B_ifaCiEZgtcMFVWYXIxdjZsdDQ/edit?usp=sharing

修改 我收到的错误是永远重复的,直到我强制终止程序:

at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$200(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at BallTestTwo.paint(BallTestTwo.java:42)
    at BallTestTwo.update(BallTestTwo.java:37)
    at sun.awt.RepaintArea.updateComponent(Unknown Source)
    at sun.awt.RepaintArea.paint(Unknown Source)
    at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$200(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)

0 个答案:

没有答案