It’s the catchphrase that many students hate seeing on the course description for their introductory Computer Science course: “Recommended for strong math students only.” That one single line is the source of many headaches for countless young students expressing an interest in computer science, but not necessary math. There are many questions about the relevance of mathematics to their programming courses.
Today, I hope to show you just exactly what is so important about math to high school students in their computer science class. A common scenario is interest in video games, but with lack of strong math skills. For that reason, I am going to discuss game development in this post, but be on the lookout for a future, second part to this.
Thinking at a high school level, a basic game really doesn’t involve all that much math. That’s all well and good, but when you think about higher difficulty games, there is usually a lot more math involved. In fact, let’s look at a simple side-scrolling Mario clone. In this list, we’re just listing mathematical components to a single mechanic of the game — jumping onto an enemy:
That may not seem like much, however, after a while the task can seem quite daunting and becomes a very involved project. This list will mean you will have to keep track of your player’s velocity, and his acceleration (positive, negative, or zero) both horizontally and vertically. While you’re doing that, you’ll also have to keep track of your coordinate system to check on your player positions and if they’re colliding or not. To cap it all off, most sidescrollers usually incorporate some sort of scoring system with an exponential function representing growth for consecutive hits. While each thing is small within itself, combined, these can pile up quickly.
Now let’s move into 3D. Adding a third dimension to your game ups the ante exponentially. You have to account for a focal point, which vertices should be showing, shading and lighting, texturing, etc. All of this is math. It goes back to your simple transformations to a function on a graph, except applied to a 3D model instead. Also, when you get into rotation, you have to know how to multiply matrices, otherwise, it’s quite impossible to get a nice smooth looking animation, that still looks proper.
While I haven’t covered computer science per se, but I have hopefully shed some light on why math is important for the applications that many high school students choose to write — games. As a last note, if you only take one thing out of reading this article, think about things this way: if you really want to be involved with game development through coding, whether it be the actual game engine, or physics engine, etc. don’t look at the math aspect as a reason to give up, but rather, a challenge. Don’t be afraid to get something wrong and have to try until you get it right. It’s much better off to get something right on the 5th try by re-analyzing the problem, than getting it right the 1st try by sheer dumb luck.