Sign in to follow this  
jwezorek

[java] basic questions about writing a game applet

Recommended Posts

I want to write a 2D puzzle game in Java that plays in a browser and have a few questions. 1.) Is Java2D going to have everything I need? Basically I need to be able to load and blit sprites with internal alpha. Can Java2D blit bitmaps that have an alpha channel? Is it easy to load, say, PNG's or am I going to have to write that myself? 2.) I plan on rendering to an offscreen bitmap and then blitting that to the screen. I'd rather not do a dirty rectangle approach if I don't have to. I plan on just re-rendering everything each frame. About how big can I make that bitmap so that users with average systems get reasonable performance? Is 800x600 too big? I know it depends on the game but figure for something like Bejeweled. 3.) Are things like JGame, PulpCore, or Slick worth looking into for a simple game? I've read about each of them and am not sure what I would really get out of them if I don't need their advanced features. I'd rather not have to have a dependency on OpenGL or 3rd party code in general.

Share this post


Link to post
Share on other sites
1) Java will have everything you need, unless you want to show video. Java2D should cover your rendering needs. Image, BufferedImage and/or ImageIO in combination can handle anything short of DDS, certainly not a problem with PNG. I'm not familiar with sound support in applets but I doubt it would be a problem.

2) You can double-buffer of course, with BufferedImage or with VolatileImage. Read this and this. If you go the hardware-accelerated route you should be able to do quite a lot.

3) Never heard of JGame. Haven't tried PulpCore (or rather, last time I tried it none of the examples worked, but it seems to work now) but it might be useful. Slick introduces dependency on LWJGL and last time I checked used a bunch of singletons, so I wouldn't use it. In general I would advise against taking a stance against dependencies but for an applet this makes perfect sense of course. The LWJGL-type applet is pretty useful though so for anything more serious than Bejeweled (say, another Runescape) I would go with LWJGL. However, it does add up - the libraries are 256k, the platform binaries for windows are another 226k. For a small 2D puzzle game this is not very cost-efficient.

If you deploy your applets via JNLP (not webstart) you get to specify your heap size, or switch to OpenGL rendering if you want. You could also check out JavaFX and see if that offers you anything new.

Share this post


Link to post
Share on other sites
Quote:

2) You can double-buffer of course, with BufferedImage or with VolatileImage. Read this and this. If you go the hardware-accelerated route you should be able to do quite a lot.


Thanks, that helps a lot. I didn't know about hardware-accelerated Java2D. I think I'm going to go with VolatileImage and not bother with any of the 2D game frameworks.

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