Reputation: 303
I am trying to render a background image in my Slick2d window. However, it's not rendering. What's wrong?
This is the first part of my main class
public class SimpleGame extends BasicGame{
Image land = null;
public SimpleGame()
{
super("Slick2DPath2Glory - SimpleGame");
}
@Override
public void init(GameContainer gc) throws SlickException {
land = new Image("bg.jpg");
land.draw(0,0);
}
Here's the root tree http://billedeupload.dk/images/4J5CQ.png
Upvotes: 1
Views: 3279
Reputation: 409
You should do all the rendering in the render() method instead of the init() method. So something like this:
@Override
public void init(GameContainer gc) throws SlickException {
land = new Image("bg.jpg");
}
@Override
public void render(GameContainer gc, StateBasedGame sb, Graphics g) throws SlickException {
g.drawImage(land, 0, 0);
}
Upvotes: 4