MODULE: Easy mirrors 2.0

Started by Monsieur OUXX, Thu 11/07/2013 10:24:45

Previous topic - Next topic

Monsieur OUXX

Quote
IMPORTANT NOTE :
- This module was created before late_repeatedly_execute_always was introduced
- If you replace repeatedly_execute_always with late_repeatedly_execute_always it should procude better results (no latency in character frame mirrored)




This allows you to create small mirrors in your game very quickly.

FEATURES:
- three types of symmetry: front/back (the mirror is facing you), left/right (the mirror is turned 90° from your viewpoint), none (the character is repalced with any character of your choosing, allowing upside-down symmetry of any crazy idea you have).
- you can choose the opacity of the mirror: 0.0 means it reflects perfectly. 1.0 means it doesn't reflect anything.
- Custom-shaped mirrors : just pick a sprite as a mask and your mirror can have any shape. It also uses alpha (you can have cracks in your mirrors, a soft outline, etc.).
- Attenuation: when the player moves away from the mirror, his reflection becomes less and less visible.
- Moving reflection : you can make the character's reflection move around to simulate a moving mirror (water surface, etc.)
HOW TO USE
- See the demo game and the header script. It's as simple as possible : choose an object as the mirror, another object as its symmetry center, and a region to trigger it on or off when the player walks on it.

KNOWN ISSUES
- [version 1.x only] [It's quite slow. It's meant for small mirrors. I'd say no more than 200x100 pixels reflecting simultaneously.
- [version 1.x only] There are tiny rendering bugs (sometimes the mirrored image is late one frame, or sometimes it's not aligned properly -- but the player won't really notice). Those will be fixed in next version.

- It only reflects the player character. It doesn't reflect any object or animated background or anything else. But it's easy to tweak the module and make it reflect one or several NPCs.

HISTORY
- 2013: uploaded version 1.x which work with per-pixel computation (allows shaders)
- 31 july 2014 : uploaded version 2.0 which drops the whole per-pixel thing and uses standard AGS characters as the reflection.

>>> DOWNLOAD 1.1 (obsolete, per-pixel computation) <<< (sources + compiled demo game)
>>> DOWNLOAD 2.0 (faster, more reliable) <<< (sources + compiled demo game)

Also you might like the private jokes for point-n-click lovers in the demo ;)


==================

UPDATE: You know the way you always learn new things in AGS scripts?
Well, you'll notice that my module uses the following silly technique to get sprites Width and Height :
Code: ags

      //not the actual code in the module
      DynamicSprite* s sprite= DynamicSprite.CreateFromExistingSprite(something.Graphic);
      int width=s.Width;
      int height=s.Height;


Well, feel free to replace it with this, which will be much faster and memory-savy:
Code: ags

      width = Game.SpriteWidth[something.Graphic];
      height = Game.SpriteHeight[something.Graphic];

 

kaput


Kitai

Seems like an amazing job! Not tested it yet, but I had to implement a mirror too in an AGS game and never figured out how I could make a module with it. So I'm pretty impressed by the customizable and yet user-friendly aspects of this module.

But where is the mirror on the screenshot you posted? Is it the golden stone? If so, what does it reflect?

Ghost

Quote from: Kitai on Thu 11/07/2013 12:47:31
But where is the mirror on the screenshot you posted? Is it the golden stone? If so, what does it reflect?
The golden nugget, a section of the icy wall and the icy ground all reflect; in the screenshot this doesn't show though- but it looks beautiful in action.

Well done, Monsieur; I never thought I'd need mirrors. Now I will put them everywhere!

Monsieur OUXX

Quote from: Kitai on Thu 11/07/2013 12:47:31
But where is the mirror on the screenshot you posted? Is it the golden stone? If so, what does it reflect?

Just run the demo already! :)
There are 5 mirrors, just not on the screnshot (yes, I know, that's silly)


Quote from: Ghost on Fri 12/07/2013 00:12:54
Well done, Monsieur; I never thought I'd need mirrors. Now I will put them everywhere!

Thanks!
 

Gribbler

I always avoided rooms with potential mirrors while game designing. Now I don't have to. Thanks so much!

Wicked

That looks absolutly amazing I was gonna have to figure out how to make some mirrors for my game but wow this is awsome , I wonder if it works well with animated background or water

Adeel

    This is really handy, Monsieur. Played your demo. Loved the reference :D. Now I can implement it my game.

Ryan Timothy B

Yes that was definitely a bad screenshot if you wanted to display what this module does. I recommend changing it.

As for the demo game, that was pretty impressive. What is the scanlines.txt for, and with that question, why do you output it as a txt with raw ints instead of a binary file? That way the player is not wondering what this text file is and if they should read it.

Monsieur OUXX

Quote from: Ryan Timothy on Sat 13/07/2013 17:03:12
I recommend changing the screenshot.

Updated screenshot :



Quote from: Ryan Timothy on Sat 13/07/2013 17:03:12
What is the scanlines.txt for, and with that question, why do you output it as a txt with raw ints instead of a binary file? That way the player is not wondering what this text file is and if they should read it.

Wooops! That was meant for debugging only! Now I understand why the demo game suddenly got so slow! :D
It's just a matter of commenting out the line calling the function dumping of the text file.

Quote from: Horrorfiend on Sat 13/07/2013 01:00:05
I wonder if it works well with animated background or water
It's not compatible with animated backgrounds. Animated backgrounds are evil anyway! ;)
 

Monsieur OUXX

Bumping to remind Iceboty to move this to the modules forum.
 

Gilbert


EliasFrost

The download link is broken :( Think you can fix it please? :)

selmiak

maybe someone moved stuff around on the dropbox? ;)
try this link instead pls.

EliasFrost


Monsieur OUXX

Uploaded version 2.0 (see first post for downloading the demo game)

Gets rid of most issues, especially it's much faster (even though less flexible) since it drops the whole per-pixel computation approach.

[imgzoom]http://33.media.tumblr.com/49776a07d6c33839e4b33cb35d89266a/tumblr_n9lcs53I9P1tsfksfo1_1280.png[/imgzoom]
 

Cassiebsg

Hey! Great module! Don't currently have any mirrors planned, but it's nice to have the option. :)

BTW, how do I get to the Ice Cave? Whenever I click on the arrow that says "Go to ice cave", I just get the harbor. :(
Only changed from 3x to 2x in winsetup.
There are those who believe that life here began out there...

Ghost

#17
Quote from: Cassiebsg on Thu 31/07/2014 21:27:18
Whenever I click on the arrow that says "Go to ice cave", I just get the harbor. :(
You can debug into that room- Indy then states that it is unused and has no mirrors, so you are not missing out on anything ;)

Love the update, Monsieur! All those tiny extras are great to have (tints et al); in my opinion this should be included into the AGS download. It may not be used THAT often, but whenever someone needs a mirror the module covers it (nod)

Monsieur OUXX

Fixed the "to ice cave" thing and updated the download link. But as Ghost stated, there is nothing in that room, it's just there for legacy from version 1.X (it's a pretty room ;-) )
 

Mehrdad

My official site: http://www.pershaland.com/

SMF spam blocked by CleanTalk