O'Reilly logo

Beginning Math and Physics for Game Programmers by Wendy Stahler

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The Point Defined

In the world of game programming, you will deal with many different types of functions. In general, a function is a rule that takes in information (input) and returns new information (output). In programming, you can write functions that take in various types of input, such as variables, text, or numbers, and return a different type of information or even perform an action as output. In a well-written program, you should compartmentalize repeatable tasks in functions so that the code is kept simple and clean. Let's take a look at an example of a well-commented and useful function:

 // purpose: determine whether a number is a power of 2 // input: the number being checked // output: true if it's a power of 2, else false bool powOfTwo(int ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required