< Previous | Contents | Next >

Types, Variables, and Standard I/O: Lost Fortune


Game programming is demanding. It pushes both programmer and hardware to their limits. But it can also be extremely satisfying. In this chapter, youll be introduced to the fundamentals of Cþþ, the standard language for AAA game titles. Specifically, youll learn to:

n Display output in a console window

n Perform arithmetic computations

n Use variables to store, manipulate, and retrieve data

n Get user input

n Work with constants and enumerations

n Work with strings


 

Introducing CþþUsing Cþþ for GamesCreating an Executable FileDealing with ErrorsUnderstanding the ISO StandardWriting Your First Cþþ ProgramIntroducing the Game Over ProgramCommenting CodeUsing WhitespaceIncluding Other FilesDefining the main() FunctionDisplaying Text through the Standard OutputTerminating StatementsReturning a Value from main()Working with the std NamespaceIntroducing the Game Over 2.0 ProgramEmploying a using DirectiveIntroducing the Game Over 3.0 ProgramEmploying using DeclarationsUnderstanding When to Employ usingUsing Arithmetic OperatorsIntroducing the Expensive Calculator ProgramAdding, Subtracting, and MultiplyingUnderstanding Integer and Floating Point DivisionUsing the Modulus OperatorUnderstanding Order of OperationsDeclaring and Initializing VariablesIntroducing the Game Stats ProgramUnderstanding Fundamental TypesUnderstanding Type ModifiersDeclaring VariablesNaming VariablesAssigning Values to VariablesInitializing VariablesDisplaying Variable ValuesGetting User InputDefining New Names for TypesUnderstanding Which Types to UsePerforming Arithmetic Operations with VariablesIntroducing the Game Stats 2.0 ProgramAltering the Value of a VariableUsing Combined Assignment OperatorsUsing Increment and Decrement OperatorsDealing with Integer Wrap AroundWorking with ConstantsIntroducing the Game Stats 3.0 ProgramUsing ConstantsUsing EnumerationsIntroducing Lost FortuneSetting Up the ProgramGetting Information from the PlayerTelling the StorySummaryQuestions and AnswersDiscussion QuestionsExercises