Thursday, March 6, 2014

Theory on doors

This week I've been working a little bit on many different things but I've had the most trouble with doors. Doors in our game are intuitive; the player can interact with a door if he is close enough, when he does the door opens away from the player. The door cast a shadow just like the walls but it gets complicated when it comes to the door-frame.

From the alpha play test we got some feedback concerning the walls; they looked like huge 3D walls. Some thought it was cool, others didn't. Some merely pointed it out and asked if it was out intention to have that effect. One suggestion to fix the 3D feeling was to limit the view when looking through doors, so this is what I've been trying to do.

My first thought was to take the same function as the wall shadow but move both the starting vectors (the two points on the door) further away from the player. I also thought the length by which the starting vectors would be adjusted would be dependent on the distance from the door to the player; this meaning a player far away from the door would only see that the door is open but not much through it, and a player close to the door would see as normal (no shadow from the frame at all).
   This sounded simple, but when I delved deeper into how to get the values by how far the starting vectors should move, the complicated stuff began. I realized it would look "off" if the vectors would move the same distance, so I had to figure out a way to get the both values correctly.
Circle theory
   After some time I had two different theories. The first one was to get the line from the player to one of the vectors and check where it intersected a circle with center in the middle of the door. Doing this for both the vectors would send them back further if they were closer to the player, this way it was also very simple to change the distance you could see by adjusting the radius of the circle.
   The second idea was to get the perpendicular line to the line from the player's position to the middle of the door. Then calculate where both lines from the player to each of the vectors intersected with the perpendicular line. This would give the same result and changing the distance would simply to take a point further back on the center door line.

Perpendicular theory
I never implemented this however. I have started working on it but when we got our new lighting system from our lead programmer this felt unnecessary since the player can't see far anymore.

I know this was a theory heavy post, but that's since I haven't made anything big this week this was the best thing I could write about. Thanks for reading and stay awesome!

1 comment:

  1. I remember from trying your game at the playtesting that the walls had a really interesting 3D-effect which I quite liked, even though I wasn't sure if it was meant to be like that or not (looked like a cool side-effect of the lighting system).

    I haven't tried working with lighting or masking in a 2D-game before (it's a lot easier in a 3D-game with premade functions ^^), but I can see a lot of reasoning behind your theories.

    I do wonder about how it would look with the light like how you showed it in the pictures. With a light-shape like that, shouldn't it mean that the player is emitting a light-source on a line aligned to himself, pointing in the green line's direction in the last picture? If the room the player is in is lit up, then I imagine it would more similar to this - http://i.imgur.com/O5MTvt3.png - where the light comes from the room and stretches as far as it can into the next room, displaying only what the player can see of it (since there's a wall in the way as well).

    It's hard to really know how it's supposed to look like without actually seeing it myself, so I'm just going to say good luck with it ^^
    (I always stay awesome, btw)

    ReplyDelete