More advanced method of rendering

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

There’s nothing inefficient about using g.drawImage(image,x,y,null); at all, unless the image is HUGE. Just remember to not modify its internal data buffer and it will be optimized as much as possible by Java2D. Slick2D and LWJGL allow you to access OpenGL, which will cause your games to run MUCH faster but for now if you’re still a beginner in game design, I recommend you stick with Java2D.

My problem isn’t with efficiency, it’s with the time it takes to add the new class to renderUpdates(), then write the render method for EVERY class.

I’m sure it doesn’t work like that with a professional game, where hundreds or thousands of things are rendered every frame.

Does anyone know how Notch does that with the pixels[] array? If anything, I’d just like to know how it’s done.

-Nathan

I would just make a class called ‘entity’, or something like that. Then, each time you have a new ‘entity’ you want to render, you just add it to an ArrayList. Each time render is called, you loop through that ArrayList and call their render statement.