Heya

I've been studying programming in java for 2 months and we're supposed to make the game Asteroids using StdDraw (http://introcs.cs.princeton.edu/java/stdlib/javadoc/StdDraw.html).
I've pretty much completed the program and it's working very well expect for the fact that it crashes when I'm around 4-6 mins in the game.
As a newbie I'm not 100% sure how its best to do this but I ended up building it around using methods that use other methods and those methods often use the original one etc. so I guess you could say it's an endless loop.
Here is the error:
Exception in thread "main" java.lang.StackOverflowError
at java.security.AccessControlContext.optimize(AccessControlContext.java:394)
at java.security.AccessController.getContext(AccessController.java:501)
at java.awt.AWTEvent.<init>(AWTEvent.java:106)
at java.awt.event.InvocationEvent.<init>(InvocationEvent.java:224)
at java.awt.event.InvocationEvent.<init>(InvocationEvent.java:188)
at java.awt.event.InvocationEvent.<init>(InvocationEvent.java:150)
at javax.swing.RepaintManager.scheduleProcessingRunnable(RepaintManager.java:1380)
at javax.swing.RepaintManager.addDirtyRegion0(RepaintManager.java:434)
at javax.swing.RepaintManager.addDirtyRegion(RepaintManager.java:474)
at javax.swing.JFrame.repaint(JFrame.java:777)
at java.awt.Component.repaint(Component.java:3286)
at StdDraw.draw(StdDraw.java:842)
at StdDraw.show(StdDraw.java:820)
at Game.updateGame(Game.java:107)
at Game.printGame(Game.java:95)
at Game.updateGame(Game.java:108)
at Game.printGame(Game.java:95)
at Game.updateGame(Game.java:108)
..............
...............(like 500 times)
...............
at Game.printGame(Game.java:95)
at Game.updateGame(Game.java:108)
Edit: I also seem to get this sometimes
Exception in thread "main" java.lang.StackOverflowError
at java.util.EventObject.<init>(EventObject.java:54)
at java.awt.AWTEvent.<init>(AWTEvent.java:337)
at java.awt.event.InvocationEvent.<init>(InvocationEvent.java:224)
at java.awt.event.InvocationEvent.<init>(InvocationEvent.java:188)
at java.awt.event.InvocationEvent.<init>(InvocationEvent.java:150)
at javax.swing.RepaintManager.scheduleProcessingRunnable(RepaintManager.java:1380)
at javax.swing.RepaintManager.addDirtyRegion0(RepaintManager.java:434)
at javax.swing.RepaintManager.addDirtyRegion(RepaintManager.java:474)
at javax.swing.JFrame.repaint(JFrame.java:777)
at java.awt.Component.repaint(Component.java:3286)
at StdDraw.draw(StdDraw.java:842)
at StdDraw.show(StdDraw.java:820)
at Game.gameLoop(Game.java:107)
at Game.printGame(Game.java:95)
........................
........................
.........................
at Game.printGame(Game.java:95)
at Game.gameLoop(Game.java:108)
edit: Sometimes I get this
Exception in thread "main" java.lang.StackOverflowError
at java.util.EventObject.<init>(EventObject.java:54)
I googled this, found out that it's because of the endless loops but I have no idea how to fix this. I guess java has some kinda endless loop security, right? Why am I not allowed to loop this forever? :/
Can I change the amount of times my program can loop so I can at least have 15+min of play time. :/
Is perhaps the amount of memory it's taking? I monitored task manager while playing and it was pretty stable at ~140-160K
This post was edited by Molek on Nov 9 2013 02:53pm