Slick2d java game crashing when I setBackground();-Collection of common programming errors
I’m using slick2d and in my Java application. In my render method I use a method called changeBackground();
@Override
public void render(GameContainer gc, StateBasedGame sbg, Graphics g)
throws SlickException {
changeBackground(g);
}
changeBackground();
public void changeBackground(Graphics g) throws SlickException{
Thread.sleep(500);
g.setBackground(new org.newdawn.slick.Color(0, 255, 0);
Thread.Sleep(500);
g.setBackground(new org.newdawn.slick.Color(255, 0, 0);
changeBackground(g);
}
When I run my application the game crashes.