Sign in to follow this  

"Developing Games in Java"

Recommended Posts

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:

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

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.

Share this post

Link to post
Share on other sites
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.


Share this post

Link to post
Share on other sites
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.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this