Yesterdays bugged FoV |
Unbugged FoV |
- SetPosition and GetPosition are not needed anymore since everything is done in the class instead.
- The VertexArray that drew the line was not needed anymore since I added the ConvexShape (polygon) to the wall class instead.
- I moved the code from the Run method in the Engine class to the Update method in the Wall class. I do not want too much code in my Engine, so this was obvious.
- The PointOnWall method take two Vector2f parameters and calculate where on the edge of the screen a line, from the first position tangent to the other position, hit and then returns the position.
- The CheckCorner takes three Vector2f parameters, and return the position of the first corner between the two first position. The third position is the player's and is used for checking what way to look for corners. If there are no corners between the two lines it simply returns the first parameter.
PointOnWall creates a Vector2f vector that is set to the unit vector between the two positions given. It then calculates how many steps are needed to get to the closest wall in both directions. The fewest amount of steps needed is then multiplied to the unit vector which creates a position on the edge of the screen which is returned.
CheckCorner is a bit more complicated. First it checks if there are of corners between the two given positions. If there is none, it simply return the first position. Otherwise it checks the first position to see if it is a corner. If it is, it checks the other position for and x or y value that is not 0, width or height of the screen. That value is replaced by the corresponding variable from the first position and the position of the corner is returned.
If however the first position is not a corner the program checks if there are two corners between the two given positions. If there are, it checks the value from the first position that is not 0, width or height of the screen and then the player's position to see if it's going to look up or down for the next corner. It then returns the position of the corner.
Finished FoV |
So, that's something. . .
If you read all this, you're awesome and thank you so much!
It's me again!
ReplyDeleteThe way you troubleshoot your issues are missing in this post in my opinion, I can't really see what went through your thought process when you figured you should have narrowed the class down to one construct and what steps you took to slim down the iterations.
The things I see though is:
*your marvelous approach to the issue you had at hand.
*your solutions are explained thoroughly
*your descriptions on anything you mention are detailed and short(still!)
I simply want to know if you made some mistakes a long the way while you found your solutions I guess but these posts are great and not long!