Game Development Reference
Use comments wisely and as you see fit. It is quite legitimate to write an entire
program without comments; however, be warned, when you come back to
code several months later you'll be glad you did.
A function is a block that bundles a number of lines of code together to
form a specific operation. It contains prewritten code that can be reused
over and over again, saving programmers the stress of reinventing the
wheel each time they write a program. Programmers can also write their
Whenever the author thinks of functions, she visualizes them as food
processing machines. You put vegetables in, they get processed,
and you get chopped, mashed, or minced vegetables out.
The most common newbie function taught is print() or a derivative thereof.
This function takes input and prints it to the screen. For example,
on the screen or console.
Functions available to you as a programmer will depend on the programming
embedded into the HTML of a webpage,
will display the text on the webpage when viewed inside a browser.
Listing 1.8 .
Listing 1.8 Code Syntax for an Empty Function
function myFunctionName(input list)
A function declaration begins with the keyword function, followed by its name
and then a list of input values.
While functions are a programming element usually introduced to new
programmers further down the track, they are fundamental to writing