B R I E F CO N T E N T S Acknowledgments xix Introduction xxi Chapter 1 The Interactive Shell 1 Chapter 2 Writing Programs 11 Chapter 3 Guess the Number 21 Chapter 4 A Joke-Telling Program 39 Chapter 5 Dragon Realm 45 Chapter 6 Using the Debugger 63 Chapter 7 Designing Hangman with Flowcharts 77 Chapter 8 Writing the Hangman Code 87 Chapter 9 Extending Hangman 111 Chapter 10 Tic-Tac-Toe 121 Chapter 11 The Bagels Deduction Game 149 Chapter 12 The Cartesian Coordinate System 163 Chapter 13 Sonar Treasure Hunt 171 Chapter 14 Caesar Cipher 197 Chapter 15 The Reversegam Game 209 Chapter 16 Reversegam AI Simulation 239 Chapter 17 Creating Graphics 255 Chapter 18 Animating Graphics 273 Chapter 19 Collision Detection 285
Chapter 20 Using Sounds and Images 301 Chapter 21 A Dodger Game with Sounds and Images 311 Index 335 viii Brief Contents
ACKNOWLEDGMENTS This book would not have been possible without the exceptional work of the No Starch Press team Thanks to my publisher Bill Pollock thanks to my editors Laurel Chun Jan Cash and Tyler Ortman for their incredible help throughout the process thanks to my technical editor Ari Lacenski for her thorough review and thanks to Josh Ellingson for yet another great cover
INTRODUCTION When I first played video games as a kid I was hooked But I didn’t just want to play video games I wanted to make them I found a book like this one that taught me how to write my first programs and games It was fun and easy The first games I made were like the ones in this book They weren’t as fancy as the Nintendo games my parents bought for me but they were games I had made myself Now as an adult I still have fun programming and I get paid for it But even if you don’t want to become a computer programmer programming is a useful and fun skill to have It trains your brain to think logically make plans and reconsider your ideas whenever you find mistakes in your code