#InputStream only reading certain image files as non-null within same directory. Why?

1 messages · Page 1 of 1 (latest)

rigid veldtBOT
#

<@&987246399047479336> please have a look, thanks.

arctic isle
#

The first video is an example of it running properly, showing a pallet-swapped version of the "flappy bird" image that is used unsuccessfully in the second video

#

The images with checkmarks work just fine, but I have no idea what makes them special, as I made them all in photoshop with the only difference being the colours

neon chasm
#

hm

neon chasm
#

make a new folder called res

#

right next to src

#

right click and mark it as a resources root

#

and move all your assets there

#

this might be an "intellij confused" thing and that would help it

arctic isle
#

I tried it out to no avail. The old images still work too

neon chasm
#

oh you still need the assets subfolder

arctic isle
#

so res/assets?

neon chasm
#

yeah

#

to match up with what it was before

#

if thats not the fix, show me where in the code you load flappybird.png and where you load the other stuff

arctic isle
#

I tried a couple variations of the filepath with and without the extra assets folder and it didn't work

#
        mouseInputs = new MouseInputs(this);

        importImg();

        setPanelSize();
        addKeyListener(new KeyboardInputs(this));
        addMouseListener(mouseInputs);
        addMouseMotionListener(mouseInputs);
    }

    private void importImg() {
        InputStream is = getClass().getResourceAsStream("assets/flappybird.png");
        try {
            img = ImageIO.read(is);
        } catch(IOException e){
            e.printStackTrace();
        }
    }```
These are the only two methods that apply to the images
rigid veldtBOT
neon chasm
#

well good news

#

there doesn't seem to be anything wrong with that code

#

bad news

#

that means i don't know whats going wrong

arctic isle
#

well that's reassuringly horrifying

neon chasm
#

if you can share your code in a way i can run on my machine i can test it

arctic isle
#

I appreciate the help, I feel a little less crazy

#

I'm working on getting a github repo up rn

fluid tangle
#

You're looking at the wrong spot.

#

You've added them to src/assets.

neon chasm
fluid tangle
#

The correct location for those files by default is src/main/resources.

neon chasm
fluid tangle
#

Which you also happen to have, mind unfurling it?

#

Correct to both.

#

Ideally stick to one structure. Since now you have some Java files under src, and some src/main.

arctic isle
#

Would it be worth adding the path manually just in case or should it be good as is?

#

Also is there anything like an upvote or rep thing I can give u guys? I appreciate the help

neon chasm
#

it would be cool to have points

#

we could spend them like money