DEV Community

Discussion on: Please Reinvent The Wheel

Collapse
 
jvanbruegge profile image
Jan van Brügge

It's funny, because I was about to write this exact post myself. I am a self thought Programmer, with Java being my first language I learned when I was 14 years old.
About one year later, I decided that I want to write a Super Mario Game. I already wrote a few GUIs with Swing, so i just abused the Java GUI system to paint sprites on a pane. Point is, it worked. At this point I did not had any formal education or had read about patterns at all.
So I saw issues popping up. First one being: I have to write the same animation logic multiple times, why not put that somewhere else and just initialize it with the path of the image and a few settings? So I learned to seperate and reuse logic.
Then I wanted my GameObjects to be notified if certain events happen, but not every GameObject needs every event, so i wrote a Manager that you can subscribe to in your constructor if you implement a certain interface (the event handler). I just "invented" pub-sub or event driven programming without knowing it.
Then I thought that it is quite inconvenient to pass this manager per constructor all the time, as it limits where i can create GameObjects. So I thought if static variable are the same for all Objects, I should be able to have a static instance that is initialized only one. Later I read that this was called a singleton.
Reinventing stuff is the best way to learn not only concepts, but also deepen your programming knowlege in general.

Collapse
 
codemouse92 profile image
Jason C. McDonald

You may enjoy the book "Game Programming Patterns" by Robert Nystrom. Don't let the title fool you; these are the same patterns used in non-game programming, only presented from a game design angle to make them easier to visualize. He not only covers the what, why, and how, but also the when (as in, when NOT to use the design patterns).