PDA

View Full Version : Going java?



ehbgamer
08-15-2004, 01:57 PM
Hi,

I'm considering using java in my next games, I'm a little worried because I have used to use DirecX and C++ before, and I have built a solid library which I use to develop my 2D titles, but ... It seems java has many advantges over using C in games, the most important is portability, multiplayer support, and ease of use.
I have noticed a good book (not yet published) about developing games in java at the following link:
java game programming techniques (http://fivedots.coe.psu.ac.th/~ad/jg/)
In this book (the first chapter) explains why java is considered -in his opinion- better than C++. actually he has very good reasons for that (I agree with him, Princec will agree too :D ).
But still confused, why indie gamers do not use java? Let me know your opinions about java and why did not you use it for your games.

cheers...

princec
08-15-2004, 02:38 PM
Mostly inertia, fear of the unknown, and the fact that until recently Java was genuinely too shit to write games in. And arguably it still is if you don't use LWJGL.

Getting a VM can be a daunting experience for a potential customer, but it's quite well offset by the supreme ease of using Webstart to get new games.

Cas :)

tewe76
08-15-2004, 10:57 PM
I think java is like linux: the best but very complicated for computer newbies (wich i think are very very important in this biz ;) )


Mostly inertia, fear of the unknown, and the fact that until recently Java was genuinely too shit to write games in. And arguably it still is if you don't use LWJGL.
By the way, princec, OpenGL doesn't work on my PC (an old graphic card) so LWJGL doesn't too, so your game also :(

Kai Backman
08-16-2004, 01:10 AM
I have considered doing game development in Java as well (and actually done so a few years back). I have a slightly different view than Cas on a few points. I have been doing Java programming since 1995.

Pro:
+ Excellent language and noncrashing VM model
+ Potentially good speed optimizations (HotSpot)
+ Ease of update using WebStart

Con:
- Most game toolkits natively support C/C++ (adding potential bugs in the binding layer)
- Bundling the VM with your application or compiling to binary both have major disadvantages in size and stability

Most other issues, like loss of power in local speed optimizations, can easily be worked around by plugging in custom C/C++ modules. The one currently holding me back is the lack of library support, most of the libraries I use are native C/C++. If you find a suitable graphics and sound library for Java everything else is already there.

I do agree with Cas on the fact that there is definetly a resistance from the establishment, part of it unfounded.

princec
08-16-2004, 01:46 AM
I do believe that there's an SDL wrapper for Java somewhere if that floats your boat. Otherwise ordinary 2D graphics with 1bit alpha are accelerated as fast as you can get them. Then there's the LWJGL of course for professionals :)

What other libraries do you find that you need that you have to resort to external C libs?

Cas :)

Kai Backman
08-16-2004, 03:35 AM
What other libraries do you find that you need that you have to resort to external C libs?


For me personally the showstoppers are: OGRE, FMod and Lua (and probably subversion). FMod and Lua could maybe replaced with similar libraries but OGRE is a stopper currently. They have a Java bindings project but the main development is on the C/C++ interface. In the name of stability it is easier being closer to the source (the reason I switched from SDL based development on Linux to Windows).

tentons
08-16-2004, 04:30 AM
I really love Java, and Eclipse (http://www.eclipse.org/) is the best IDE I've ever used for any language (plus it has a plug-in for Subversion support (http://www.eclipse-plugins.info/eclipse/plugin_details.jsp?id=338)), but I do wonder what impact the need for a recent JVM has on customers. I guess bundling it isn't so bad?

Couldn't OGRE be hooked up through JNI?

princec
08-16-2004, 04:52 AM
OGRE is already hooked up to Java (see www.javagaming.org)
FMod is already hooked up to Java (see www.lwjgl.org)
For Lua you would probably use Beanshell in Java, or Jython, or PNuts.

Cas :)

Nemesis
08-16-2004, 07:20 AM
Lua within Java? That's like a scripted language within a scripted language! :)

Not sure about this, but I think that either the Java runtime library or some third party API (Casper? or JSR?) offers compilation services. Such services might be used to run scripts written in Java itself that are loaded dynamically and compiled on the fly.

Pro: no need to know a secondary scripting language
Cons: Can do anything in Java i.e. beyond the domain of the game i.e. opportunity for malicious code.

princec
08-16-2004, 07:26 AM
You have different security permissions on scripts because the code will be loaded with a different classloader. The only security hole I can see being a problem is DOS attacks (eg. creating hundreds of busy threads that spin in a loop).

You can distribute a full Java compiler with your game.

Cas :)

Kai Backman
08-16-2004, 09:48 AM
OGRE is already hooked up to Java (see www.javagaming.org)


Hmm. I need to rephrase... :)

First, the project Cas is refering to is at: http://www.bytelords.de/cowiki/426.html (Ogre4J).

The problem isn't the existence of a wrapper but the fact that it is a wrapper. My experience is that with most 3D engines today you are required to work with the original interface language (C++ for OGRE, Basic for Blitz). With a wrapper you add one extra layer to debug and keep working. This extra work is (in my own experience) substantial.

Turing complete just isn't enough.. ;)

princec
08-16-2004, 09:59 AM
I don't think a native engine is the way to go at all myself. I'd use Xith3D or MonkeyEngine if I wanted to write a 3D game in Java with a bunch of stuff done for me.

Cas :)

HairyTroll
08-16-2004, 11:32 AM
For me personally the showstoppers are: OGRE, FMod and Lua (and probably subversion). FMod and Lua could maybe replaced with similar libraries but OGRE is a stopper currently. They have a Java bindings project but the main development is on the C/C++ interface.

I just wish more projects would provide a C API in addition to a C++ API. Only providing a C++ API means that anyone wanting to interface to the library is limited to using C++ ((Thanks, C++ name mangling) unless a lot of work is done upfront. A C API is the lowest common denominator.

-Luke

Sillysoft
08-16-2004, 02:36 PM
I did use java to make my game and have no regrets. However java is the language that I am most familiar with, so that helps a lot. If you don't have java experience that it will take you some time to learn how to do the things you want, but after that you should be able to speed along.

My game isn't 3D, and isn't hugly graphical intensive, so I just used the built-in java2D API. It is simple and supported everywhere, without any openGL funkyness, etc.

dreeze
08-16-2004, 11:00 PM
I'm not into java, but check out http://www.agency9.se , they're using sun's native opengl support or something like that.

LiquidAsh
08-16-2004, 11:31 PM
In case these help:

I messed with using Lua on top of some java objects... maybe 3years ago or so. I think I used an old version of this LuaJava (http://www.tecgraf.puc-rio.br/~cassino/luajava/) and did end up rewriting a few things to support some of the latest (at that time) Lua features. JLua (http://hetland.org/jlua/) is another project that was not yet running at the time, but I remember keeping an optimistic eye on.

princec
08-17-2004, 12:56 AM
My experiences of coding with Java do lend me to thinking that a scripting language is more or less unnecessary. Java tends to make writing code easy enough that the added hassle of bolting in scripting probably costs you more time than it saves. And of course it kills the performance in the scripted parts, after all that clever VM compiler trickery it's a bit like buying a titanium exhaust for yer bike and then having a greasy fry-up before you go for a ride...

Cas :)

Nemesis
08-17-2004, 01:37 AM
The other important reason for implementing scipting besides simplifying coding is to provide the means for a level designer to implement events, logic and AI for entities within a game's levels or world. The idea is to provide a simplistic programming language that the designer can actually use.

Obviously, scripting in this sense is more geared towards content-driven games rather than the casual or arcade game. Speaking of which, scripting also comes in handy for the top-of-the-range arcade games, such PomPom's offerings.

Out of curiousity, how are you handling enemy spawning in AF? Is it data driven, generic rules etc?

grimreaper
08-17-2004, 02:45 AM
Nemesis reminds me of a great thread a few months back on the gd-algo list. The guys there were discussing data-driven v.s. heavily object-oriented. IIRC the consensus is that data driven leads to a better, more flexible design. Which, IMHO, stands to reason anyway.

Scripting the AI, effects, enemy spawning etc, makes a lot of sense. I cant imagine myself hardcoding what enemy X on level 45 into the main game executable itself will behave ...

grimreaper

princec
08-17-2004, 02:52 AM
Out of curiousity, how are you handling enemy spawning in AF? Is it data driven, generic rules etc?
In AF all the enemies are configured with XML and basically they're hand crafted Java code. The complexity of the code would be approximately the same scripted or non-scripted give or take maybe a few extra brackets, with the added benefit that I got it all checked for me at compile time.

Super Elvis is very much more data driven - there's only one Alien class and it's completely XML configured. However the XML is so hairy I think I might just hardcode everything next time, it'll be easier and faster.

Cas :)

Aldacron
08-17-2004, 03:34 AM
The other important reason for implementing scipting besides simplifying coding is to provide the means for a level designer to implement events, logic and AI for entities within a game's levels or world. The idea is to provide a simplistic programming language that the designer can actually use.

Obviously, scripting in this sense is more geared towards content-driven games rather than the casual or arcade game. Speaking of which, scripting also comes in handy for the top-of-the-range arcade games, such PomPom's offerings.


I'm with Cas, in that Java itself is already a great scripting language. It's possible to compile and hotplug classes at runtime. Considering that Java is no more difficult to learn than Python or Lua, designers could just use it instead of adding scripting overhead (which has a much larger impact in a Java game than it does in a C++ game).

Nemesis
08-17-2004, 08:36 AM
@grimreaper
I agree with you that the more data/script driven, the better. Perihelion has hard-coded AI and screen rendering code for each entity encapsulated in classes derived from a generic Entity object. Each entity requires a specific configuration, world positioning etc. and this is obviously data-driven. The approach is just about good enough for our game since it is linear and hence no complex triggering is required other than entities appearing in the horizon or passing by the player. There are all sorts of entities, from enemies, to level-speed changes to character dialogue and we also plan to use it for environmental effects such as rain, snow, meteor shower.. you name it. In short, the hard-coding is mostly required for the AI and there is no specific level hard-coding, so in a sense it is a bit of a hybrid.

@cas
Thanks for sharing. I think your system was more than adequate for AF. Sometimes it's far simpler to hard-code than implement a sophisticated generic solution that may still not offer the same flexibility.

@aldacron
Security-wise I think it depends on who will be "modding" your game. You wouldn't want anyone distributing a level with enemies that format your harddrive when shot! :) I haven't delved much into the SecurityManager myself but I guess you'd need to severaly limit what a designer can do with his java game plugins. Perhaps disallow access to practically all API classes except, say, the collection framework and support API's for the game.

Dan MacDonald
08-17-2004, 09:35 AM
Ironically this month's PCGamer magazine (here in the US) has a write up on "java games", has a picture of quake3 java etc.

princec
08-17-2004, 09:37 AM
Bah. I bet AF didn't get a mention :(

Cas :)

Dan MacDonald
08-17-2004, 09:48 AM
Well maybe it does indirectly "long considered the realm of simple games with bad controls, java is emerging..." -heh- just teasing Cas, No, it mentions the Quake3 Java thing and has a screenshot, also some "Tribal Trouble" 3d game. They mention a few retail games that used java as a scripting language and then yack with Chris Melissions (sun's chief gaming officer) where he goes off about any game that can be made in C++ can be made in java.

Ironically when I look at the quake3 screenshot, there's no stencil shadows, or shadows of any type, just lightmaps, the Tribal Trouble one actually looks better then Quake.

I guess you'll just have to go 3D to get mainstream attention, how about that sweet robot based MMO cas? that thing looked pretty sweet... ;)

princec
08-17-2004, 12:48 PM
Next year, perhaps. Probably in collusion with Elias.

Cas :)

Aldacron
08-17-2004, 05:50 PM
@grimreaper
Security-wise I think it depends on who will be "modding" your game. You wouldn't want anyone distributing a level with enemies that format your harddrive when shot! :) I haven't delved much into the SecurityManager myself but I guess you'd need to severaly limit what a designer can do with his java game plugins. Perhaps disallow access to practically all API classes except, say, the collection framework and support API's for the game.

And the great thing is you can do that with the security management API and custom class loaders.

SteveB
08-19-2004, 05:59 AM
I'd like to use Java for my next project, but the 15MB JRE download is a show stopper right now. How have you guys dealt with that? I can't see a potential customer downloading it for the sole purpose of trying out a simple demo.

princec
08-19-2004, 07:15 AM
http://www.theregister.co.uk/2004/08/19/us_broadband/

Don't worry about the sizes of the downloads any more. A large number of people already have Java installed; an even larger number are getting Java installed on their PCs from new (>50% of all new PCs have Java on) and of course the Mac has Java built in.

Installation of the JVM is now very painless, no more of a hassle than getting Shockwave.

Cas :)

SteveB
08-19-2004, 08:57 AM
princec, I know that you did a special AF native build for Windows users. Do you plan on a similar strategy for future games, or will you require a locally installed JRE?

princec
08-19-2004, 09:25 AM
I'm beginning to think I should go for pre-installed JVMs only. Super Elvis will not be released as a native windows executable and I may remove the Win32 native executable of Alien Flux too.

Cas :)

tentons
08-19-2004, 11:32 AM
I'm beginning to think I should go for pre-installed JVMs only. Super Elvis will not be released as a native windows executable and I may remove the Win32 native executable of Alien Flux too.

Would you care to explain why you're making that choice? I'm curious about the differences, pros/cons.

Sillysoft
08-19-2004, 12:07 PM
The Windows installer for my java-game checks to see if the user has a suitable JRE installed. If they do then it does the install. If they do not then it points them to the sun webpage where a JRE download starts automatically. It has worked well.

This means that the Windows installer must have an exe download, but that is fine by me.

Mac OS X comes with java pre-installed and I tell Linux people that they must have a JRE installed.

princec
08-19-2004, 12:54 PM
I plan to detect the availability of Java from the actual webpage. I'll have the detection code on just about every page in my site; it's going to urge people to download the JRE before the players can even see download links to games. What I might do - haven't decided yet - is bundle a public VM in the game download so it's all transparent, and then subsequent game launches won't need the VM.

I want to do this for a couple of reasons: firstly because my embedded VM is technically breaking some license or other (but Sun don't care); and secondly because Super Elvis now uses AWT and Swing anyway for expediency so I can't embed a smaller VM any more.

Cas :)

Mithril Studios
08-19-2004, 02:19 PM
and secondly because Super Elvis now uses AWT

You're a glutton for punishment! :eek:

Anthony

Sillysoft
08-19-2004, 07:38 PM
I thought about detecting whether or not they had java on my webpage, but decided against it in the end.

On my download page I put the text "If you are prompted to install java then do so and ...". I figured that there was a better chance of people installing java once they have gone to the trouble of downloading my demo.

SyneRyder
08-20-2004, 02:18 AM
I still regard the JRE as a showstopper (as a customer, not a developer). I've downloaded Java before to run business applications, though I had to really want the app to commit to downloading 20MB. When I finally got it and installed the app, performance was extremely sluggish. I contacted the developer but his advice was to get a faster computer.

I think the Java language is great, a nice clean language and the technology is fantastic... as a developer. But from the user's perspective, I find it just isn't as good an experience as a pure Windows app. Now if I see an app requires Java, I don't even bother downloading it. Native Java compilers producing tight code would go a long way to improving this, but the last time I looked at them, I was still getting 1-2MB for a Hello World application.

Just an opinion, but I think Java remains an extra barrier to customers (on the PC anyway). As for broadband, it isn't even available in some parts of Australian cities yet, so download sizes are still important there.

princec
08-20-2004, 02:56 AM
The JRE download size figure seems to vary wildly with each posting :)

Actual size as downloaded from Sun: 14.6 MB (j2se1.4.2_04)

And on the same subject - I tweaked and 7-zipped j2re1.5beta3b60 up and got it down to 10.2 MB. Which is about the size of a graphics driver.

And not forgetting the Alien Flux JVM, which is <3MB, but unfortunately has no AWT capabilities and doesn't include Webstart.

Cas :)

SyneRyder
08-20-2004, 09:13 AM
I'll see your 14.6 and raise you 50? :D Sorry, when I said 20MB, I was meaning rough figures of the JRE + size of application. The Windows version of the program I tried was 14.1MB including JVM, and the Linux version was 23.8MB including JVM. It was a desktop version of a PalmOS app that only takes 84k on my handheld, so you can imagine my horror at the bloat!

Statistics aside - I stumbled across the Alien Flux postmortem by coincedence today, and realize now that I should take back some of my comments. I see that you used Excelsior JET to make a native Win32 version that you could squeeze into a 5MB download. I assume that didn't require a JVM, and if so that seems a perfectly acceptable download size to me.

Sillysoft
08-20-2004, 10:52 PM
I agree the fact that some people will have to install a JRE before java games will work is a real down-side for java. However I don't see it as a showstopper. Especially because every version of Mac OS X comes with a JRE already installed, so the problem exists only for a percentage of windows users.

And it is quite possible nowadays to create java apps that are pretty much indistinguishable from pure Windows apps. I have tried to do so with my game, and think that I have done a good job of it. ( Although you will need java installed to check it out ;) )

tentons
08-21-2004, 12:05 PM
Are there any native complier tools like JET for Mac? (Sucks that Excelsior doesn't support Mac. Darn corporate-centric people!)

Gilzu
08-21-2004, 01:47 PM
The JRE download size figure seems to vary wildly with each posting :)

Actual size as downloaded from Sun: 14.6 MB (j2se1.4.2_04)

And on the same subject - I tweaked and 7-zipped j2re1.5beta3b60 up and got it down to 10.2 MB. Which is about the size of a graphics driver.

And not forgetting the Alien Flux JVM, which is <3MB, but unfortunately has no AWT capabilities and doesn't include Webstart.

Cas :)

This sound like that rotten .NET framework. Why should I bother downloading it? thats the only reason I'm staying with my VC++ 6. If I as a programmer bothered from DLing Java runtime, why should others who want to buy my game?

Bluecat
08-21-2004, 02:01 PM
This sound like that rotten .NET framework. Why should I bother downloading it? thats the only reason I'm staying with my VC++ 6. If I as a programmer bothered from DLing Java runtime, why should others who want to buy my game?
You know, you can use VC++ 7, in the Visual Studio .NET package, to work with standard C++ that has nothing to do with .NET.

I recently upgraded to 2003 .NET to stay compatible with the Boost, and because the new C++ compiler is way closer to the C++ standard than the VC6 compiler is.

cheers

John

whisperstorm
08-25-2004, 08:43 PM
This may or may not be relevant, but there's a recent article from "Joel on Software" about how MS api's are losing to more web friendly ones:

http://www.joelonsoftware.com/articles/APIWar.html


And to just sound even more inane, is there anything that is an equivalent of GameMaker or Klick & Play only having java as it's output? The only thing I've found so far is something like Alice3D.

samnova
09-08-2004, 08:18 AM
And hats off for Cas...

The Grand Prize in the 2004 Java™ Technology Game Development Contest, a GameSpy Development License and AMD high-performance gaming system, goes to:

Super Elvis!

https://games-contest-winners.dev.java.net/

Dont know if it was mentioned before on the site (Posted 28th of July), but must have missed it then...


Long live Java :)

Cas, got a link for the game so we can check it out :) ?

nalenb
09-08-2004, 08:44 AM
I agree with SyneRyder, downloading a JRE is a show stopper for me. I haven't met any regular users that have a JRE installed already (win98 and winxp). I haven't seen any new Windows pc's with Java installed. With broadband downloading 15 megs isn't bad, but most still have modems. Then you add the complexity of the install, most users get scared that they have to install something else. I want my installs to be as easy as possible. Just double click the exe, click next a few times and done. All in a small package. Now that said, I have a problem with .NET and directx too for the same reasons.

princec
09-08-2004, 09:43 AM
Here's the WIP demo: http://www.puppygames.net/downloads/hallucinogenesis/hallucinogenesis.jnlp

I update it fairly regularly as work progresses.

Cas :)

Valen
09-08-2004, 06:38 PM
Hmm, interesting concept Cas. :) Not sure if this is intentional, but the menu button click sound effect sounds exactly like the one in XCOM 2. Luckily for you, Microprose no longer exists. :) Heh, it's kinda sad actually. They released some good games..

Nemesis
09-09-2004, 01:33 AM
I recently (re)installed Java Webstart to try out SuperElvis. I did have some problems as it kept freezing until I found a way to run it by loading Java WebStart first and then entering the JNLP url from there. It's not as painless as shockwave or maybe it's just me!

Nemesis
09-09-2004, 01:36 AM
Sorry to bump th thread, but just to give my 2c...

I would recommend releasing an Windows EXE build of a Java game. The developer still has the convenience of Java plus building an exe will make it even easier to install on Windows.

princec
09-09-2004, 03:21 AM
I'm going to try an experiment this time round and not (initially) supply an .exe installer for Windows.

Cas :)

Nemesis
09-09-2004, 03:41 AM
Well.. the proof of the pudding is in the eating as they say. I wish you luck!

By the way, Super Elvis is looking good - very polished! It reminds me of Robotron but with different objectives. Just a quesion on the theme.. where on earth do you get such crazy ideas?? :) Is this the famous 80 hour experiment?

princec
09-09-2004, 07:38 AM
I dunno, they just seem to evolve in my head... Super Elvis is loosely inspired by Ancipital (Llamasoft).

Wait for the next demo - it's looking even more polished :D

Cas :)