The Daily Click ::. Forums ::. Klik Coding Help ::. Best way to do reflections?
 

Post Reply  Post Oekaki 
 

Posted By Message

JetpackLover



Registered
  01/03/2007
Points
  212
30th October, 2009 at 06:10:22 -

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.

tl;dr

I need a way to do reflections that isn't heavy on active object use.




 
http://www.invincibletime.com/

Devlog for HD MMF Game Omulus. Check it out because it's gonna be awesome. http://omulus.tumblr.com/

Follow me on the twitters https://twitter.com/JetpackLover


UrbanMonk

BRING BACK MITCH

Registered
  07/07/2008
Points
  50102

Has Donated, Thank You!Little Pirate!ARGH SignKliktober Special Award TagPicture Me This Round 33 Winner!The Outlaw!VIP MemberHasslevania 2!I am an April FoolKitty
Picture Me This Round 32 Winner!Picture Me This Round 42 Winner!Picture Me This Round 44 Winner!Picture Me This Round 53 Winner!
30th October, 2009 at 07:56:38 -

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:

Always
-Set Refection x to Player x
-Set Refection y to 100-((Player y)-100)

Done!

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.

http://www.jsoftgames.com/qwing.zip

 
n/a

JetpackLover



Registered
  01/03/2007
Points
  212
30th October, 2009 at 09:03:59 -

HAH cool game engine!

However...

I couldn't get the pseudo code to work...I'm stupid sorry...

When I tried to put in what you have

This is what I have

Always
Set Y coordinate, Y( "Reflection" )+100-Y( "Player 1" )-100

Edited by JetpackLover

 
http://www.invincibletime.com/

Devlog for HD MMF Game Omulus. Check it out because it's gonna be awesome. http://omulus.tumblr.com/

Follow me on the twitters https://twitter.com/JetpackLover


Eternal Man [EE]

Pitied the FOO

Registered
  18/01/2007
Points
  2976

Game of the Week WinnerHero of TimeLOL SignI am an April Fool
30th October, 2009 at 14:01:42 -

Hmm, isn't there an object that can do this? Just can't remember the name though...
Viewport perhaps?

 
Eternal Entertainment's Code'n'Art Man

E_E = All Indie


...actually Ell Endie, but whatever.
Image
Image

UrbanMonk

BRING BACK MITCH

Registered
  07/07/2008
Points
  50102

Has Donated, Thank You!Little Pirate!ARGH SignKliktober Special Award TagPicture Me This Round 33 Winner!The Outlaw!VIP MemberHasslevania 2!I am an April FoolKitty
Picture Me This Round 32 Winner!Picture Me This Round 42 Winner!Picture Me This Round 44 Winner!Picture Me This Round 53 Winner!
30th October, 2009 at 14:48:36 -


Originally Posted by DudeHuge

Always
Set Y coordinate, "Take this out, I didn't say to do this!(Y( "Reflection" )+" 100-Y( "Player 1" )-100



 
n/a

Del Duio

Born in a Bowling Alley

Registered
  29/07/2005
Points
  1078

GOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!Evil klikerHasslevania 2!The OutlawSanta Boot
30th October, 2009 at 15:34:35 -


Originally Posted by Eternal Man [EE]
Hmm, isn't there an object that can do this? Just can't remember the name though...
Viewport perhaps?



Yeah, someoe made an example once using viewport where one side of the game was completely mirrored on the other. That's what I was thinking of too.

 
--

"Del Duio has received 0 trophies. Click here to see them all."

"To be a true ninja you must first pick the most stealthy of our assorted combat suits. Might I suggest the bright neon orange?"

DXF Games, coming next: Hasslevania 2- This Space for Rent!

JetpackLover



Registered
  01/03/2007
Points
  212
30th October, 2009 at 22:26:10 -

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!!

 
http://www.invincibletime.com/

Devlog for HD MMF Game Omulus. Check it out because it's gonna be awesome. http://omulus.tumblr.com/

Follow me on the twitters https://twitter.com/JetpackLover


UrbanMonk

BRING BACK MITCH

Registered
  07/07/2008
Points
  50102

Has Donated, Thank You!Little Pirate!ARGH SignKliktober Special Award TagPicture Me This Round 33 Winner!The Outlaw!VIP MemberHasslevania 2!I am an April FoolKitty
Picture Me This Round 32 Winner!Picture Me This Round 42 Winner!Picture Me This Round 44 Winner!Picture Me This Round 53 Winner!
30th October, 2009 at 22:36:38 -

Welcome DudeH

 
n/a
   

Post Reply



 



Advertisement

Worth A Click