I have been doing front and back end web programming for over a year now, and now I am trying to learn 2D game programming in Java. Based on various sources on the web as well as one from my friend who is an experienced game developer, this is a typical setup:
Window.java | Window setup class
Game.java | Main game class
But when I attempt to run the Game
class, the frame opens and then freezes, the only thing I have control of is my mouse, nothing else. I know the problem occurs in the render
method, because the program runs fine when that method has an empty body.
I copied the code exactly from the tutorial in which it runs fine, and my friend who sent me an almost identical version which works on his computer, causes the same freeze for me. In both the tutorial and my friend's testing, the operating system is Windows, which causes me to believe that this is strictly an Ubuntu/Linux problem.
I have an Intel i7 3.4gHZ processor, and 8 gigs of RAM, so processing and memory shouldn't be the issue here. Any ideas of what is going on? I know that this is more of a programming question, but the fact that the problem seems to be Ubuntu-specific leads me to post it here.
EDIT
I've isolated the problem to one line in the Game class: bs.show()
. For some reason, it is freezing as soon as I try to show the buffer strategy. If I create the buffer strategy with 1 buffer, it works fine, with anything greater than 1, it freezes.
When it froze the most recent time, I opened a virtual desktop and ran top
, the weirdest thing is that Java was taking up less than 2% CPU and 6% memory. That just doesn't add up. I really need some help for what is going on here, I've gone about as far as I can go and I don't want to force any more restarts on my machine.