Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (578)
games submitted by our members
Games in WIP (499)
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-30 01: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 22: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 22:27:43
All right. So using this new structure, taking inspiration from your other topic :

bin
res
   sounds
      explosion.wav
   images
      title.png
src

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

with loadBitmap containing :
BufferedImage img = ImageIO.read(Images.class.getClassLoader().getResourceAsStream(filename));

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 21: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 20: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 :

bin
   images
      title.png
      ...
   seconds
      focus
         gui
            Display.class (contains main)
            Images (loads Bitmaps)
            Sound (loads sounds)
   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 16: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 javax.imageio.ImageIO.read(ImageIO.java:1388)
at seconds.focus.gui.Images.loadBitmap(Images.java:36)
at seconds.focus.gui.Images.<clinit>(Images.java:13)

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 22: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 12: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 18: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 18: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 16:53:20
Greetings.

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


   
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
public static Bitmap walltest = loadBitmap("/focus/Resources/textures/walltest.png");


   
   public static Bitmap loadBitmap(String filename){
      try {
         System.out.println(System.getProperty("java.class.path"));
         BufferedImage image = ImageIO.read(ArtResources.class.getResource((filename)));
      etc.
}


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 12: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 10:28:21
Hello,

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]
 

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

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (31 views)
2014-04-15 18:08:23

BurntPizza (28 views)
2014-04-15 03:46:01

UprightPath (43 views)
2014-04-14 17:39:50

UprightPath (26 views)
2014-04-14 17:35:47

Porlus (42 views)
2014-04-14 15:48:38

tom_mai78101 (64 views)
2014-04-10 04:04:31

BurntPizza (124 views)
2014-04-08 23:06:04

tom_mai78101 (223 views)
2014-04-05 13:34:39

trollwarrior1 (190 views)
2014-04-04 12:06:45

CJLetsGame (198 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
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!