It was niggling at me, bit by bit, every time I went to Microsoft's api for XNA it kept saying version 4 and I knew I was on version 3.1, I kept putting it off like one of those awkward conversations, until I decided to take the plunge.
Taking the appropriate steps, like crossing my fingers, making a backup and praying to the Tetris God I dove in head first.
It went quite painlessly to be honest, there was one minor change in one of the spritebatch methods (the method's that display 2D sprites on screen, apparently additive alpha channels were gone and it is now multiplicative), half an hour got the code working again.
But that wasn't all I wanted to upgrade, I was also interested in perfecting the lighting algorithm before I got on to anything serious like AI as it will also be acting as my line of sight algorithm, looking through the various algorithms on roguebasin. I decided to go for Restrictive Precise Angle Shadowcasting because it claimed to produce no artifacts(glitches), was fast and I actually understood what it was trying to do, so debugging my code would be easier.
It sounded very simple, you work out each eighth of a circle seperately, you assign the cells angles by dividing 1 by the number of cells in the row and assigning start mid and end angles, if the square is a blocking square ie a wall, you say that all cells after that have angles between the and blah blah blah, click the link if you want to see the details.
After implementing it, I seemed to be getting artifacts, so I studied the code of the guy who has actually implemented it and it seems he omitted to mention that you need to check if the cells in the previous row were blocked. So a few typos in my code and many hours later, I ended up with a fully functioning lighting system.
Still on the horizon, monster AI and time/combat system.
No comments:
Post a Comment