September 2010
Beginner
384 pages
8h 49m
English
A common programmer mantra is "duplication is evil." The idea is that any time you type the same thing twice, you could be wasting time and effort. Remember that the less typing we do, the less likely we are to drop dead from the programmer illness I totally fabricated.
Notice that we have some duplication in this line:
transform.position.x = Input.mousePosition.x Screen.width/2)/ (Screen.width/2);
We've typed Screen.width/2 twice. That won't do! For starters, typing makes my hands tired. What's more, we're forcing the computer to do that complicated math calculation twice. Why not do the calculation once and ask the computer to remember the result? Then, any time we want to talk about the screen's midpoint, we can ask the ...
Read now
Unlock full access