So I try to create a small Zombie-Shooter game. I use a GTurtle class from ACM package (jtf.acm.org). I have additional thread for a GTurtle, which is a GObject. I have a run method with while loop, that is checking if boolean is true, if it is – this.forward() method gets executed.
I tried running game and pressing button, if it is W or D, boolean in GTurtle object gets changed and Thread executes action. Then I get this exception:
java.lang.NullPointerException
at java.util.Hashtable.put(Hashtable.java:394)
at acm.util.JTFTools.pause(JTFTools.java)
at acm.util.Animator.delay(Animator.java)
at acm.graphics.GTurtle.setLocation(GTurtle.java)
at acm.graphics.GObject.move(GObject.java)
at acm.graphics.GTurtle.move(GTurtle.java)
at acm.graphics.GObject.movePolar(GObject.java)
at acm.graphics.GTurtle.forward(GTurtle.java)
at anotherTryJava.Player.run(Player.java:20)
at java.lang.Thread.run(Thread.java:662)
Judging by the source code for
Hashtable.putyou either passedkeyparameter withnullorvalueparameter withnullor bothnull.From Javadoc.
Note: I do not know the version of the JDK you are using (link below does not have a line 394 matching with your version), although the reasoning remains valid!
http://www.docjar.com/html/api/java/util/Hashtable.java.html