How do you make a gif always be the background of an active window (behind other objects)?

823 Views Asked by At

How do you make a picture or gif always be a set at a greater depth into your active window than any other visible object? (Using StdDraw.java)

I'm trying to set an animated gif into the background of a game I'm making. But whenever I create a new shape (the ground block for example), the new object is always behind the gif. I want to make it so the gif is always on the bottom no matter what (because my code is eventually going to deal with multiple objects, text etc.)

My code so far: (Note I had it working as I described but have somehow messed it up so it no longer even shows the bottom block behind the gif--if you know what I did to screw that up too that'd be very helpful)

public static void main(String[] args){
    StdDraw.setCanvasSize(800,480);//window dimensions in pixels
    StdDraw.setXscale(0,1);//scale of window
    StdDraw.setYscale(0,1);//scale of window


    StdDraw.setPenColor(StdDraw.BLUE);//pink rectangle (bottom block)
    StdDraw.filledRectangle(0.5,0.0,1.0,0.05);//ground (visual only)
    while (true){//GIF LOOP
        StdDraw.clear(); //clears previous drawing
        StdDraw.picture(0.5, 0.5, "clouds.gif");//cloud gif is 640x480 so the block *should* extend beyond it given the scale
        StdDraw.show(10); 

}

I realize that a similar question has been asked already: How to bring an image to the foreground in Java? however I believe my variation on that question deserves help as I'm not entirely sure I understand how the answers given in that post could apply to my code without changing it dramatically (for one, I'm using StdDraw, not Swing).

I'm a beginning coder and new to stackexchange so please pardon my ignorance.

Thanks for any help you can offer!

0

There are 0 best solutions below