Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (754)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (842)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Game Development / Newbie & Debugging Questions / Re: Loading a Bufferedimage on: 2013-08-29 23:53:13
Wow. You didn't need to go so far as to spend some time making an example. But thanks a bunch for the help.

[Edit] : Success. I get a proper .jar, it seems. I had to clean up another issue with sounds, but it works. Phew. Sorry for being such a blockhead, anyway.
2  Game Development / Newbie & Debugging Questions / Re: Loading a Bufferedimage on: 2013-08-29 20:57:38
My bad, the images were also stored elsewhere.
Anyways, I'm pretty tired right now. I'll read up more on it tomorrow and hopefully be able to work things out a bit more than I am right now. Thank you for your help, anyway, all of you.
3  Game Development / Newbie & Debugging Questions / Re: Loading a Bufferedimage on: 2013-08-29 20:27:43
All right. So using this new structure, taking inspiration from your other topic :


public static Bitmap title = loadBitmap("title.png");

with loadBitmap containing :
BufferedImage img =;

This is a relative path, yes ?

It works fine for images, which is nice.
However, it fails to do so for sounds afterwards, and I don't understand why :

public static Sound shoot = loadSound("shoot.wav");
AudioInputStream ais = AudioSystem.getAudioInputStream((Sound.class.getClassLoader().getResourceAsStream(filename)));

[Edit] : Something I'd forgotten to mention : I hadn't added my res folder to the build path as a source folder. However, when I did so, images stopped working. Removing the folder from the build path didn't start making the images load properly as before, so there's some otehr subtlety going on I don't know about, apparently.
4  Game Development / Newbie & Debugging Questions / Re: Loading a Bufferedimage on: 2013-08-29 19:34:30
My apologies, jonjava, but I was answering davidc's question.

And I have looked at the first topic you mentioned (but not all the others -yet). However, it does not seem to answer my question regarding Linux builds and why my method works EXCEPT for Linux builds.

I am looking more into the topics right now. Sorry if I've unintentionally annoyed you.
5  Game Development / Newbie & Debugging Questions / Re: Loading a Bufferedimage on: 2013-08-29 18:02:31
filename is (in the case of the first image I load) : /images/title.png
(I changed layouts and names some)

Layout is like this :

            Display.class (contains main)
            Images (loads Bitmaps)
            Sound (loads sounds)

When I export it as is, the images and sounds folders aren't added to the .jar. So I add them and place them next to the .jar. Then everything works fine, except on Linux (why it doesn't work I don't understand). I would like it to work on Linux.

I hope this is clear enough.
6  Game Development / Newbie & Debugging Questions / Re: Loading a Bufferedimage on: 2013-08-29 14:04:14
Unless I'm mistaken, the method above uses URLs, I just confusingly call my variable 'filename'.

The piece of code that seems to be the problem is the one in my first post (and a similar bit for sounds).

My files are located in the /bin folder, in two separate folders, images and sounds. The .class files are in /bin/seconds/focus.

When I export and manually add the files in separate folders beside the .jar, it runs fine -except on Linux distributions, where I get this error, which leads me to believe the files aren't detected :

Exception in thread "main" java.lang.ExceptionInInitializerError
Caused by: java.lang.IllegalArgumentException: input == null!
at seconds.focus.gui.Images.loadBitmap(
at seconds.focus.gui.Images.<clinit>(

I'm probably not doing something right here, but if I add the files to the .src folder and export them, they appear in the .jar but still don't seem to be detected, which is strange...
7  Game Development / Newbie & Debugging Questions / Re: Loading a Bufferedimage on: 2013-08-28 20:29:09
Actually, I have another question (sorry) : is the relative filepath I provided above valid for all platforms ?

I exported a .jar recently and it seemed to work on mac and windows distributions, but linux distributions wouldn't load images and sounds ? Somebody suggested I change the first '/' to './' but that didn't change anything.

I've done a bit of searching, and though there are some topics on similar matters, none seem to focus on this particular aspect of exports, to my knowledge.
8  Game Development / Newbie & Debugging Questions / Re: Loading a Bufferedimage on: 2013-08-25 10:39:47
[Edit] : Problem solved. Sorry for the unnecessary post.

/*Hmm. In the end I stuck with the class.getResource() method. It worked fine, I even added some .wav files for good measure, until I tried to export. And then, nothing, when the .jar is run, an unsized frame starts and that's it. I guess the resources aren't included, and in fact, the .jar only contains the .class files, no images, no sounds.

I tried implementing your method instead, with separate images and sounds folders, as I thought the files would then be added on  export, but it fails to load the sounds. I'm guessing that I'm unable to reset the classpath after having loaded images, and that it's trying to load sounds starting from the images folder.

I don't mind which method I use, but I'd like a properly running .jar. Sorry, looks like I'll need a bit more help on this one.*/
9  Game Development / Performance Tuning / Re: Basic Java code optimisation on: 2013-08-20 16:10:09
Thanks for the reply,
but that is pretty general, and my sort of question includes programming habits, so I guess that would include the approach to code design too. I was thinking of performance improvements more along the lines of the basic stuff I mentioned.
10  Game Development / Performance Tuning / Basic Java code optimisation on: 2013-08-20 16:01:25
Title says it all.
In essence, good programming habits one could (and should) have in order to make one's program faster and more stable. Or possibly, what you this is good programming habits in general.

I know there are resources for this kind of thing, but perhaps hearing it from the members of the forum might give a different light on things.

I barely know about this kind of thing, so the only two things that pop in mind immediately are bit-shifting and taking conditions out of loops whenever possible. I guess using the same constant (100, 100 instead of 101, 102 ; that kind a thing) values might help as well.

Any suggestions ?
11  Game Development / Newbie & Debugging Questions / Loading a Bufferedimage on: 2013-08-17 14:53:20

I seem to be having trouble loading a BufferedImage as a Class folder.
Essentially, I have these pieces of code in my ArtResources class :

public static Bitmap walltest = loadBitmap("/focus/Resources/textures/walltest.png");

   public static Bitmap loadBitmap(String filename){
      try {
         BufferedImage image =;

According to the getProperty() line, my class path is : D:\(...)\TimeStrips\bin

My resources are in a /src/Resources/textures folder. What am I doing wrong exactly ? No matter what path I specify, and which folder in the hierarchy I set as Class folder still yields me a java.lang.IllegalArgumentException: input == null! error.
12  Game Development / Newbie & Debugging Questions / Re: Casting corners on: 2013-08-17 10:24:20
My apologies, I had'nt realised I hadn't given many details. Say a grid is 128*128, and the top left grid starts at 0,0 and ends at 127,127.

If I cast a ray which is supposed to hit a corner, vertical intersections and horizontal intersections will not be the same. Essentially, I get this for a wall :

|      |
|      |
|      |

which means I am able in places to see through a wall and that some corners stick out when they shouldn't.

13  Game Development / Newbie & Debugging Questions / Casting corners on: 2013-08-16 08:28:21

I have been encountering an issue lately, when trying to cast rays on a grid :

it seems my corners aren't properly being detected. My corners either partly overlap, or there might be a gap in the corner which one can see through. I think the issue may be due to some rounding errors (which makes either vertical or horizontal intersections be detected when they shouldn't, or not be detected when they should).

Does anyone have any idea how to workaround this ? I'd like to be able to texture my world and I won't be able to properly do so until the corners stop overlapping.
Pages: [1]
DesertCoockie (33 views)
2018-05-13 18:23:11

nelsongames (75 views)
2018-04-24 18:15:36

nelsongames (70 views)
2018-04-24 18:14:32

ivj94 (752 views)
2018-03-24 14:47:39

ivj94 (82 views)
2018-03-24 14:46:31

ivj94 (622 views)
2018-03-24 14:43:53

Solater (98 views)
2018-03-17 05:04:08

nelsongames (179 views)
2018-03-05 17:56:34

Gornova (405 views)
2018-03-02 22:15:33

buddyBro (1065 views)
2018-02-28 16:59:18
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 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‑
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!