Foundation Game Design with ActionScript 3.0, Second Edition

Free Foundation Game Design with ActionScript 3.0, Second Edition by Rex van der Spuy Page A

Book: Foundation Game Design with ActionScript 3.0, Second Edition by Rex van der Spuy Read Free Book Online
Authors: Rex van der Spuy
successive generation of the Flash Player to improve performance, but this is a major handicap for game developers who depend on squeezing every iota of processing power out of a system to maximize performance in their games. This is why 3D Flash games, which require a vast amount of processing power to calculate geometry, struggle to compete with the rich graphic splendor of 3D on the game consoles (such as the Xbox, PlayStation, and Wii.) The consoles use custom compilers that optimize all the game code to run directly as machine language on their specific processors.
    If you're thinking of eventually getting into game design for consoles, however, you're still in pretty good shape with Flash: the skills you'll learn by programming in AS3.0 can be directly applied to programming for consoles when you're ready to take that step. The AS3.0 programming environment is also probably the most user-friendly programming environment you can learn in. And, hey, make a game with Flash, post it on the Web, and you've got a potential worldwide audience for it—that's power!
Naming conventions
    Before this chapter closes, let's take a quick look at an aspect of programming practice called naming conventions . You might have noticed something peculiar about the kinds of names that you gave the file, class, and method names. Look at the choice of file name for the AS file:
    HelloWorld
    Does it look a little strange to you? It should. You'll notice that the H and W are uppercase, and there's no space between the two words. This is a style of giving things names that programmers affectionately call camel case (also known as humpBackNotation ). Can you guess why it's called that? I'm sure you can!
    With camel case, you can write a compound phrase using more than one word. The words are not separated with blank spaces, and the phrase is still easily readable by you and by AS3.0. Blank spaces in the middle of compound names are the programming equivalent to foxes in a chicken coop—avoid them at all cost! The AS3.0 code compiler throws its hands in the air when it encounters a blank space where there shouldn't be one, so camel case was developed by programmers as an efficient way of writing compound words or phrases without spaces. You should also avoid blank spaces in any of your folder names, because if you're using an IDE other than Flash Builder, the underlying Flex SDK that compiles your code can't process paths to files that include spaces.
    Camel case is an important feature of naming conventions, which are rules that programmers decide on before they start a project about the style they'll use for creating package, variable, class, object, method, and file names. By strictly sticking to these naming conventions, programmers are better able to dodge the easy-to-make errors that come from misspelling or incorrectly capitalizing any elements in their code. They can also easily see what kind of programming object they're dealing with simply by the way it's been capitalized.
    There are two types of camel case that you'll be using throughout this book.
Lower camel case : startsWithLowerCaseLetter. You'll be using this case for package names, variables, methods, and instances.
Upper camel case : StartsWithUpperCaseLetter. You'll use this case for class names and constructor method names. You'll also use it for the names of AS class files such as HelloWorld.as and Main.as, which must be named exactly like the class they define in the file.
    Because ActionScript is a case sensitive programming language, keep in mind that helloWorld is different from HelloWorld, which is different still from helloworld. Make sure that you follow all the capitalization as it appears in the text; otherwise, your programs won't work. If you write a program that seems perfect in every way but just doesn't run, check your spelling and capitalization! This is one of the most common mistakes that novice programmers make, and many a programmer will tell you tales of woe

Similar Books

Tortoise Soup

Jessica Speart

Old Filth

Jane Gardam

Fragile Hearts

Colleen Clay

The Neon Rain

James Lee Burke

Galatea

James M. Cain

Love Match

Regina Carlysle

Murder Follows Money

Lora Roberts