Non-graphical Games Programming in C++Long Table of Contents
Chapter 1 Programming the DOS Console Window 1
Compiler Project Options 2
Basic Window Operations and Color 3
Advanced Console Window Techniques 4
An OOP Encapsulation of the DOS Console Window 13
Drawing Boxes On the Screen 28
Writing Client Programs That Use the Screen Class 30
Programming Problems 33
Chapter 2 Random Numbers and Dice 35
Class Random, Die, and Dice 35
Making Production Libraries 47
Using Die Rolls in a Game 51
Programming Problems 58
Chapter 3 Children’s Games: Controlling Game Sequencing 59
Programming Problems 76
Chapter 4 A Review of Linked Lists, Stacks, and Queues 78
Designing a void* Growable Array Class 79
Designing a template Growable Array Class 88
Designing the void* Double Linked List Class 96
Providing a Find Matching List Item Function: Call-back Functions 97
Handling the Insertions into the List 100
Deleting the Current Node 105
Adding a Debugging Feature 107
The Template DoubleLinkedList Class 120
Designing a void* Stack Class 131
Template Version of the Stack Class 137
The void* Queue Class 142
The Template Queue Class 147
Programming Problems 152
Chapter 5 Using the STL (Standard Template Library) 153
The Container Classes 154
The vector STL Class 156
Iterators 160
Details of the begin and end Functions 161
Using a Range of Iterators 162
The list Container 163
Algorithms 169
The deque Container 171
Chapter 6 Adventure Games, Dealing with Stories 175
The Adventure Game Initial Design Steps 175
The Mechanics 176
Make It Fun, But Keep It Moving 178
The Caverns or Rooms 179
The Objects 180
The Story Line 181
The Menu File 183
The Object Class 185
The Player Class 190
The Room Class 194
The Game Class 204
The Main Function 217
The Story Text 218
Problems 222
Chapter 7 Arcade Live Action Games 223
Creating a Real-time Keyboard Handler Class 224
Handling Time 229
The Ladder Game 230
The Classes for the Ladder Game 233
The Point Structure 234
The Level Class 235
The Object Class 238
The Barrel Class 241
The Player Class 249
The Game Class 263
Problems 271
Chapter 8 Card Games 272
The Card Class 273
The Deck Class 276
The Player Class 283
The Game Class 286
Programming Problems 297
Chapter 9 Trees 298
Introduction 298
Tree Notation 298
Binary Trees 301
Methods of Binary Tree Traversal 303
Inorder Traversal 303
The Preorder Traversal 304
The Postorder Traversal 304
The ~BinaryTree Function 304
Binary Search Trees 305
The Heap Tree 306
Building a Binary Search Tree 309
Determine the Height and the Number of Nodes in a Tree 311
Pgm09a The BinaryTree Class and Tester Program 312
Pgm09b The Account Inquiry Application
Loading a Binary Search Tree from a Sorted ISAM Index File 327
Multiple Projects in the Same Workspace 341
Programming Problems 342
Chapter 10 Variant Records 346
Unions: an Advanced Feature of Structures 346
Variant Records 348
Chapter 11 Choosing New Spells: a Conversation with the Archmage 367
Spell Encapsulation and Binary Files 369
Implementing ChooseSpellsDialog 383
The Spells Class 383
The SpellTree Class 389
The Simple Player Class 399
The ChooseSpellDialog Class 402
The Pgm11b main() Function 419
Programming Problems 420
Chapter 12 A War Game 421
The BattleField Class 421
The FilePicker Class 425
The main() Function 429
The Screen2 Modified Screen Class 430
The Many Counter Classes 436
The BasicInfo Class 437
BasicInfo.h 437
The Defense Class 441
Defense.h 441
Defense.cpp 442
The Mobility Class 444
Mobility.h 444
Mobility.cpp 444
The Damage Class 446
Damage.h 446
Damage.cpp 447
The UnitId Class 449
UnitId.h 449
UnitId.cpp 449
The Movement Class 451
Movement.h 451
Movement.cpp 452
The Guns Class 454
Guns.h 454
Guns.cpp 456
The VehicularMGs Class 461
VehicularMGs.h 461
VehicularMGs.cpp 462
The Base Classes Associated with a Counter 463
Countries.h 463
The Location Class 465
Location.h 465
Location.cpp 465
The Object Class 467
Object.h 467
Object.cpp 468
The GEObject Class 470
GEObject.h 470
AttackingStats.h 472
GEObject.cpp 473
The Many Derived Equipment Classes 477
GEClasses.h 477
The Infantry Class 478
The TowedGun Class 486
The TransportVehicle Class 488
The ArmedTransport Class 490
The ArmedHalftrack Class 494
The AAVehicle Class 495
The ArmoredCar Class 496
The FlameThrowerVehicle Class 497
The Tankette Class 500
The LightTank Class 501
The MediumTank Class 502
The HeavyTank Class 505
The InfantryTank Class 508
The SpecialTank Class 511
The TankDestroyer Class 513
The SelfPropelledArtillery Class 514
The SelfPropelledGun Class 517
Organization of File in a Large Project 518
The Game Class Definition 521
The Game.cpp File 527
The LineOfSight Class 546
LineOfSight.cpp 547
The Game Class Direct Fire Functions 556
GameDF.cpp 556
The Game Class Indirect Fire Functions 575
GameIF.cpp 575
The Game Class Movement Functions 583
GameMV.cpp 583
The Game Class Close Assault Functions 598
GameCA.cpp 598
Programming Problem 608