Hi! I'm new to these forums, and a little confused by some of the categories so please forgive me if this post is more suited to a different category.
So I've been working on a platforming game for a while now, and when i run it inside eclipse (just using the little green play button) it runs just fine, but whenever i export it as a jar and try to run it in an html file it breaks. Sometimes i get an error saying that it cant find the class, and sometimes I just get a blank screen. I decided to test this with a pong game i made a year or so ago that worked just fine, but had no imported images in it, just simple graphics drawing (g.fillOval(x, y, 20, 20); kinda stuff). Well, when i replaced the ball with a small sprite, i found that the game would run just fine in eclipse, but when exported to a jar and run in an html file, all the simple drawing was fine, but the ball image wouldn't appear.
I've tried a few different ways to import the image, but the way it is currently is as follows:
To create the ball sprite:
BufferedImage sprite;
//Some Code omitted...
try{
sprite = ImageIO.read(new File("playerSprite.png"));
}catch(Exception e){System.out.println("Oh No!");}
and then the draw method is as follows:
public void draw(Graphics g, ImageObserver imgOb){
g.drawImage(sprite, x, y, 20, 20, imgOb);
}
and then the html code in a separate html file is:
<applet code = "Pong.class" archive = "Pong2.jar" Width = 500 Height = 500>
</applet>
So just to clarify, when run from eclipse the ball appears just fine. When run in the html file, however, everything that is drawn NOT from an image shows correctly, only the ball does not; the ball is invisible. Any help would be appreciated. - Thanks!
EDIT: Oh! I have the image inside a source folder i created inside the project.