Fog Wiping mechanic advice

Started by Vocalfreak, Tue 03/12/2024 11:48:10

Previous topic - Next topic

Vocalfreak

I'm working on a game and want to include a fog-wiping mechanic, similar to the one in Erica (where players can clear fog off a mirror using gestures or mouse clicks). The idea is for the player to progressively reveal the background as they "wipe" the fog.I tried using overlays but it didn't work. Does anybody have experience with this mechanic?


eri0o

What resolution is your game? Can you give a link to the game Erica, possibly if you have a print or video of this scene?

Crimson Wizard

#2
Please always tell what did you try, and how that did not work. That might let us better understand your current progress and give more precise answer.

In general, the solution would depend on whether you want this "wiping" be fully random, like player using eraser on a canvas, or if you want always same fixed areas to be cleaned one by one.

In the first case you'd need to use Dynamic Sprite and Drawing Surface.
https://adventuregamestudio.github.io/ags-manual/DynamicSprite.html
https://adventuregamestudio.github.io/ags-manual/DrawingSurface.html

In the second, it's possible to do this using several separate objects (overlays or whatnot), representing each area, which are removed by selecting them.

Snarky

#3
If you mean what I think, you should provide one sprite for the "clear" view, one sprite for the "foggy" view, and one sprite for the "brush" template (the shape you want to wipe with, opaque against a transparent background).

Create a "display view" DynamicSprite from the foggy view and display it on screen (for example as an object sprite). When the user clicks on it, figure out the matching sprite coordinates and create a new "brush stamp" DynamicSprite with a copy of the clear view, clipped to match the brush size and the coordinates. Copy the transparency mask from the brush template to the brush stamp, and draw the stamp to the display view (using DrawImage) at the right coordinates. That way, you're drawing a section of the clear view on top of the foggy view, in the shape of the brush.

In order to support gestures, you need to keep track of when the mouse button is down and the mouse moves, and then draw another stamp each time—all the stamps together then form a "brush stroke." (If you want to get really fancy you can also measure the movement distance since the last stamp, and if it is more than some particular value you draw the stamp at intermediate points as well, to ensure that the stroke appears continuous.) Another way to make it fancier is to rotate the brush or use different brushes depending on the direction of the gesture.

SMF spam blocked by CleanTalk