Light Beam
|
Hello and welcome!
This week i have worked on a lot of bug and small artifacts like like fixing lights or implementing menu screens, end screens and screen shake so instead i will write about the light beam I created. I began by making a class and since we don’t have a sprite manager I set the texture and sprite inside our constructor as well as the position and origin. Now I made an update function to change color at random and update the hit box. My group wanted a light beam as a Power up that we should shoot because we wanted a powerful weapon to take down many enemies in a row. This simple light beam we wanted as a laser, all light beams are faster than the eye can see and to do this i first started to expand it by increasing it’s size but as i realized this was just unnecessary since my laser would never be seen increasing. So I just set it long enough to reach outside of the screen since it never ended when it collided with enemies or walls because of how short there was to the beta. But this ended with a problem since we are using rectangle collision and the SFML function float rectangle to create the hit box and by using its own intersect function to see if it collides with other objects using the float rectangle function. But now the real problem occurred where the hit box won’t rotate when I shoot the laser in a y axis which expanded the hit box to cover everything on the y axis. So to fix my problem with the laser hit box I had help from a friend named Malcolm who told me to try using a ray march which is a method. Using this method where you will spawn one sprite and if it does not collide it creates one more. To do this I used a while loop to create new light beam sprite until It would collide with our screens edges then stop spawning and then I choose to just remove it next update so it wouldn’t be everywhere on the screen. This did not solve my problem with the to big hit boxes completely but It improved it since now the light beam hit boxes was much smaller. Another way to fix this would be to use separate axis theorem which I will not have enough time to learn about and implement until the final.
|
