Sign in to follow this  
biggjoee5790

Starting Game programming.. Java?

Recommended Posts

biggjoee5790    229
Hey guys.

So Ive been programming in Java for a few years now, but nothing game related. I am quite comfortable programming in Java.. although I do know Python and C/C++ on a beginner/medium level. Since I want to do game programming, and since its a notoriously difficult thing to do, I thought it would make sense to use the language that Im the best with. So, how can I start game programming in Java?.. or better yet.. should I even bother? If its a good idea,, what libraries will I need for 2D games? It seems like other languages are more clear cut... for C++ Id just use SDL, for Python I'd use pygame, etc. Mind you I dont want some pre fabricated game engine... just the API to access graphics, sound, input, etc. Basically I want to do as much on my own as I can, because its all about learning for me. Once I have a library, where do I start. People have said do something simple like tetris or breakout... but I wouldnt even know where to start.

Share this post


Link to post
Share on other sites
fireside7    213
If you want the minimum for java, you want lwjgl. It's a wrapper around opengl with sound. If you don't need hardware accelleration, then you can program graphics and sound with java in an applet or whatever with the built in libraries. One site to ask more specific questions is javagaming.org.

Share this post


Link to post
Share on other sites
biggjoee5790    229
I was actually looking at LWJGL, seems good. So you said Id I dont need hardware acceleration, I could just use an applet? So I could just program all of my logic simply using the Java base language and display graphics using the AWT? Such as just drawing rectangles or whatever other shapes I need? Also, how do I know if I need hardware acceleration?

Share this post


Link to post
Share on other sites
heromal    100
If you need guidance of some sort thenewboston has 30+ javva-specific game programming tutorials (70+ java tutorials in total). He doesnt use jogl or lwjgl or anything, only things that come with java. A warning: this is for a game application(download) not an applet(like runescape for example). I believe roseindia(google it) has a java applet tuttorial as well. Sorry for no links/bad spelling,im on my phone.

Share this post


Link to post
Share on other sites
LionMX    100
I dont have anything against Java, but I found XNA really easy to get into and start programming games with. You will be using the C# programming language so very similar to java, its just a change of syntax.

Share this post


Link to post
Share on other sites
SeaBourne    120
I'd recommend C# over Java. Java is slow and memhog for me but that's just from what I've seen and felt. Plus also lacks operator overloading, so your math will look like crap when using it. C# does have XNA, while you could also use OpenGL if you prefer. But, go with C# and just forget about Java.

Share this post


Link to post
Share on other sites
SimonForsman    7642
Quote:
Original post by biggjoee5790
Also, how do I know if I need hardware acceleration?


Basically, if you want modern 3D graphics you need hardware acceleration, If you're just doing basic 2D you'll get by just fine without it allthough since 2D using OpenGL is fairly straightforward and AWT is a bit of a pain to use effectivly i'd recommend going with LWJGL even for 2D graphics and possibly JME for 3D (its a fairly good 3D engine so if you just want to make a game it will save you alot of time and trouble)

Share this post


Link to post
Share on other sites
rip-off    10976
Quote:
Original post by biggjoee5790
Since I want to do game programming, and since its a notoriously difficult thing to do, I thought it would make sense to use the language that Im the best with..

That makes a lot of sense. Game programming isn't too bad until you start writing really big games. Getting simple 2D games up and running shouldn't pose too much trouble for even a moderately experienced developer.

What might take time is adjusting to writing "simulation" code. It has a distinct type of flow which differs from normal batch or UI driven applications.
Quote:

If its a good idea,, what libraries will I need for 2D games? It seems like other languages are more clear cut... for C++ Id just use SDL, for Python I'd use pygame, etc.

I've had good results using LWJGL in Java. I believe it is used by Notch for "minecraft", which should indicate what you can do with it.
Quote:

People have said do something simple like tetris or breakout... but I wouldnt even know where to start.

Pong is a classic beginner game, and one of the simplest to write. At its simplest you need to be able to draw three quads, you can use simple AI until you have your input routines written. The other is space war, which is again quite simple. Each of these games requires two players and a single item of interest which will need collision testing.

Tetris and breakout are more complex for a first game, having many more objects and requiring a bit of work on the data side too.

Share this post


Link to post
Share on other sites
agm_ultimatex    191
Quote:
Original post by SeaBourne
I'd recommend C# over Java. Java is slow and memhog for me but that's just from what I've seen and felt. Plus also lacks operator overloading, so your math will look like crap when using it. C# does have XNA, while you could also use OpenGL if you prefer. But, go with C# and just forget about Java.


Java 6 -xint is definitely slower. Steady State and Server however are faster then C#. If someone knows Java just fine, there's no reason they can't go with it. I personally think both JMonkeyEngine and XNA are great options for game dev.



biggjoee, depending on if your focus is 2d or 3d, you can look into slick2d for 2d games, and jmonkeyengine for 3d. Both are wrappers to the lwjgl.

Share this post


Link to post
Share on other sites
biggjoee5790    229
Thanks for the replies guys. My initial goal is to start simple, using as little library and engine functionality as possible. Maybe it would make sense to start simply using built in java? such as the AWT, swing, and java2d? Then incorporate an external library once Ive made some simple games like pong and a side scroller?

Share this post


Link to post
Share on other sites
agm_ultimatex    191
The simplicity of AWT allows you to create things like shapes and a GUI really easily. You still need to the same amount of math and calculations regardless. Slick2d and JME have nice classes you can extend from to get a game going. I think it really is a better idea to dive into one of them sooner than later, to get familiar with the classes and how to use them. There are some decent tutorials out there for getting started with such frameworks.

When I was learning SFML with C++, I created a pong clone then. Worked pretty well for me to learn the library.

Share this post


Link to post
Share on other sites
Fenrisulvur    186
Quote:
Original post by SeaBourne
Java is slow and memhog for me but that's just from what I've seen and felt.

Next to .NET? The idea of any CLR outperforming HotSpot is pretty farfetched - Sun's JVM has a reputation as the finest app VM in widespread deployment.

Quote:
Original post by SeaBourne
Plus also lacks operator overloading, so your math will look like crap when using it.

Your math should look great, because it should be beautifully LaTeX'd in the supporting documentation. ;)

But seriously, the implementation is never canonical on the math when there is any significant analysis involved in the derivation and verification of mathematical results used in the project. Littering your code with obscure transformations without maintaining an explanation as to where they came from is akin to stupidity.
Yeah, the code base can start looking a bit verbose without operator overloads, but the code isn't the true asset, so it shouldn't matter so much.

Share this post


Link to post
Share on other sites
rip-off    10976
Quote:
Original post by biggjoee5790
Thanks for the replies guys. My initial goal is to start simple, using as little library and engine functionality as possible. Maybe it would make sense to start simply using built in java? such as the AWT, swing, and java2d? Then incorporate an external library once Ive made some simple games like pong and a side scroller?

I've always found the Java provided libraries annoying for games. They can certainly work, there was a time when Java Applet games were reasonably popular. I just think the APIs are a pain because they don't easily lend themselves to real time graphics.

Quote:
Original post by Fenrisulvur
Quote:
Original post by SeaBourne
Java is slow and memhog for me but that's just from what I've seen and felt.

Next to .NET? The idea of any CLR outperforming HotSpot is pretty farfetched - Sun's JVM has a reputation as the finest app VM in widespread deployment.

The JVM is fantastic, within the limitations of the Java langauge (for game developement). For example, not having user defined value types is something that makes writing ulta-high performing game code difficult in Java, likewise lack of support for dynamic containers of non-reference objects. It isn't impossible, it just requires more manual optimisation work that you get for "free" with a runtime that natively supports such constructs.

That the JVM isn't further behind is testament to the amount of optimisations it does. And for smaller games, it is often not an issue.

Share this post


Link to post
Share on other sites
JoeCooper    350
I've been doing this. I've been app programming in Java for a while then started writing games in it. Mainly using the Java standard library - Swing, java.awt.Graphics, etc.

You can see my junk here if you want any focused examples on using the standard lib for that sort of thing. Overriding paint, custom JComponent, etc.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this