Friday, September 26, 2014

An Analysis of Arkham Horror

Me and my group have been playing the board game Arkham Horror this week, and this is my analysis of the game.

Arkham Horror is a co-op ameritrash board game for 1-8 players based on the Cthulhu mythos. Each player plays an investigator and will be walking around Arkham and other worlds searching for clues. The objective of the game is to defeat the Ancient One, or Great Old One, and this can be done in mainly three ways: 'killing' it in combat, sealing gates or closing all open gates.
It's not supposed to be easy though as the Ancient One will fight back. Each Ancient One have their own unique passive and worshippers that makes the game harder for the investigators. Not only that, every turn a gates to other world opens throughout Arkham releasing monsters the investigators have to fight in order to walk arounf the streets. If the Ancient One awakens and the investigators are all devoured, they have lost the game.

Investigators

Each player will be playing one investigator and if that investigator is devoured before the Ancient One has awakened, you may choose a new investigator to play as. Each investigator have a pool of Sanity and Stamina, if his sanity is reduced to 0 he is driven insane and is taken to the Arkham Asylum where he can regain his sanity. It's the same thing with Stamina, he gets knocked unconscious and is taken to St. Mary's Hospital where he can regain stamina.
Each investigator also have attributes: speed, sneak, fight, will, lore and luck. These are very important to keep track of and are essential for the planning part of the game. Each investigator have a max and min in each stat and you can adjust them each turn depending on what he is going to do, but you need to think carefully for increasing one skill will decrease another. They come in pair, skills: speed and sneak, fight and will, lore and luck. If you increase his speed you also decrease his sneak and so on.
Investigators also have their own uniqe abilities that make them feel even more different from all the other investigators.
And lastly all investigators start with some of these things: money, clues, common items, unique items, spells, skills, allies and a few other things.

Ancient Ones

All Ancient Ones have a doom track with room for 10-14 doom tokens, depending on the Ancient One, and it is basically the timer of the game. The doom track starts empty and each time a gate opens in Arkham, a doom token is added to the doom track. Once the track is filled, the Ancient One awakens and the investigators must immediatly fight it.
The Ancient One also have worshippers, making some monsters stronger or adding stronger monsters to the game.
It also has a power that makes it harder for the investigators to win the game.
And lastly, if it awakens, it has a combat rating and an attack.

Game board

The game board mainly represent Arkham with all it's important locations and streets. On the side of the board are the other worlds.

Monsters

Each time a new gate opens, or a monster surge occurs, monsters are drawn from the cup and placed in Arkham where the investigators then have to defeat them. If there are more monsters in Arkham than a certain number, depending on how many players there are, the terror level increases. If the terror level hits 10 there is no longer a monster limit in Arkham and the board can be overrun and the Ancient One awakens.

Gates

When a gate opens it's placed on a specified location in Arkham, if an investigator enters that location he is sucked into the gate and places his marker in the specified other world on the side of the board. He then spends two, can me more or less depending on what happens, turns in there before he returns to Arkham through the gate he entered. When he has returned he may close the gate, if he succeeds he may spend 5 clue tokens to seal it as well. The good thing with seals is that gates cannot open on them.

And finally the core mechanic of the game is; Mythos Cards

These are the game playing against the players. The start of every turn begin with the Mythos phase. A mythos card is drawn and a gate opens at the specified location and a monster is placed on the gate. If there already is a gate on the specified location, then it's a monster surge instead and a monster is placed on each open gate.
Then it's the monster movement. Each monster have a symbol and if that symbol is shown on the mythos card the monster moves.
After that, the event of the card is read out loud. These events can be both harmful or helpfum (more often harmful) and they can also stay in play for several turn.

Mythos cards are the core mechanic since they are the one that opens the gates, hence adding doom tokens to the doom track hence making the time tick forcing the players to act fast. They also make sure that the monsters do just stand there but move around in a unforeseeable pattern making it harder to plan for the future.

Here's the most interesting system; The phases of the game.

Upkeep phase

At the start of each turn is the Mythos phase and the players can't do much if anything at all in that phase. After that is the Upkeep phase, what I call the planning phase. Here the players may adjust the skill sliders, untap exhausted items and use upkeep or any phase actions. Untapping exhausted items and using upkeep actions is trivial, but the real interesting part is the adjustment of the skill sliders.
Every turn is new and there is something different in Arkham, more often than not you'll have to adjust the skills in order to have a successful turn. You'll have to disscuss with your team mates what you want to do, what they want to do, what needs to be done, which monsters needs to be killed, which gate needs to be closed and so on. When you all have a plan you need to see which skills are needed for the action you are going to take later, you cannot change the skill sliders after the upkeep phase.

Movement phase

This is pretty simple, the players move. If they encounter a monster they have to fight it.

Encounter phase

Depending on where the player stands, different things happen.
Generally nothing happens on streets.
If the player is standing on a location he may then either draw a location card or use the locations special encounter (if the location doesn't have a special encounter the player must draw a location card). On the location card several thing can happen: gates can open, monsters can attack the investigator, the investigator can gain or lose items, money, sanity, stamina and other stuff.
If the player is standing in another world he has an encounter there drawing a card from the other world deck. These can be both harmful and helpful, but like always they are more often harmful.

After the encounter phase is over a new turn begin with the Mythos phase.

Enough with explaining the game, now;

The positives

One of the great thing about Arkham Horror is that it's a team based game where everyone work for the same main goal, which allows for a lot of communication and team strategy. At the start of the game each player gets a few random items, and even if you are unlucky and do not get what you want you can always exchange items with your friends.

Another great thing is there is little down time. Everyone are often active all the time and thanks to the flavor on all the cards players feel engaged from beginning to end.

The way the game fight the players is also great. It constantly pops up more stuff to take care of and if the players doesn't handle it in time it can get out of control telling the player: "You need to deal with this". It is also semi random, there are locations that gates open more often in and when you have played a while you know of these locations without counting the cards. Also the monsters move from time to time which makes it hard to plan to far ahead because you do not know where the monsters will be.

The negatives

Arkham Horror, with out any expansions and following the rules, is way too easy. It's more like Arkham Faceroll which is not as cool of a name and it is very sad to be honest. You can make it harder for yourself, choosing harder Ancient Ones and investigators, but it's still easy with 4 or more players.

There are a few not so bad things, like; it takes a long time to set up and play, and it take huge amount of space of the table. But who cares?

Target Audience

First of all; anyone who knows of Cthulhu mythos. There is so much flavor in Arkham Horror and so many references to the mythos so anyone who have read the works of H.P Lovecraft will instantly feel at home.
Secondly poeple who likes big and complicated board games so they can learn everything there is to know and build and test different strategies.
Lastly those who want to have game evenings with a few friends and just have a good time playing together.

Conclusion

Arkham Horror is an awesome game and just gets so much better with expansions. It is fun to play alone and even more fun with others and there's enough depth to delve into for countless hours.

That was Arkham Horror, thanks for reading and stay awesome!

Friday, September 12, 2014

An Analysis of Citadels

Two weeks ago we received an assignment to play and analyze a board game as a group, and our group chose to play Citadels with it's expansion The Dark City. Citadels is a bluffing card game where the players compete to try to build the greatest city, they do so by building districts in their city. In the end each player get points for how expensive their city is and can get additional points if they have met a few goals with building their districts. The player with the highest score win the game.

The game is played in rounds; each round all players, starting with the player who have the crown token, secretly selects a character to play as. Then, the characters are called out one by one and if a player have the character that is called, he takes his turn. When all characters have been called and each player have had their turn, the character cards are all shuffled back into the character deck and a new round starts. When a player plays his eight district card the game ends after that round.

There are four components in the game: character cards, district cards, gold tokens and the crown token.

District cards:
There are five different types of district cards: noble, trade, religious, military and special. Each building cost a certain amount of gold the player must pay during his turn to build it. The special buildings have unique special effects that mostly have something to do about gold, district cards or score, the other districts have no special effects but can be used by different characters to gain additional gold.

Gold tokens:
Gold is the main resource in the game and is gained in a few different ways. It's mostly used to build districts but can also be used to destroy them.

Crown token:
The oldest player start with the crown token, later during the game this will be passed on each time a player chooses to play with character number 4. The player with the crown token always choose which character to play with first, there are no other perks.

Character cards:
The important thing about Citadels is knowing what the different characters does, otherwise it is not neither a strategy nor a bluffing game. So the 8 normal cards are:
  1. Assassin: Names a character, that character may not take his turn this round.
  2. Thief: Names a character (not number 1). When the named character is called the thief takes all that players gold.
  3. Magician: May exchange his district cards (with another player or the district deck).
  4. King: Gains extra gold from noble buildings and gain the crown token.
  5. Bishop: Gains extra gold from religious buildings and gain protection from number 8.
  6. Merchant: Gains 1 extra gold and gains extra gold from trading buildings.
  7. Architect: Takes additional district cards and may build up to 3 district cards that turn (otherwise limited to one per turn).
  8. Warlord: Gains extra gold from military buildings and can pay to destroy other players districts.
The absolute most interesting system in Citadels is the character deck and how the players choose their character. At the beginning of each round all the characters are shuffled into the character deck, then one of them is discarded at random and placed face down so that no one can see which character it is. Then, depending on how many players there are in the game, a number of randomly selected characters are discarded and placed face up on the table for everyone to see (number 4 cannot be discarded this way). Now the player with the crown token get the character deck and selects one character he will play with this round, then passes the rest of the characters on to the next person who does the same. The last person will have two characters he can chose from, he takes one and place the other face down on the table.

When all the players have their character the player with the crown token call each character, starting from number one. When a player have the character that is called, he takes his turn. This is very important, it's not the player with the crown who takes his turn first, it's the player who chose the Assassin character.

Example 1
Here is an example where I have the crown and it's the first round of the game. The Bishop has been secretly discarded (I know this since I can see the other seven cards) and the Warlord and the Thief have both been discarded faced up for every one to see. First I take a look at my 4 district cards and see if I have something I can gain extra gold from and that I can afford to build. I see a trade building that cost 5 gold, so if I pick the merchant and take gold as my action I have enough to build it and gain 1 extra gold from the bank. This is a great first round. However, that mean the Assassin is open for the others and when the second pick see that the Bishop and the Merchant are gone it's pretty easy to know which card I took and then assassinate me causing me to lose my entire turn.

So I think differently, maybe I should take the Assassin and be safe from attacks. The Merchant is a strong card and someone will surely pick it, it's a safe card to assassinate. But I do not gain bonuses from that, sure I cannot be assassinated but I gain two less gold and can't build as good of a building as I could have as the Merchant.

In the end I pick the King since I already have the crown and do not want anyone else to have it. It's also a lower possibility of getting assassinated as it's not an obvious choice over the Bishop, and lastly I have a noble building costing 3 gold which mean I gain 1 additional gold that turn.

The second player then get the rest of the deck and see that the King and Bishop are gone. He decides to take the Assassin because he doesn't want to get assassinated and even though he has a 50% chance of assassinating me, he chooses to target the Merchant since it's a much stronger card.

Example 2
Another example where I'm the player next to the player with the crown. It's in the later stages of the game and I have no district cards in my hand but an awful lot of gold. When I get the character deck from the first player I see that the Assassin and the Warlord are both gone. The Thief is discarded faced up so I do not need to worry about him.

Since I have no district cards, there are two great characters for me, the Magician and the Architect. With the Magician I can take another players district cards and with all my gold I can play one of them. The problem is I am two districts away from having 8 districts in my city. With the Architect I can draw 3 district cards from the deck and build all three of them if I can afford it.

So the obvious choice is the Architect, but the Assassin is gone and I do not believe the first player would pick the Warlord and leave the Architect to me so I consider. He have four district cards in his hand so he might assassinate the Magician in fear of losing his cards, but is that a risk I'm willing to take?

In the end I chose the King since I know I wont get assassinated as him, I also want to be the player with the crown next turn so that I can take the Assassin and be out of harms way. Also I have 2 noble buildings which allows me to build what ever district card I take this and the next turn.

The positives

I've already talked in detail about the depth of choosing a character, and that is the best part of the game, but not the only good thing. The characters and their relation to the buildings is very well balanced in my opinion as there are way more trade districts than other districts making the Merchant gain more gold than the other characters even thou it doesn't say it on the card. There are equally many religious and military districts and only a few, and expansive, noble districts. The fact that there are few noble districts is good since the King is already powerful with him taking the crown token, if he gained as much gold as the others that would have ruined the balance in the game.

The special buildings are also balanced in that they do not yield gold like the other buildings do, but their special ability makes them a bit stronger. There aren't as many special districts as there are normal ones, and they aren't so strong that you automatically win if you only draw special district cards. They are just as strong as they need to be for a player to feel good when he draws one.

Another great thing is the expansion that adds 10 characters to the game. This adds two characters with the number 9 and eight characters with numbers from 1 to 8. These bonus characters can be exchanged for the normal characters with the same number at the start of the game. This adds even more depth generally since each game can be different depending on which character you exchange. There are strategies that certain characters counter and when they are exchanged suddenly you are free to execute them without fear.

The negatives

There are a few minor bad things about the game, the first is the down time. In character selection you wait for the other players to take their characters and you have little to nothing to do in game in the mean time. Then when it's each players turn you do want to pay attention, but you can't effect what is happening until it is your turn. This is the games biggest flaw according to me.

Another thing is the characters numbered 1, the Assassin and the Witch. The Assassin is a risk free choice and the player that is assassinated gets huge down time. The Witch however is a risk picking since you lose your building phase, the reward is greater if you successfully bewitch someone and they do not lose as much as they would have if you'd assassinate them. They get to take their action but you get to use their special ability and build. I believe this adds more to the game and I almost always play with the Witch instead of the Assassin.

There is a rule I do not like; "Before the game begins, players may agree to remove one or two of the original eight character cards and replace them with the bonus characters of the same rank numbers.". The fact that I almost always exchange the Assassin for the Witch mean I can only add one other bonus character, and I have had great games with 5 to 6 bonus characters. I've never intentionally followed this rule, and I probably never will.

Another rule, this one is just annoying; "Before the game begins, players may agree to add 2-3 additional purple district cards to the District Deck (...)", (purple is the special district). This merely annoys me since it means you have to go through the whole district deck every time you want to play, remove the bonus district cards and then add the new bonus district cards. If you add all the bonus district cards the chance to get special districts is too high, but this is usually what I do anyway since I can't be bothered to go through the whole deck before each game.

The last big-minor bad thing about this game is the fact that you believe you know what the characters does by reading on their cards, but in fact you have to read about them in the rule book since there are a few unexplained things there.

That's all for me, thanks for reading and stay awesome!

Thursday, March 20, 2014

Level Editor

Now when all of the features of our game is finally implemented we've been working hard on our levels. Our game is played on four floors where the first, top floor is the tutorial. After the tutorial the player is going down until he is on the first floor where the game end and he wins. The levels are loaded in from text files and those have become extremely hard to create since we have so much that needs to be loaded. Therefore I've been working on an editor to make level design much easier.

The main features of the editor are: Save and load to/from a file, place and remove objects from level. It seem simple, maybe it is, but I had to think a while before I started so that I made the easiest and fastest solution since we only had two week left before final. I also wanted it to be easy to add extra content to the editor so that I could send the new versions to our level designer and have him be able to load the levels he had already made and continue with the new features implemented.
   I first got the idea to have states, and that depending on which state was active you placed and removed different thing, and since it was such an good idea and worked, I didn't really think of a plan B. Instead of making a state_manager though I created a string called m_state and in the update and draw I had an if-statement for each state there was. Now I know this isn't good looking but I wanted a fast solution, not a good looking one!

I started with tiles and the first problem was: How should I select the tile I want? There was either a UI that showed all tile available where you could click to select which tile to place down next, or it was to cycle between all tiles with a keyboard button. Since all tiles are in one single sprite sheet I decided to do the first one. I drew the sprite sheet on the top middle of the screen and when the user clicked on it the editor found out which specific tile was clicked and set the current tile to that tile. When I clicked anywhere on the background a tile identical to the current tile was place there. I had some trouble with several tiles added on the exact same place but solved it by first going through all tile to see that there wasn't already a tile there. I also added so that the right mouse button removed the tile on the current mouse position.
   After the basics was finished I just added some tools to make things easier. The current tile was draw where the mouse was, the tile aligned them-self to the grid and a border was drawn around the current tile to be able see it clearer.
   When that was done I came to a little bit more difficult problem: How to save the map? The load map was easy since all I had to do was copy it from our main game and adjust it slightly, but the save was a little bit harder. All the tiles are stored in a vector instead of a two-dimensional array and thus I don't know which the most left, right, top and bottom tiles are. But after some thought I simply decided the go through the whole vector saving the lowest and highest of the x and y values in four variables. This also made it possible to not only work in a specific area but anywhere. If the top tile had a position of -512 it would have the position 0 in the saved file and all others would move down 512 pixels as well. To save them I had two for-loops with a third for-loop in them. The first two checked each position and the third went through each tile to see if it should be in that specific position and when a tile was found it was written to the file. If there where no tile there, simply write "9,9" to the file (when I wrote about the loading of levels I said "9,9" was chosen to represent an empty tile).

Finally I had the tiles finished, so I sent the version to our level designer and started working on the walls. The wall where a bit simpler in that they all have the exact same texture, but also harder since they had two points which had to create a perfect line. In the wall state update I made it so that the left mouse button set the starting point of the wall and the right mouse button created the end point. All I had to do was checking when an end point was placed to see if it had either the same x or the same y value as the starting point, but not both. For removing a wall shift had to be held down when right clicking and saving the walls was very simple since it didn't need to be saved in any order, just a loop with a single write to file line inside it.

After I had sent the new version away I started working on the props. These where like the tiles only I didn't have to align them in a grid, but I had to rotate them. No biggie and saved just like the walls.
   I fixed the vents after that, then the doors, player starting position, evidence and lastly the elevator. These last ones where really simple since I mostly copied from what I had written before. The only thing that is left are the enemies and their patrol pattern, which I wall do eventually. This editor have been great though! The time it have taken me to code has already been worth it since our level designer have had a super easy and fun time creating the levels. Now we are focusing on play testing and to create fun and difficult level for our game.

I don't have much more to add, thanks for reading and stay awesome!

Thursday, March 13, 2014

The Tutorial

The tutorial is a great tool to introduce the player to your game and this week I've been working on the tutorial for our game.

On the first attempt to create the tutorial I wanted to explain the basics of our game; How you move, shoot, pick up evidence and progress to the next level. The tutorial was also meant to serve another porpoise: Explaining why you are there. I did not want to have much text in the tutorial, mostly images and preferably everything should be intuitive, but I failed on my first attempt.
   Firstly I limited what the player could do before he had advanced to a specific part of the tutorial, which isn't bad except I did it with movement. On the play-test day almost everyone playing the tutorial got stuck right away, some asking "Can't you walk?". This was obviously really bad.
   Secondly I wasn't clear with what the player was meant to do. At the start you are standing in front of a man and there is an image saying: "Move the 'image of a mouse' to aim". Everyone tried to walk with the character, who was immobile until a later stage, instead of aiming at the boss. We had to tell almost everyone what they needed to do at this stage, and that wasn't very good either.
   When the player aimed at the boss another image replaced the old one saying: "Click 'image of left mouse button' to shoot". However, this was so similar to the previous image that some players completely missed it.
   After the player had killed the evil boss it was fine. "Move with 'wasd'" was everyone familiar with and "Press 'space' to pick up evidence" was straight forward as well as the arrow pointing at the elevator when the evidence was collected.

There is one big thing however I did correctly with the tutorial: I completed it in time to be play-tested. I gained a lot of valuable feedback and now know how to create a better one!

So I had to fix these errors and create an easier tutorial. The first thing that happens in the new tutorial is that the character walks out of the elevator into a room with no guards, there is no UI to see either. If the player doesn't move for the first five seconds the image pops up telling the player to walk with 'wasd'.
    The player then progresses out of the room and walks into a corridor with a guard guarding. First now the player will see a circle around him and an image saying simply: "'Ctrl' to sneak". If the player press ctrl while walking he will see the circle getting smaller and that he moves slower. If he stands still the circle disappears. It will be easy to walk past the guard and advance into the next room.
   In the next and final room there is the evil boss. When the character walks in, the boss will say: "Don't hurt me!" and the character replies: "You don't deserve to live.". The 'how to shoot' image will pop up and the bullets UI will show as well.
   When the player kills the evil boss the tutorial will remind the player that the bullets can't be replenished. Also an evidence spawn in the room and the evidence UI is shown as well as the 'how to pick up evidence' image.
   The last stage of the tutorial begin when the player picks up the evidence and an arrow appear pointing in the direction of the elevator. The guard the player walked past before now enters the room and the last tutorial message is displayed saying: "'Shift' to run". When the player run the circle around him will increase considerately but he will be a lot faster and thus outrunning the guard will be easy.

I believe these changes will create an better tutorial which is more intuitive and teaches the player  more things about our game. Still, there is a few weeks before the project should be finished so I have plenty time to play-test it and ask others to try as well.

That's all for me this time. Thanks for reading and stay awesome!

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!

Thursday, February 27, 2014

The almost finished player's field of view, finally

One of the most, if not the most important mechanics in our game is that the player have no vision behind walls. I've had the task of writing this code the past few weeks now, and I'm happy to say I've finally solved it. As you can imagine there have been a few problems along the way and I will explain everything here in detail.
Early mockup of the shadow system

Before I talk about anything else, I want to make this clear: what exactly was I supposed to do?
Shadow system the we decided not to use.
   In the early development of our game we discussed how exactly the lighting system should work. We talked about making the player just barely be able to see behind walls, that way the observant players wouldn't be surprised when walking around a corner and only to be shot by a guard. However this was voted against and instead we added a sneak system where if the player is sneaking he can see nearby sounds, like footsteps of patrolling guards.
   We also considered only giving vision in a cone in front of the player rather than everything around him, this was also down voted leaving me with a definite task: make everything behind walls pitch black (except for sounds when the player is in stealth).

For the prototype it was more emphasis on getting a working solution rather than a good solution, so I thought of the easiest solution I could find. At the time I worked in SDL and had only used the draw line method and nothing else, so my solution was this:
  • I have the player's position.
  • I take a pixel on the edge of the window and call it point.
  • I take a pixel and set its position to the player's position. I move it one pixel closer towards point until it hits a wall or arrives at point. When it hits a wall a line is drawn from its position to point.
If this doesn't sound too bad, let me explicate. When the player stands inside a wall this method compare values this many times: screen width * 2 + screen height * 2. For a window with the dimensions 1024x768 this is 3944 times it has to check for walls and draw lines. If there are no walls on a map this method runs a while loop around 450 times more times, almost 2 million times each update that is. This caused the game to run significantly slower even if there wasn't even one wall on a map that was 512x512 pixels in dimensions.

For the real thing I had to figure out a much better solution, so my first thought on the problem was to draw one black shape for each wall after everything else, except sound, had been drawn. Each shape would cover the area behind the wall from the player's position.This is a simple solution in theory but it has one big flaw, if I set an opacity on each wall making them see-through there would be darker areas where two walls cast their shadows. Back then we hadn't decided whether the player could see faintly behind walls or not so I had to think of another solution were overlapping walls didn't cause darker shadows.
   I came up with an idea that there was only one big shape that was drawn. It would be defined from taking all wall edge points and see if the current point is in front of the previous and the next, if so, then it should be included, otherwise it should be discarded. I didn't think to much on this since we decided quickly on having no vision behind walls.

Now it was time to get the shadows correctly.
  1. At first I created a shape with four points. The first two points were always the same, the start and end points of the wall. The third point, the point after wall end, was going to be the point on the edge of the screen which if a line was drawn between it and the player's position, it would go through the wall end. I called that point the edge end. The fourth and final point was the edge start which was similar to edge end except it went through the wall start instead.
  2. I realized quickly that this wasn't enough if the shadow hit a corner. At this point I thought a lot on two different possible solutions to this specific problem. The first one being to simply extend the two edge points beyond the screen thus creating a large quadrilateral. The second one was to find the corner and set another point there. I liked the second solution better since it was a neater solution and I believed it shouldn't be too hard.
  3. So I changed the shape to have five instead of four points. If the shadow didn't hit a corner, the now fourth point would have the same position as the third point, edge end. I moved the edge start to position five since the corner point had to be between the both edge points.
  4. I believed I was finished here but before I could program too much I realized that the shadow could hit two corners, so back to thinking again. I had already decided on this specific solution so not much was needed to change. I added one more point to the shape and moved the edge start to position six to let the second corner come between it and the first corner. Then I got to the programming bit.
In the wall constructor I set the shadow to have six points and a fill color of black. Then I set the first two points to wall start and wall end.
   In the update I set the remaining points depending on the player's position. I first calculate the two edge points, then I use those points to calculate the corners.

To get the point on the edge of the screen was fairly straight forward. I first calculated the unity vector from the player's position to the specified wall position. I took the unity vector and calculated how many steps it had to go to reach the edge of the screen in both x and y-axis. Then I multiplied the unity vector with the smaller distance of the x and y value. Lastly I returned the walls position plus the vector, which is the position of the point on the edge of the screen.
   For example: the player's position is x = 138 and y = 88. The wall position is x = 128 and y = 128. The unity vector from the player's position to the wall position is then: -0.24 in x-axis and 0.97 in y-axis. The distance to the edge of the screen in x-axis is 128 since it's moving in a negative direction and it's x position is 128, therefor it takes 128 / 0.24 which is approximately 533.33 steps to get to the end of the screen on the x-axis. The distance to the edge of the screen in y-axis is the window height, 768, minus the wall y position; 768 - 128 = 640. Therefor it takes 640 / 0.97 which is close to 659.79 steps to get to the end of the screen in y-axis. Since the unity vector hits the end of the screen on the x-axis first I multiply the unity vector with the number of steps it takes to get to the x-axis. This gives me the vector from the wall to the edge of the screen and so I just add the wall position to the vector and ta-da, I have the edge position!

To see if there is a corner between two positions was a little bit harder. First of all I had to have the player's position as well as the two points I wanted to check since I need to know which way I should look for a corner. Secondly I tested if there even was a possibility that there was a corner between the two points, if there weren't I just returned the first parameter (the position took look for corners from). Then I tested to see if the first parameter was a corner, if it was, the second corner had the same x or y value as both the points and the other value equal to the second point. If however the first point was not a corner I tested to see if there were two corners between the two points, if there were, then it found the first corner by taking the x or y value from the first point (whichever is 0 or the screen dimensions) and the other value is set to 0 or the screen dimension depending on the player's position. If the first point was not a corner and there was only one corner between the two points, the corner had the same x or y value as the first point which ever is a 0 or screen dimensions and the other value of the other point.

That worked fine, until we added a view port. . .

Bugged shadows
What happened when we added view port to our game was that no longer was the top left corner always at point 0, 0 nor the bottom right the width and height of the screen. Since both my methods EdgePoint and GetCorner calculated everything from 0, 0 to width, height; adding the view port made everything to bug completely except when in the top left corner of the game.
   It may sound simple to change this, I certainly thought it should have been. However after several hours of not understanding why my changes didn't work I started to doubt my code. I looked deeper into SFMLs View class and it worked just as expected so there was clearly something wrong in my code but I just couldn't see it. After a week I described the problem to my programming teacher Tommi who said I shouldn't make things so complicated. He advised me to draw huge shapes that went way outside of the screen instead.

Since I had already thought some on this idea it didn't take long until I knew exactly what I should do. It was basically exactly the same as getting the point on the edge of the screen except taking the longer distance instead of the shorter one.

In the end the code looked like this:
Define m_shadow in the constructor
Update the two changing points in m_shadow
The get point method

In the GetPoint class I set the maximum value on distance to 1 million, I do this because the value can be infinite if the player is on the same x or y position which results in the shadow not drawing at all.

That was all I think! If you made it all the way please leave a comment. Also thank you for reading and stay awesome!