So, up until this point, I have been doing my rendering the good old fashioned way: simply using g.drawImage(img, x, y, null);
I was thinking, and this seems like a very inefficient way to do it. I remember watching Notch’s Minicraft livestream and him using an array called pixels[] and I THINK he was just adding pixels or whatever to that array, and rendering that.
My main problem with the g.drawImage way is the extra code it takes whenever I add a new entity to render. For example, when I add a new class that needs rendering, I make the class with a render method
public void render(Graphics g)
{
g.drawImage(main.spritesheet.sprites[67], x, y, null);
}
then I add the object to my main class and do this for my main rendering
public void renderUpdates()
{
if (state.equals("menumain")) menumain.render(g);
if (state.equals("playing"))
{
for (Wall wall : wallList) wall.render(g);
for (Pellet pellet : pelletList) pellet.render(g);
ghosts.render(g);
player.render(g);
}
}
the renderUpdates method is called from within my render method.
So, my question: Are there any established tutorial sets out there that demonstrate a more efficient method? It’s hard trying to learn from the livestream, because nothing is explained. If not, what are your methods for doing it? Do I just need to start using a library like Slick2D or LWGJL?
Thanks a bunch,
-Nathan