Jump to content
  • Advertisement
Sign in to follow this  

"Developing Games in Java"

This topic is 2970 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
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.

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
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!