views:

310

answers:

6

Hi, I'm currently working on a tile-based game in Java2D, and I was thinking of adding some cheap eye candy.

For example, implementing a simple particle system (maybe something like this) for explosions and/or smoke.

Do you have any suggestion for relatively easy to program effects that wouldn't require drawing a lot (or at all) of new art?

Tutorials and code samples for said effects would also be most welcome!

-Ido.

PS - if absolutely necessary I could switch to something like LWJGL/JOGL or even Slick - but I rather stay with Java2D.

+5  A: 

Implementing blurs and other image filtering effects are fairly simple to perform.

For example, to perform a blur on a BufferedImage, one can use the ConvolveOp with a convolution matrix specified in a Kernel:

BufferedImageOp op = new ConvolveOp(new Kernel(3, 3,
    new float[] { 
        1/9f, 1/9f, 1/9f,
        1/9f, 1/9f, 1/9f,
        1/9f, 1/9f, 1/9f
    }
));

BufferedImage resultImg = op.filter(originalImg, resultImage);

Not quite sure when a blur effect is needed, but it may come in handy some time. But I'd say it's a low-hanging fruit for its ease of implementation.

Here's some information on convolution matrices. It can be used to implement effects such as sharpen, emboss, edge enhance as well.

coobird
Motion blur can be made to look really nice in 2D and its very simple to achieve.
shoosh
Thanks, I'll use that!Any more effects like that you know of?
Ido Yehieli
A: 

You could try using sprites.

MikeNereson
+3  A: 
coobird
A: 

Transparency effects (e.g. for smoke) can make a big difference without too much effort. No idea if this can be done in Java2d though.

Mark Pattison
+1  A: 

Filthy Rich Clients describes in great detail a number of very nice Java2D/Swing effects. It also gives an excellent theoretical background to these effects. I'm not sure how much low-hanging fruit there is, but it's a great resource for browsing.

One possibility might be to do something with alpha compositing. Maybe combine alpha composite with Timing Framework. Depending on the rules of your game, it might even be important to gameplay to selectively and time-dependently make objects semi-transparent.

Rich Apodaca
A: 

Anything that looks kind of realistic, things bouncing off of other things, rolling off, etc. can be kind of cool and if your game is a side scrolling 2D rather than top-down 2D you might be able to use a ready made physics engine like Box2D to do something cool with very little effort. Here's a Java port of Box2D that you could use for it.

John Munsch
I used Phys2D for stuff like that before.Sadly it's a top-down game.
Ido Yehieli
Ah well, it was worth mentioning. In that case I would definitely go the particle route. But ONLY after the game is finished enough to be playable. Getting it in people's hands to play is always your highest priority.
John Munsch