This is really long, if you don't want to read check the bottom for the abridged version.
I'm making a game with a beatem up style perspective,ie only left and right animation directions.
And in my game I have a mirror that the player passes and I was wondering what is the best way to do a reflection?
What I have currently is this;
My player character is using PMO with 0 gravity so I can have 8 direction movement btw
Right now I'm using the Platform movement object with a duplicate sprite called "Reflection" that uses the same movement as my players one except the reflections X position is linked to the player and the UP and Down are switched. This is because if you go farther away from a mirror you'll see more of your body and if you go closer you eventually cover your reflection up.
So I have 2 sprites each with their own collision box that the images are linked to.
The reason the reflection has a collision box is because the freaking reflection PMO wouldn't stop moving when the player hit a wall. No matter what I did. I tried setting up conditions that would negate the movement of the reflection, such as
"Player1 is not overlapping backdrop"
"Repeat while pressed Up"
>Set Reflection PMO to Y velocity 150(opposite of Player 1's)
Anyway none of that worked. So I figured I would just set up a collision that the Reflection PMO would collide with so it would freaking stop moving.
Now it all works...barely and the problem I have with this is how freaking ridiculous the code is and how many actives I need. There has to be an easier way.
I can't stand having a mirror frame active, the blue part of the mirror(otherwise you could see through to the wall), the reflection character image, the 2 actives on either side that block out the reflection from being seen before it enters into the mirrors view and they have to be active because otherwise the Reflection could be behind them and now I have an active that is edited so it acts as 2 collisions. One so the reflection can't go to far below the mirror and one so it can't go to above the mirror.
I need a way to do reflections that isn't heavy on active object use.
Did you seriously apply movement and collisions to a reflection object?
Just do a little math and you could do a reflection in one condition.
Figure it out on paper. Where do you want the reflector to be placed?
If the reflector is parallel with the x axis you simply do a little math equation.
let's say that the reflector is located at y=100 then the reflection should be at the same position as the player at y=100. But as the player walks down the reflection moves up! Sooooo, do this:
-Set Refection x to Player x
-Set Refection y to 100-((Player y)-100)
I'm making a game that has a shadow engine built in. It's simlar to reflections, but the math is easier.
Here's the source for you to look at.
I finally got it to work! At first I thought I was supposed to be working with 2 of the same numbers but then I realized the code you posted makes the movement of the Reflection opposite of the Player. So knowing that all I had to do was edit the numbers to suit my frame. Thanks UrbanMonk!!