I'm having trouble implementing easy mirrors, specifically in declaring a new mirror - I'm confused what the parameter 'center' is.
struct Mirrors2
{
//tells the module that character "c" can be used as a mirror reflection.
//Call this function at least once (i.e. give the module at least one character)
//otherwise it can't work!
//You should call this function as many times as there are mirrors in the room
// that has the most mirrors.
//For example if there are two mirrors in a room, and if that is the room
//of your game that has the most mirrors, then call this function twice.
//(with two different characters!).
import static void AddMirrorChar(Character* c);
//Declares a new mirror in the current room. The player MUST be in that room when NewMirror is called!
// This must be done only ONCE in the entire game (in "first time enters room")
// The mirror starts disabled. It has to be enabled (using script) afterwards to be visible.
//
// 'mirror' is the object containing the sprite used as the mask.
// 'center' is a marker. The center of its sprite (width/2, height/2) should be where the player would stand (his feet coordinates) if he was glued to the mirror ;)
// 'symetry' is one of the symetries in the enum above
// 'x_offset' and 'y_offset' allow to shit the reflection by a constant number of pixels
// 'opacity' must be in 0.0, 1.0. Note: if the mirror's opcaity is 1.0 then it's fully opaque, therefore there's NO reflection!
// 'distance_attenuation' (recommended value '60.0'): if the player stands 0 pixels away from the mirror, his reflection will appear fully opaque. If he's standing 'distance_attenuation' pixels away from the mirror (or more), his reflection will be fully transparent
import static void NewMirror( Object* mask, //set to null if no mask
Object* center,
Region* reg, //set to null if mirror always on
Mirrors_Symmetries symmetry,
float opacity,
float distance_attenuation,
int x_offset=0,
int y_offset=0);
//Tells the module that this mirror should use an entirely
//different character altogether as the reflection, instead of computing
//the reflection.
//That character should use Views that have the same number of loops and frames
//as the player character.
import static void SetSubstituteCharacter(Object* mask, Character* c);
//To modify the offset you've set in NewMirror
import static void SetOffset(Object* mask, int x_offset, int y_offset);
//To modify the opacity you've set in NewMirror
import static void SetOpacity(Object* mask, float opacity);
//That doesn't delete the mirrors in memory (which is done automaticaly). It just disables them so that they're not rendered
import static void DisableAllMirrors();
//Enables all mirrors in THIS room if they've been previously declared with 'NewMirror'
import static void EnableAllMirrorsInRoom();
//Enables one mirror selectively
import static void EnableMirror (Object* mirror);
I'm confused what I should put for the center parameter.
This is the game: https://tilapisha.itch.io/gobyworld
Password: gummy
Github Repo: https://github.com/lishap/gobyworld
My guess is that object is used to specify the coordinates used to position the mirror image. Draw a small cross hairs sprite (like 9x9 pixels or something like that) and put it on a new room object. Then move the object to the floor below the mirror.
Hmmm, I did that, and still nothing.
"Still nothing"?
As in, nothing mirrory happens in-game?
Did you activate the mirror?
QuoteThe mirror starts disabled. It has to be enabled (using script) afterwards to be visible.
AddMirrorChar -> use this on game_start, if your room with most mirrors has 1 mirror, call once, if your room with most mirrors has 2 mirrors, call twice ...
You pass a dummy character to this function (NOT cGoby), this dummy character is going to be moved by the module, mirroring the character being reflected
NewMirror -> You are using this correctly in room_FirstLoad
You can also do something like the below
bool mirrorsCreated = false;
function room_Load()
{
//do this for each room that has mirrors
if (!mirrorsCreated) {
Mirrors2.AddMirrorChar(cDummy);
Mirrors2.NewMirror(oMirrorMask, oLeftMirrorCenter, null, eSymmetryHoriz, 1.0, 50.0, 0, 10);
mirrorsCreated = true;
}
Mirrors2.EnableAllMirrorsInRoom();
}
Now there's a catch, this module is like super old and it has a scripting error, so I know it says you can make the region be null, but that is a lie
You actually have to make a region in your room, which is the area where the character can stand that will activate the mirror. If you use for instance region 2 you can then pass region[2] there.
the mask is more something like this, with a hole so the cDummy can walk through the mirror border
(https://i.imgur.com/8fvtLj7.png)
Finally, I don't understand why you are making the game using 16-bit colors, this causes all sorts of hard to use alpha values, I don't know how things work in 16-bit
Quote from: eri0o on Fri 06/05/2022 04:18:10
Finally, I don't understand why you are making the game using 16-bit colors, this causes all sorts of hard to use alpha values, I don't know how things work in 16-bit
16-bit games don't use alpha on sprites themselves (they are created fully opaque), but they still may use Transparency property on objects.
Quote from: eri0o on Fri 06/05/2022 04:18:10
the mask is more something like this, with a hole so the cDummy can walk through the mirror border
(https://i.imgur.com/8fvtLj7.png)
Will you explain this to me? The picture is a bit confusing, I made a mask that covered the whole room, and left the mirror transparent, but the character still can be seen on the walls!
https://ibb.co/p0xqyGQ