I'm trying to write a graphical roguelike game in Processing, and I want to be able to use some of the neat effects that Processing makes possible. Ideally, I want to use flashy effects like lightning and fire and project them onto the game area. The problem is, for many effects, you need to refresh the background in each loop of draw(), which erases whatever you've drawn so far, which will include the current game map. I'll include a lightning example and the end of this post.
My question is, is there a way to include flashy effects over top of an image you've already created via processing? I have a couple ideas, but I wanted to run them by the community before trying what could be a dead end. Currently, I'm stuck having to redraw everything on screen after each iteration of my effect.
1) Could you include two PApplets in the same JPanel, and give one of them a transparent background, so that one effect appears over the other PApplet? I've tried this but I can't get the background to be transparent. Apparently you can do this with createGraphics(), but it won't work with OpenGL, so I'm hesitant.
2)Is it possible to dynamically read the graphical data on the PApplet, and then quickly make that the background, so that it can be refreshed in draw() more quickly?
3) Is there a way to make "temporary" marks? As you should be able to tell if you look at my lightning example, it consists of a somewhat randomly generated wiggly line, which is then quickly erased and replaced by a new one, and so on. If there were a way to make temporary effects, that would also work.
Thanks in advance for any input or guidance.
Here is the lightning example I mentioned:
It works fine, but I've included it for reference.
I'm starting a new project in eclipse, and I'm aware that we're supposed to avoid swing. I'm fairly new to Java, but all of the window/frame objects are in swing, such as JFrame. Does that mean that everything has to happen inside the Papplet that processing creates? Or are there other Java based windows that you can use?