"Developing Games in Java"

Started by
2 comments, last by wittler55 13 years, 7 months ago
I have some Java Programming Experience so I bought "Developing Games in Java" book. Everything was going well until chapter 5, which I make a side scroller game. I downloaded the code from his website:

http://www.brackeen.com/javagamebook/

The main class file of chapter 5 is unable to import packages from other folders. I fixed this easly by moving the main class elsewhere to where it can easly find other packages and import them.
-Now it compile without errors!-
But when I try to run there file im pilled with errors:

Exception in thread "main" java.lang.IllegalArgumentException: Width (-1) and height (-1) cannot be <= 0
at java.awt.image.DirectColorModel.createCompatibleWritableRaster
at java.awt.GraphicsConfiguration.createCompatibleImage
at com.brackeen.javagamebook.tilegame.ResourceManager.getScaledImage
at com.brackeen.javagamebook.tilegame.ResourceManager.getMirrorImage
at com.brackeen.javagamebook.tilegame.ResourceManager.loadCreatureSprites
at com.brackeen.javagamebook.tilegame.ResourceManager.<init
at com.brackeen.javagamebook.tilegame.GameManager.init
at com.brackeen.javagamebook.test.GameCore.run

I researched on the internet for a long time and found no one who came across any errors with any of the books source code. Any help at all? All the other book's source codes run fine execpt chapter 5. Maybe it's JCreator or a newer verson of Java.

Advertisement
Have you tried setting a breakpoint before that evaluation where width and height are incorrectly valued at -1? Or even where those variables are given a value?

Try to find out where they are being set to that value and determine what is causing them to be -1.

JDDeal
Seems like the images cannot be loaded correctly. Make sure all the images are accessible to the program when you run it. I downloaded the zip for chapter 5 and there's an images folder with many PNG images in it.
Were you able to successfully run it? And if so, which IDE do you use?

This topic is closed to new replies.

Advertisement