Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (109)
games submitted by our members
Games in WIP (536)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  [Solved] Issue with LWJGL Space Inaders Example  (Read 2014 times)
0 Members and 1 Guest are viewing this topic.
Offline gmmaster

Senior Newbie





« Posted 2013-11-08 09:22:49 »

Hello,

I am trying to run the Space Invaders example from the LWJGL wiki. This one.
http://lwjgl.org/wiki/index.php?title=Space_Invaders_Example_Game

What is odd to me is that there is no red 'x's in Eclipse and it seams like I have
properly attached all the libraries right.  

Here is the error it gives me.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
Fri Nov 08 02:26:45 CST 2013 INFO:Slick Build #237
Fri Nov 08 02:26:45 CST 2013 INFO:LWJGL Version: 2.9.0
Fri Nov 08 02:26:45 CST 2013 INFO:OriginalDisplayMode: 1440 x 900 x 32 @0Hz
Fri Nov 08 02:26:45 CST 2013 INFO:TargetDisplayMode: 800 x 600 x 0 @0Hz
Fri Nov 08 02:26:45 CST 2013 INFO:Starting display 800x600
Fri Nov 08 02:26:46 CST 2013 INFO:Use Java PNG Loader = true
Fri Nov 08 02:26:46 CST 2013 INFO:Controllers not available
Exception in thread "main" java.lang.RuntimeException: Resource not found: testdata/alphamap.png
   at org.newdawn.slick.util.ResourceLoader.getResourceAsStream(ResourceLoader.java:69)
   at org.newdawn.slick.opengl.InternalTextureLoader.getTexture(InternalTextureLoader.java:185)
   at org.newdawn.slick.Image.<init>(Image.java:192)
   at org.newdawn.slick.Image.<init>(Image.java:166)
   at org.newdawn.slick.Image.<init>(Image.java:154)
   at org.newdawn.slick.Image.<init>(Image.java:132)
   at org.newdawn.slick.tests.AlphaMapTest.init(AlphaMapTest.java:33)
   at org.newdawn.slick.AppGameContainer.setup(AppGameContainer.java:393)
   at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:317)
   at org.newdawn.slick.tests.AlphaMapTest.main(AlphaMapTest.java:79)



Thank you so much for reading this and trying to help. Smiley

loopish's brother Cheesy
Offline philfrei
« Reply #1 - Posted 2013-11-08 09:55:29 »

Did you find and load the resource files mentioned in the instructions?

The error code is saying that it can't locate alphamap.png, which is a graphical resource used in the program. It may be that you have to create/add the filefolder "testdata" to the project and move the resources to that location. Have you loaded resources before?

I ran this tutorial once, I think it was in August, but have since deleted the project, and can't remember exactly what all I had to do to get it to work.

"Greetings my friends! We are all interested in the future, for that is where you and I are going to spend the rest of our lives!" -- The Amazing Criswell
Offline gmmaster

Senior Newbie





« Reply #2 - Posted 2013-11-08 10:09:07 »

It's possible I didn't load it right? I just made a folder in my workspace project folder called 'res' and put all the files that came with lwjgl in there. I also made a folder called testdata because I thought that might work, though it didn't. The odd thing is that there is no file named 'alphamap.png' that I could find with the lwjgl resources. Is it possible this has to do something with the slick library?? There were no errors with the red Xs which it normally does when I don't have the correct packages imported. Tongue

EDIT: wow, I just found that this same exact error is happening for me on a completely different project folder. What is odd is that this other project is not using the slick libraries at all...

loopish's brother Cheesy
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline philfrei
« Reply #3 - Posted 2013-11-08 21:20:09 »

You are not alone...
http://stackoverflow.com/questions/15054512/error-when-hitting-run-in-eclipse-2d
(LOL--I was doing a search on alphamap.png and the above came up.)


BTW, questions about loading resources come up a LOT, as getting the addressing right, especially in jars. So, it doesn't surprise me that the problem comes up in an entirely separate context.

The Java Tutorials section that deals with resource loading is here:
http://download.oracle.com/javase/tutorial/uiswing/components/icon.html
They are discussing this in the context of loading an image into an icon, but the part about loading images in general and about the relative addressing still pertain.

You might consider going through this set of Space Invaders tutorials instead:
http://www.cokeandcode.com/main/tutorials/space-invaders-101/

There are four versions, and if I remember correctly, 104 uses LWJGL. I recall getting 3 of them to work--I remember skipping one of them.

I also wonder if the file is part of the Slick download, if there are some resources packed with the full distribution.
http://slick.ninjacave.com/

The writer Kevin Glass is listed with JGO, and often comments/contributes. But since he officially handed this code off, he might not wish to be asked maintenance questions. I really don't know him well enough to say.

"Greetings my friends! We are all interested in the future, for that is where you and I are going to spend the rest of our lives!" -- The Amazing Criswell
Offline Vladiedoo
« Reply #4 - Posted 2013-11-08 21:30:35 »

I couldn't explain in depth why it occurs but I believe your issue might be the following.

You can make Source Folders or regular Folders while in Eclipse.

If you have a regular folder you will need to do "res/testdata/alphamap.png".
If you have a source folder you can do "testdata/alphamap.png".

So try "res/testdata/alphamap.png" and if that doesn't work, post a screenshot.

Good luck.
Offline Magn919

Junior Member


Medals: 6
Exp: 4 years



« Reply #5 - Posted 2013-11-09 00:17:55 »

Hi gmmaster, you are getting that error, because you are not running your own main method.

The slick library contains numerous example programs, each with its own main method.

At the time you first attempted to run your code, you may not have had focus on the editor or may have had another class open, so eclipse couldn't find a main method.
This makes it search the build path for a main method, and it finds all those inside Slick and sorts them alphabetically, and picks the first (it may have shown a dialog too).
So you are actually running AlphaMapTest.java, it says that in the stack trace too, and as another feature of eclipse it remembers which file you ran last, so it keeps running that when you click the run button.

A simple solution is to open your own class in the editor, right click in the editor, and run it from there, this it should remember too, so doing it once should be enough.

For every new problem, a new source of solutions has come to exist.
Offline gmmaster

Senior Newbie





« Reply #6 - Posted 2013-11-09 08:19:42 »

Thank you everyone!!

Especially Magn919 for the solution and easy fix and philfrei for all the links and info.

loopish's brother Cheesy
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

CogWheelz (18 views)
2014-07-30 21:08:39

Riven (26 views)
2014-07-29 18:09:19

Riven (15 views)
2014-07-29 18:08:52

Dwinin (13 views)
2014-07-29 10:59:34

E.R. Fleming (34 views)
2014-07-29 03:07:13

E.R. Fleming (12 views)
2014-07-29 03:06:25

pw (43 views)
2014-07-24 01:59:36

Riven (44 views)
2014-07-23 21:16:32

Riven (30 views)
2014-07-23 21:07:15

Riven (31 views)
2014-07-23 20:56:16
List of Learning Resources
by SilverTiger
2014-07-31 18:29:50

List of Learning Resources
by SilverTiger
2014-07-31 18:26:06

List of Learning Resources
by SilverTiger
2014-07-31 13:54:12

HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!