Tutorial on Game Programming in Java

Hey

I was looking around the web for some game-programming tutorials for Java and all I could find was two tutorials that even though they were quite nice, they talked only about applets and not full applications. So I was wondering where I could find some reference material I could use to learn how to program games in Java (as regular applications)? I already have some Java programming experience, as I use Java to build computer simulations for various physics systems at my University, so I’m not so much looking for a programming tutorial as for a game-making tutorial - more specifically, the Java2D API (I know there are various ways into the 3D world (Java3D, JOGL and many others), but right now I think that 2D would be enough of a challenge… first Pong, then Quake ;)) , and a general overview of “normal” game-making techniques (i.e., loops, input/output, etc).

Thanks!

This might help:

http://www.java-gaming.org/cgi-bin/JGNetForums/YaBB.cgi?board=cluebies;action=display;num=1081461966

(a few posts down in this forum :/)

Kev

Kev

That was actually one of the two tutorials that only talked about applets I mentioned in my post :wink: I’ve found a book that’s being written by a user in these forums and I’m trying to start with it, but I’m kinda pressed for time right now so I don’t know yet if it meets my needs or not. In any case thanks, and if you happen to know of a tutorial that deals with what I’m looking for - programming games in Java as applications and not applets - do remember to drop me a line :slight_smile:

Thanks!

Hehe the irony ;D

Actually Kevin is just about whipping such a tutorial together:
http://www.java-gaming.org/cgi-bin/JGNetForums/YaBB.cgi?board=Announcements;action=display;num=1081718135

Right now it’s source only, but that will change. Oh and btw applets and applications aren’t that different. In applets you extend (J)Applet and init() is the entry point and in applications you extend (J)Frame and main() is the entry point… that’s it - in a nutshell.

Welcome to the board :slight_smile:

Heh, ironic indeed :slight_smile: thanks onyx - I’ll make sure to keep an eye on that topic.

And my beef with applets is that an applet gives you the Graphics context with which you can draw stuff right out of the blue (or so it seems), and I always wondered how to do the same with a JPanel or a JFrame.

Thanks for the heads-up on the topic at any rate, and for welcoming me to the board :slight_smile:

[quote]And my beef with applets is that an applet gives you the Graphics context with which you can draw stuff right out of the blue (or so it seems),
[/quote]
Thats one of the things I tried to addressed in the applet tute I wrote (in the tutorials section about applets-how they work), because it was really confusing to me at first too.

The gist of it is, an applet is a component in a web browser that only responds to commands/methods called from the web browser (init, start, stop, update/repaint) so normally an applet will only update its display when told to by the web browser, hence the Graphics appears “out of thin air”.

You can also force drawing in an applet by using getGraphics() and releaseGraphics() (these may not be the actualy methods but you get the idea) to get and release the Graphics whenever you want. This used to be a performance improvement, but not with Swing and current jre’s.

Hope that helps.

Well that does clear some thing up for me - I had some ideas as to what applets were and it seems I was correct - but what I’m really interested in however is how to do that in an application, not an applet. Thanks anyway :slight_smile:

I remember there was some kind of a “fullscreen” tutorial, but I forgot where it was and I did not bookmark it :-[…anyone know where that one is?

Ironic indeed, keyro’s post is actually what pushed me over to actually putting the tutorial together (which I’ve been meaning to do for a while).

Tutorial is now first edition:

http://www.cokeandcode.com/info/tut2d.html

Hopefully blah will put it on the JGF page too :slight_smile:

Kev

[quote]I remember there was some kind of a “fullscreen” tutorial, but I forgot where it was and I did not bookmark it :-[…anyone know where that one is?
[/quote]
I believe there is a link to a cleaned up version of the Scroller full-screen sampel I wrote on the Wiki.

Mike Martak’s turtorial on full screen exclusive mode actually cover other thinsg too like BufefrStrategy and active rendering. Its on The Swing Connection somewhere. Whenever I neeed the link I google for
“Martak” and "Full Screen " and it pops right up.

Kev, that’s a very well put together tutorial!

[quote]Mike Martak’s turtorial on full screen exclusive mode actually cover other thinsg too like BufefrStrategy and active rendering. Its on The Swing Connection somewhere. Whenever I neeed the link I google for “Martak” and "Full Screen " and it pops right up.
[/quote]
Thanks for the google keywords :D!
Just in case someone wants to take a look, it’s @ http://java.sun.com/docs/books/tutorial/extra/fullscreen/

Sorry for not having posted in a while, but I’ve been hammering out my latest project for University and have had little time to study game programming. On the other hand, my next project will rely heavily on animations, so Kev, rest assured I’ll examine your tutorial thoroughly :wink: thanks for posting it online man :slight_smile:

kevglass - thanks for the excellent tutorial. I’ve been looking for a good j2se, non-applet tutorial and this is exactly what I’ve been looking for.

I also enjoyed having the game be playable via java web start. I idly clicked on it and lost the next half hour to an old skool version of space invaders - well done!

Thanks again.

Rajß