I’m using getSubImage() to get a BufferedImage area of an image and it draws it very slowly, here’s what I’m doing:
// initialize.
BufferedImage sprites = null;
try {
sprites = ImageIO.read(getClass().getResource("sprites.gif"));
} catch (IOException e1) {
e1.printStackTrace();
}
BufferedImage badGuy = sprites.getSubimage(82,0,19,25);
BufferedImage goodGuy = sprites.getSubimage(56,0,26,13);
BufferedImage bullet = sprites.getSubimage(41,25,16,5);
BufferedImage explosion = sprites.getSubimage(0,0,32,31);
...
// start game loop
...
// update world
...
// draw world
g.drawImage(...); // for each of those 4 images.
pretty straight forward, but the framerate drops down to 1 fps, how can I speed things up, or accomplish what I’m trying to do in a different way?