Creating a camera class Camera class (not a 100% done)
|
Coding a camera class at first was one of the hardest thing in my head because I was thinking the wrong way. I choose to tell you about this simple (yet made harder by my brain) class because I learned something from it. When you are working with more than one person you can have a hard time creating a class when you don’t understand what the person you are working with are thinking. So what you have to do is communicate. Well that might be a final step. So dividing it up in steps is the easiest way to tell you how I did when I worked on this class. At first instead of talking with my programming master ( I will give him that title since I feel he is that much better than me at what we are doing right now) I tried to look at his code alone and see how he did to make a sprite and ended up wasting my time with that instead of just getting the job done. After that I went right up at the rotation of the camera, thinking in the wrong way I just failed over and over with codes that really did not make any sense. Then after several trials and error I stood up from my computer and remembered one of the guest lectures I attended. ”Most people find it easier to scribble on a piece of paper in order to get things straight” And guess what that is what I did. Then All that was left was divide and conquer. What do I need to make the camera class work? Start with the easy and work yourself up. First we need a sprite and after that we need to make it look at a angle specific angle. After that we need it to have a starting angle, after making a float variable we can get a pretty good angle after that we make a max variable and a min variable. Using those we can get the camera to rotate the way we want to using simple math like start – min and start + max. The part I did not make was the part where you get the value. When you think about it you probably want a lot of cameras and them watching in different directions? So we need something that can give us those values. Using Tile a program that creates a map in a easier way we can get a picture and set a starting max and min value. Then the class is done simple as that. Getting there at first though was a burden so my suggestion is get a piece of paper and break the class down in small simple steps and then go go go make errors make mistakes and then try again and again and again until you succeed. Since other work from former classes are not done yet I never completely finished the class so a screenshot of the shot is not included also since we need the class to detect something we need a detection class or something else that is not done yet. When that is done the class will be finished. Have a great day from here on and hope you liked my first own programming blog post. |
