Well, thanks all you guys for the help and tips. Everything works fine and moving on with the creation.
By the way, speaking about JFrames container in Snake class, my way works fine as well:
...
Type: Posts; User: Asido
Well, thanks all you guys for the help and tips. Everything works fine and moving on with the creation.
By the way, speaking about JFrames container in Snake class, my way works fine as well:
...
132: appleX = x[random.nextInt(30)];
140: locateApple();
The problem is I guess because paint method is called first, and then the Board constructor which initializes x and y arrays.
I did like aussiemcgr suggested me, but now I get tons of NullPointerExceptions.
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at...
Looking at the output after doing that looks everything ok.
apple: sun.awt.image.ToolkitImage@5fcf29
head: sun.awt.image.ToolkitImage@125844f ...
That's embarrassing. I couldn't see that for 3 hours. But unfortunately this didn't solved the problem though. I still can't see the images.
The previous code throws many NullPointerExceptions after...
So I am making a simple snake game and have this problem. The pictures just doesn't load. Can anybody tell me what I did wrong?
import java.awt.Container;
import java.awt.Graphics;
import...