Making Classes
Today I went to my internship and I worked on making classes for my code. A class is essentially for cleaning up your code. It stores a bunch of information in that class which can later be called in the main code. I started reading about this, and I found some text that seemed very complicated. To my surprise, making a class wasn't as complicated as I thought, although implementing a class into my code is a whole different story.
I made a bunch of classes while I was at my internship. The class I worked on first was for movement. So all of the variables assigned to the keys so that the little guy can walk. There was also a class for the character itself. Another class was made for the bird. The bird in the code posed as an obstacle for my character. When my character came into contact with the bird, he would stop. I also made a class for the crash. This had my huge if statement saying that "if the man (the makeshift square) came into contact with the bird (the other makeshift square), then stop() + console.("Crashed into the bird"). The final class that I made was for the sky. The sky was there to add a background which I thought was very necessary.
Once I finished making all of these classes, I tried to put it into my larger code, but it didn't work. Since it was almost time to go, I decided to save this part of my project until next week.
I made a bunch of classes while I was at my internship. The class I worked on first was for movement. So all of the variables assigned to the keys so that the little guy can walk. There was also a class for the character itself. Another class was made for the bird. The bird in the code posed as an obstacle for my character. When my character came into contact with the bird, he would stop. I also made a class for the crash. This had my huge if statement saying that "if the man (the makeshift square) came into contact with the bird (the other makeshift square), then stop() + console.("Crashed into the bird"). The final class that I made was for the sky. The sky was there to add a background which I thought was very necessary.
Once I finished making all of these classes, I tried to put it into my larger code, but it didn't work. Since it was almost time to go, I decided to save this part of my project until next week.
Comments
Post a Comment