Programming 2.5D

Hey, I wanna start learning Java in order to create a 2.5D game, which is like 2D images creating a ‘fake’ 3D look. I can’t figure out what I should be using though.

First of all, I want it applet based so people don’t have to manually download. They should be able to simply run it in most browsers on most systems.

With that in mind would I only be able to use pure Java and Swing? or can I use Java2D or LWJGL ? or would those not run on their computer unless they manually install them (like with Java3D)? or would it just require a verification screen? and if I can use Java2D and LWJGL, which should I use? LWJGL’s OpenGL for most of it I’m thinking? Should be some lighting, shadows (but I think I can do that manually), transparency, and a lot of graphics.

Thanks much!

Don’t use an applet. You can create an application and use Webstart so all the user has to do is click on a link and everything will be taken care of.

If you just want to use normal Java2D graphics, then there is nothing extra you have to do to get it to run.

If you want to use Fullscreen mode or use a library that uses native code, like LWJGL, then you need to sign your jar file that contains your application and the user will be prompted to accept your signed application. Don’t worry about this though, because if you start to sell your game, then you can afford a trusted digital certificate.

Slick is a 2D library built on top of LWJGL. So you the performance of 3D with the ease of 2D. It might be what you want to use for your game.

If you want to use an applet, the easiest you can do is just use Java2D.
I found that even on java 1.4 (at least on windows), the performance of drawing resized images can be good enough to do a 2.5D game, as long as you use 1-colour transparency for your images, not an alpha channel.

If you want a better chance of getting good performance across platforms (and good performance when using alpha channel), even on java 1.4, using Slick or straight OpenGL through LWJGL or JOGL is the way to go. It is possible to use LWJGL and JOGL in an applet, although I heard you could run into some compatibility problems on some browsers/OS-es, and it’s all a bit more complicated to set up.

Thanks for the information CaptainJester.

So that’s how it works, that verification popup can be removed if you buy a trusted digital certificate eh, that’s nice. :smiley:

Sorry I didn’t mention this, but it must be an applet. Eventually I’d like to make a multi-player, and want it as seamless and compatible as possible.

I read LWJGL now works with applets, but is it very limited and not worth using over Java2D for applets? I also want to consider compatibility, and I read LWJGL will work on JDK 1.2 and JVM.

Ohh, I see, I’d be overloading the applet, even if it was single-player? Even though I didn’t want to start with multi-player, I might have to, for these purposes. So perhaps I should make a simple server/client first, the Java server does the hard work and sends the results to the Java applet client.

Well, if I were to use a web-start then that would require Java Sun (JDK 1.4.1 too I think).

If I learned anything from Flash it was that most people use outdated software. So in Flash if you want your app to be compatible with most people without sending them to manually download and install, you design for the older versions. We’re up to Flash 9, and professionals still make websites in Flash 6.

Slick looks great, but still in the lower stages of development. I’d have a big problem if it was buggy and they slowed down or stopped development wouldn’t I? I pretty much want to start from scratch as low-level as possible.

RuneScape runs on your default java client, MS or SUN. Looking at it more, it actually does use some hefty textures (and all that 3D rendering). I was afraid it would require too much downloading (loading) to use 2.5D.

http://www.geocities.com/rs2comparison/banks_files/image008.jpg

Oh okay, so I should plan for Java 1.4 or higher then?

RuneScape runs on Java 1.1, lol ???

Yes, target at least java 1.4. It’s also quite a safe bet these days.
And LWJGL at least needs java 1.4 or higher, it won’t work with 1.2.

Yes, back then it made sense as there was this hideous MS VM installed everywhere which only supported 1.1.
Nowadays it doesn’t make much sense anymore to target this old version, as MS doesn’t support their VM anymore, and the Sun JVM is usually the one that’s installed.

By the way, and just to be sure (just looking at your screenshot): My comments about using Java2D for creating 2.5D were thinking that you just use image scaling/zooming for creating your 3D look. No real 3D textured polygons or anything.

Great, thanks erikd. It’s still amazing it runs on 1.1 though eh? Imagine if they upgraded to 1.4 and improved their engine.

Oh, no I won’t be using 3D. I was just comparing it with RuneScape because it’s the best (and only) example out there.

Graphics wise I’d be shooting for something like Diablo 2, or maybe lower. It uses DirectDraw 7 (option of Direct3D).

I don’t think a Java applet is capable of graphics close to Diablo 2… Maybe if a lot of detail is removed and theres more tiles. Even then the animations are very large and detailed. Of course there would be culling, and graphics would be downloaded on demand, it still seems like it might be too CPU/RAM intensive.

I can ask to “allow Game Name to store files on your computer” though right? So theres no re-downloading playing the second time.

I can absolutely guarantee you that java applets are capable of it :).

Time to get cracking then eh :slight_smile:

Just to clarify, capable with: LWJGL/Java2D on Java 1.4, without changing any Java Sun variables to allow the applet more RAM, and still running at 20 FPS or more?

Hahaha :smiley:

Oh and which one has more 2D applet support, LWJGL or JOGL?

Thanks

Any setup unless it’s Windows 98 era (400 MHz, 128 MB, no video card) is more than capable of rendering 60 FPS for a reasonable LWJGL-powered game. The days of Java being “slow” are long past us.

  • Jon

Great thanks :slight_smile: I just wasn’t sure how reasonable the above game (screenshots) on an applet would be.

but I wouldn’t recommend it!
There is a 128 MB heap limit in applets which blows for any big game like diablo.

128MB eh? Okay thanks :slight_smile:

D2 initially loads 35MB at menu, 50MB in game, 100MB after around 5 minutes. In single-player it stores everything that happened in that game. Since they used single-player as the base for multi-player it does the same on battle.net when it shouldn’t. Meaning the server sends all the players in the game information on the game to store in memory even if they aren’t in the same act, even close, or finished 5 minutes ago. After 15-20 minutes D2 finally frees the memory. Designing a multi-player game to begin with leaves me at an advantage because I should only have to use the client as a remote and for rendering/audio. So as they leave an area I can queue to free that memory. So I’m thinking the game show hover around 75MB, but under a huge load it could get up to 120MB. To test I started at 50MB in Act 5 and went and killed Shenk and all the surrounding areas. It got up to 85MB, and if they want to go anywhere the memory would be freed.

What do you think? What happens when it hits 125MB? Can I detect when it hits 120MB and disconnect the user?

Thanks again for the help fellas!

I’d wager Diablo2 also used palettized 8bpp images.

Java2D’s support for these image types is poor - as far as I understand, while they will be stored in this format in the heap, when they are cached in vram they will be expanded to 32bpp argb.

Also palette manipulation (which Diablo made extensive use of) will break the hardware acceleration pipeline.

If you are intending on making a Diablo clone, I’d suggest not using Java2D - the API is simply too inflexible to efficiently achieve what you want to do.
There is nothing more frustrating than having to design around a limited capability API.

Aww okay, thanks man. I don’t know anything about this yet, and that’s exactly why I’m asking. So I learn the right API and procedures.

What about LWJGL or JOGL?

Sun should really allow applets more than 125MB, by default. Computers are much better nowadays and it just an unnecessary limit. 256MB or 512MB would be awesome.

Does it have to be an applet? Are you open to a WebStart app instead where the requirements are less stringent?

If you have to stick to applet, use LWJGL, and manage your memory carefully, and you should be able to squeeze it out.

  • Jon

Yeah, it has to be an applet. Otherwise I would stick to 3D with C++.

Who knows though, I might change my mind in the future and go with a download or WebStart. I’d only have to change the client.

It’ll be tough but I’ll do my best memory managing. :slight_smile:

Edit: I’m about to say screw it and not use an applet. But why even use Java then? :-X

Edit: Would be a good idea to allow more memory usage for digitally certified applications. That removes the issue of allowing any random applet to use tons of memory.

Edit: Do you think by the time I finish the game, around 3 years, they would have increase the memory an applet can use? Have they done that before?

You’ll probably start getting OutOfMemoryError’s all over the place. Do keep in mind that the runtime probably starts with sucking up 25MB+.
Consider using Java Webstart instead.