Game Development Reference
In-Depth Information
chapter 8
Game Math
Games can be written without a lot of advanced math knowledge, but the more
graphically advanced the game, the more math you'll need to know. There are
many fields of mathematics; some are more commonly used than others when
writing a game. Geometry is important to describe 3D and 2D worlds. Matrices
and vectors are useful for describing worlds and the relationships between enti-
ties in these worlds. Trigonometric functions are great for special effects and
making things act organically. Tween functions are a handy way to express
movement over a constant time. The more math you know, the more tools you
have to solve any problems that come up when programming games.
Trigonometric Functions
The trigonometric functions sine and cosine are often used in game program-
ming. Applying sine and cosine to some number will return a value from 1to1.
These returned values make up a wave form, a smoothly oscillating curve. This
curve is of great use when moving something up and down smoothly—creating
an organic pulsing color, smooth oscillating scaling, and many other game-like
effects.
Plotting a Graph
The best way to get a feel for the uses of cosine and sine is to create a sandbox
program where you can play with the values. A good starting point is a program
that plots the sine and cosine waves on a graph. Here's a game state that will draw
 
 
 
Search WWH ::




Custom Search