r/javahelp • • Nov 21 '18

I want to program a simple (2D) game, but...

I wanted to try and create a simple game like snake in java, but LWJGL seems a little hard to master, where do I start (for example to make small 2D games)?

22 Upvotes

21 comments sorted by

11

u/Wiqkid Nov 21 '18

You can always use vanilla Java combined with JavaFX for visuals, but a popular route is to use the LibGDX framework which will make a lot of things easier and I think is much easier to learn than LWJGL.

I've never used LWJGL so can't say for certain.

1

u/MrDh0nt Nov 21 '18

Aah yes JavaFX, I've heard about it before but I thought it was only used for creating simple GUI's I guess I'm wrong :D

3

u/Wiqkid Nov 21 '18

That is what it's used for, but it should help to make the process of creating your 2D game easier.

1

u/MrDh0nt Nov 21 '18

Okay thanks!

5

u/User1539 Nov 21 '18

I second LibGDX. I wrote a cross platform game, mostly for Android, but with a desktop version, in a few days. It's very capable and easy to learn.

5

u/metricchicken Nov 21 '18

Jmonkey is pretty straight forward.

2

u/MrDh0nt Nov 21 '18

This seems like a nice library, but is it a good starting point to learn about game programming in general? From a beginners point of view?

2

u/metricchicken Nov 21 '18

I thought so. I took a game design and programming class in college a couple years ago and JMonkey was what we used. I had zero experience with game programming and made both a 3D and 2D game.

1

u/DerekB52 Nov 21 '18

Jmonkey is nice, It's 3D though. For a snake game, I'm also going to recommend LibGDX. It's a great framework, and if you use it to build Snake, Flappy Bird, and a basic platformer, you'll walk away with a lot of game dev knowledge that will transfer to anything.

1

u/pb4000 Nov 22 '18

I made a 3d game in jmonkey with no previous game development experience. It works pretty nicely.

3

u/Astrokiwi Nov 22 '18

Is this a project for learning Java, or because you want to start building 2D games quickly?

If you're just interested in gamedev in general with a fairly easy entry level, then you could try something like Unity, which does have good 2D capabilities these days. Otherwise yeah, libgdx, jmonkey etc.

1

u/MrDh0nt Nov 22 '18

Well, both actually, I want to learn more about gamedev and then, when I have a fairly good understanding, build a more advanced 2D game... :D

3

u/CLOVIS-AI Nov 22 '18

processing.net is very easy to use, but still quite powerful.

2

u/neck_crow Nov 22 '18

I have a very elaborate version of snake, and all I use is JPanel. I haven't needed any external packages besides the ones Java provides.

2

u/raginpsycho Nov 22 '18

Processing

2

u/dabomm Nov 22 '18

Look into greenfoot its 100% free and its what they used to teach me java at school. You can find there old book with example games etc as a pdf for free. And there are allot of tutorials arround.

4

u/[deleted] Nov 22 '18

Greenfoot is way too basic imo. OP seems to be past that point.

-11

u/jjb3rd Nov 22 '18

Or don’t use java

3

u/MrDh0nt Nov 22 '18

What about minecraft? That's also written in java. Plus java was my first programming language I ever learned.

4

u/indivisible Nov 22 '18

Java receives a lot of hate from the wider developer community. Some is deserved, some is just ignorance or not being aware of how the stack has matured.

2

u/torbmol Nov 22 '18

Minecraft is the only popular game I can think of that used Java despite not needing to (on the desktop). In other words it's the exception that proves the rule.

I remember reading that Minecraft got a measurable performance reduction when it it switched from passing coordinates as int x, int y, int z to using an object. While this isn't the end of the world, no other language frequently used for non-trivial games have that problem.

For a simple game though, any language with a GUI library is fine. I have made a simple 2d maze game in Java using Swing, but that probably isn't the best idea for learning about game programming.