why are people trying to use Java2D to make games?

I don’t think this is an absolute. It’s certainly useful to know how your tool set works, but it often is not a necessity. Most Java developers don’t understand how the JVM works, aside from at a very high level, and get along just fine. You may be able to write “better code” with more knowledge of the internals of whatever tool, but to me it’s the mark of a quality library if you can get work done quickly and easily without having to care what’s actually going on underneath.

This thread…

It really shows a lot about the direction Java is going in the future. This doesn’t even have to do with game programming. I think if we all believed in this specifically, Java will not have a foothold in the future of programming period. All that will be left will be the “true” base technologies: OpenGL ES, HTML5, and JavaScript. Java is completely unnecessary by this same logic, and LWJGL is a last ditch effort to keep a struggling library alive.

It was stated that there were plenty of tinkerers…

And rightfully so. There has to be when the technology does not leave easy answers to your questions. Tinkering is the way that people who care passionately about a technology try to improve it to become better. Many of the libraries we have today that made Java better were products of tinkering. These projects are necessary to improve the language by answering the basic questions no one else dared.

“Can a game written in Java be played on iPhone?”
“Is there a way to accelerate Java speed equal to C?”

How are these questions answered? Through tinkering.

why are people trying to use Java2D to make games?

Because, all the questions for Java2D are answered. Java2D still remains as our most sturdiest platform. You can ask anyone where to find documentation on how to display a screen. We can get them a direct site without telling them, “Go search Google.” That is the major problem with our current technologies today. Java was built on great documentation along with its code. The newer projects were all tinkering ideas that happened to make it big. Not all tinkering projects have great documentation in mind. As a community, I feel that our lack of organization is the biggest nail in the foot, and for us to rely on Google shows our lack of faith in our own API.

We are all game designers here, so let me give you an example of how bad this sounds. Let’s say I made this really cool RPG game on my website. I have a forum where users can speak about my game and tell me problems/ideas. Then, when a user comes to me with a game problem on my forum, my response is… go check on Google for other RPG’s solutions to the problem. I hate to say it… but it is pure laziness on the people producing the API to not have proper updated tutorials for users who want to use their product.

Tinkering will be reduced if people knew where to find the answers. Plain and simple. Even something as simple as getting a book published for how to use LWJGL, JOGL, or even LibGDX will be a huge push forward for these API’s. But, I know these are all running on a limited budget, so just having a focal point for the documentation will be helpful enough.

Final thoughts…

Game making is very difficult. You can have really great documentation for an API, but still games will not be created. The problem stated here is a lot bigger than just gaming. This is why we have so many people tinkering to try and make solutions to the problems easier to manage.

Actually, there are a lot of people on this site who are paving the way to much easier game development in the future. Procedural developed music, mass particle effects with minimal CPU, simplex noise generators, sound API that can work across platforms, video API that can work across platforms, etc. It is these technologies, once perfected, that is going to make Java as a whole keep its place in the programming world.

Games is only a small piece of this puzzle. As a community, however, we should strive to make it as easy as possible for users to answer these questions without having to trudge through forum threads or search on Google. It all starts with the people who are creating the API’s. If the documentation is right on target, then you’ll find a lot more people using your technologies to create games.

Yes yes this ;D

This is how all programmers should work.

Random sentence to make at least 10% of this post mine… Etc. etc.

JogAmp is still alive and actively maintained.

When developers understand how it works under the hood, they can contribute which is vital for free open source libraries. When they don’t, they need some help from people who do. Therefore, such knowledge drives a developer more autonomous even though I agree with your last point.

Just catching up on this thread…

As well as libGDX / Slick2D, Processing 2.0 would make a good starting point for someone new to creating games in Java. You’ve got the ability to work with software rendering or a modern shader-based OpenGL pipeline on the desktop (JogAmp based Julien! :wink: ), as well as export to Android (with OpenGL) and export to JavaScript (canvas or WebGL). It’s generally much better documented, and there’s a range of small games out there created with it (particularly HTML5 ones).

Didn’t the Processing guys ditch Java completely in favor of Javascript?

No, they ditched Applets, like any sane person would! :wink:

And Processing.js is still coded in Java, then exported to JavaScript (though I think you can work with JavaScript libraries directly too).

How about from a 15 year old’s point of view?

I am 15 and for me it is much easier to use Java2D to begin with, because, like a lot of people here have already stated, I can find simplistic, easy to follow answers to my problems with code that is easy to follow.

These libraries such as libGDX etc probably do have a ton of advantages, but the thought of having to write a lot of lines of code for the simple things is extremely daunting.

Counter-Argument: :stuck_out_tongue:

Just like the time when I used XNA two years ago. The framework was solid and yes, I needed to write a couple more lines that necessary but after learning it once, I could do it. I’m sure these libraries are probably the same and are more than likely well worth looking into and using, but until they come with the support required by newbies( like me :slight_smile: ) they won’t be used by newbies, for now.

The main thing that took me away from java2d was the lack of a sane way to draw a rotated image

You are missing the point… by using java 2D you are going to need to write MORE code! And it will be more challenging, and render slower.

For example, to set fullscreen mode in LibGDX you just need to set a boolean to true… In Java2D you need to deal with a lot more lines of code (“fullscreen exclusive mode”) and it might not even work reliably on all platforms!! Same goes for rotating a sprite, tinting an image, using transparency, game loops, tiled map loading, custom bitmap fonts, game UIs… The list goes on. Java2D is a terrible library for 2D games.

@davedes point me to a good tutorial on how to set it up, use it for making a 2D Game and I’ll use it :smiley:

Scyth , don`t triple post :slight_smile:

More promoting libGDX…it has classes that you would otherwise have to make yourself, Camera, Vector2/Vector3, SpriteBatch, automatically caps fps to 60, better key detection (just one line of code for polling), particle effects, actors and stages, etc.
Oh, and TWL :slight_smile:

It may take longer to learn (not so much the learning curve as there aren’t that many tutorials) but you will make games so much faster. Keep in mind that I am 14 and there are several people younger than me on this forum so age really doesn’t matter too much as long as you spend time on it.

LibGDX tutorial: http://steigert.blogspot.com.au/2012/02/1-libgdx-tutorial-introduction.html probably the best one out there, and he’s recently making more.

There is a lot of documentation on LibGDX, and all of it caters to a game development audience.

http://libgdx.badlogicgames.com/documentation.html

To set it up there are many ways, but the easiest is to use Eclipse and download the Setup GUI tool located here:
http://libgdx.badlogicgames.com/nightlies/dist/gdx-setup-ui.jar

You simply double-click executable JAR and follow the steps.

More setup instructions and even a video located here:
http://code.google.com/p/libgdx/wiki/ProjectSetupNew

It’s really the easiest Java library to set up, ever.

If at any point you wonder why you are taking some minutes out of your day to set up a library when you could instead just dive right into Java2D, remember: Java2D is crap for games, leads to poor performance, and will require you to write hundreds more lines of code. See this simple example: Java2D vs LibGDX

And, as a bonus with LibGDX, you will be able to port your games to Android and HTML5.

To show you how easy libgdx is, here is an example:

This loads your texture from “data/texture/texture.png”, and every frame (precisely 60 times per second) it binds it, draws it as the mouse position if you press space:


public class MainLoop extends Game {

	public static final int WIDTH = 800;
	public static final int HEIGHT = 600;
	
	public static void main(String[] args) {
		new LwjglApplication(new MainLoop(), "Test Application. This is the caption", WIDTH, HEIGHT, true);
	}

	SpriteBatch batch;
	Texture texture;
	
	@Override
	public void create() {
		texture = new Texture(Gdx.files.internal("data/textures/texture.png"));
		batch = new SpriteBatch();
	}

	@Override
	public void render() {
		Gdx.gl.glClear(GL11.GL_COLOR_BUFFER_BIT);
		
		if (Gdx.input.isKeyPressed(Keys.SPACE)) {
			int mousex = Gdx.input.getX();
			int mousey = Gdx.input.getY();
			batch.begin();
			batch.draw(texture, mousex, mousey);
			batch.end();
		}
	}

	@Override
	public void resize(int width, int height) {}

	@Override
	public void pause() {}

	@Override
	public void resume() {}
	
	@Override
	public void dispose() {
		batch.dispose();
		texture.dispose();
	}
}

That’s it.
1 line to load a texture,
1 line to check a keyboard key press,
2 lines to get the mouse position,
3 lines to render a texture on screen.

All the reasons you have for using libGDX are just laziness.
I’ve written my own classes for Vector2, Vector3, and Vector4.
I’ve written my own equivalent simple version of a Spritebatcher.
I’ve written my own camera class.
I’ve written my own game loop.
I’ve created particle effects.
I’ve written a Key Listener.

All with LWJGL. And I’m 14 too. “Age doesn’t matter too much if you spend time on it”. When that sentence has the context changed, I agree.

LibGDX promotes laziness of coding. You’re promoting it as a way for beginners to use OpenGL. But are they really learning to use OpenGL? Or are they just blindly doing what X tutorial said without knowing what on earth they’re doing?

People who use Java2D are probably more likely to move on to LWJGL which really does help you learn OpenGL, and good coding skills.

I’m not saying people should’nt use LibGDX, because HTML5 and Android conversion are Awesome. I’m saying you should learn what that code you just typed out is actually doing.

Disagree if you wish, but if you don’t want me saying ‘Your library is bad’, don’t say it to the people using Java2D

Laziness, yes, but you’ve missed the most important of our resouces - time. While you made all those classes yourself, and while it may have been a good learning experience, libgdx users save time because we just have to download it.

Sorry about the triple post, I was on my phone and it messes up sometimes on the submit part of forums.

I’ll try libGDX and see how it goes, and then I’ll decide between them.

This is like saying Python or Java is too high-level, and you must be lazy if you aren’t using C, C++ and assembly. Hell, why use LWJGL at all, when you could instead write your own OpenGL wrapper from the ground up?

The truth is: people have different goals. A “game developer” wants to make a game, and it makes no sense for them to spend hours re-inventing the wheel. A “graphics programmer”, on the other hand, wants to understand and optimize things at the lowest level – even if that means going down to C/assembly – and generally don’t budget as much time for gameplay, storyline, content, etc.

[quote] You’re promoting it as a way for beginners to use OpenGL. But are they really learning to use OpenGL? Or are they just blindly doing what X tutorial said without knowing what on earth they’re doing?
[/quote]
You don’t need to know how to build an engine to drive a car. :wink:

Just like you probably don’t care which Win32/Cocoa/etc calls are being made by LWJGL’s Display class, the newbie shouldn’t be concerned with what’s happening under the hood when he calls LibGDX methods like the following:

texture.setWrap(TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);
texture.setFilter(TextureFilter.Repeat, TextureFilter.Repeat);

More important is that they understand the OpenGL concepts involved; such as texture filters and wrap modes. As they become more comfortable with graphics programming, they can choose whether or not to look “under the hood” to see how it all comes together.

[quote]Disagree if you wish, but if you don’t want me saying ‘Your library is bad’, don’t say it to the people using Java2D
[/quote]
I am beginning to wonder whether you’ve ever even tried LibGDX… ::slight_smile:

If you want to re-invent the wheel with “pure OpenGL” code, then you can still do that with LibGDX by calling Gdx.gl/gl10/gl20. There are very few reasons to use LWJGL these days.

In its smallest form, LibGDX is ultimately just another OpenGL wrapper. So, instead of writing your own SpriteBatcher in LWJGL (for desktop-only), you could have written it in LibGDX (for multiple platforms).