|
|
xv | |
|
|
xvii | |
|
|
xix | |
Preface |
|
xxiii | |
Acknowledgments |
|
xxvii | |
Definition of Key Terms |
|
xxix | |
Abbreviation |
|
xxxi | |
Companion Website |
|
xxxiii | |
|
|
Introduction |
|
3 | (21) |
|
|
3 | (8) |
|
|
11 | (13) |
|
1.1.1 Design and Implementation |
|
|
14 | (2) |
|
|
16 | (2) |
|
|
18 | (1) |
|
|
18 | (6) |
|
Chapter 1 Computers, Programs, and Games |
|
|
24 | (19) |
|
|
21 | (1) |
|
1.1 BRIEF HISTORY OF COMPUTING |
|
|
22 | (4) |
|
1.1.1 Properties of Digital Media |
|
|
25 | (1) |
|
1.2 CIRCUITS AND NUMBERS, BITS, AND BYTES |
|
|
26 | (4) |
|
|
27 | (1) |
|
|
28 | (2) |
|
1.3 WHAT IS A PROGRAM, ANYWAY? |
|
|
30 | (3) |
|
|
31 | (2) |
|
1.4 GAMES AS PROGRAMS: DATA VS. CODE |
|
|
33 | (10) |
|
|
39 | (1) |
|
|
40 | (3) |
|
Chapter 2 Logical Creativity |
|
|
43 | (38) |
|
|
43 | (1) |
|
2.1 PROBLEM-SOLVING AND CREATIVITY |
|
|
44 | (4) |
|
2.2 VISUAL DESIGN AND VISUAL THINKING |
|
|
48 | (3) |
|
2.3 ALGORITHMS AND ALGORITHMIC THINKING |
|
|
51 | (15) |
|
2.3.1 What Is an Algorithm? |
|
|
51 | (5) |
|
|
56 | (1) |
|
|
57 | (1) |
|
2.3.3.1 Detecting Odd and Even Numbers |
|
|
58 | (1) |
|
|
59 | (5) |
|
2.3.5 Variables and the First Golden Rule of Programming |
|
|
64 | (1) |
|
2.3.6 Loop Counter as a Variable |
|
|
65 | (1) |
|
2.4 DATA-CENTERED APPROACH TO PROBLEM-SOLVING AND ALGORITHM DESIGN |
|
|
66 | (4) |
|
2.4.1 Finding Min and Max |
|
|
68 | (2) |
|
2.5 STEPWISE REFINEMENT FOR ALGORITHMS |
|
|
70 | (11) |
|
2.5.1 Restaurant Bill Calculation |
|
|
72 | (3) |
|
|
75 | (1) |
|
|
76 | (5) |
|
PART 2 Understanding Programs |
|
|
|
Chapter 3 Data: Program's Information |
|
|
81 | (36) |
|
|
81 | (1) |
|
3.1 HIGH-LEVEL PROGRAMMING LANGUAGES |
|
|
82 | (6) |
|
3.1.1 High Level vs. Low Level |
|
|
83 | (1) |
|
3.1.2 Declarative vs. Imperative |
|
|
83 | (1) |
|
3.1.3 Compiled vs. Interpreted |
|
|
84 | (1) |
|
|
84 | (2) |
|
3.1.5 Development Environments and Tools |
|
|
86 | (2) |
|
|
88 | (6) |
|
3.3 PROGRAMMING IN PYTHON |
|
|
94 | (5) |
|
3.4 PROGRAMMING IN C AND C++ |
|
|
99 | (8) |
|
3.4.1 Compiling and Running C/C++ Programs |
|
|
102 | (1) |
|
|
103 | (4) |
|
|
107 | (10) |
|
|
111 | (1) |
|
3.5.2 Integer and Float Operations |
|
|
112 | (2) |
|
|
114 | (1) |
|
|
115 | (2) |
|
Chapter 4 Code: Program's Operation |
|
|
117 | (30) |
|
|
117 | (1) |
|
4.1 SEQUENTIAL EXECUTION AND PROGRAM CONTROL |
|
|
118 | (4) |
|
|
118 | (1) |
|
4.1.2 Structured Programming and Control Flow |
|
|
119 | (1) |
|
|
119 | (1) |
|
|
120 | (1) |
|
|
120 | (1) |
|
4.1.2.4 Blocks of Code and the Lexical Scope |
|
|
121 | (1) |
|
|
122 | (7) |
|
|
122 | (3) |
|
|
125 | (4) |
|
|
129 | (7) |
|
|
129 | (4) |
|
|
133 | (1) |
|
|
134 | (2) |
|
4.4 COMBINING SELECTION AND ITERATION |
|
|
136 | (5) |
|
|
136 | (3) |
|
|
139 | (2) |
|
|
141 | (6) |
|
|
142 | (2) |
|
|
144 | (1) |
|
|
145 | (2) |
|
|
147 | (34) |
|
|
147 | (1) |
|
5.1 DEFINING AND USING FUNCTIONS |
|
|
148 | (6) |
|
5.1.1 Returning from a Function |
|
|
152 | (2) |
|
|
154 | (3) |
|
|
155 | (1) |
|
|
156 | (1) |
|
|
156 | (1) |
|
5.3 LOCAL AND GLOBAL VARIABLES |
|
|
157 | (6) |
|
|
163 | (18) |
|
5.4.1 Simple Board Game Simulator |
|
|
167 | (4) |
|
|
171 | (2) |
|
5.4.3 Prime Number Listing |
|
|
173 | (3) |
|
|
176 | (1) |
|
|
176 | (5) |
|
PART 3 Structured Programming |
|
|
|
Chapter 6 Types, Files, and Libraries |
|
|
181 | (56) |
|
|
181 | (1) |
|
|
182 | (18) |
|
6.1.1 Predefined and User-Defined Types |
|
|
182 | (1) |
|
|
183 | (3) |
|
|
186 | (5) |
|
6.1.2 Memory Address and Pointer Type |
|
|
191 | (6) |
|
6.1.3 Passing Parameters to Functions |
|
|
197 | (3) |
|
|
200 | (8) |
|
6.2.1 Multiple Source Files |
|
|
200 | (6) |
|
|
206 | (2) |
|
|
208 | (29) |
|
|
208 | (5) |
|
6.3.2 Graphics in Javascript |
|
|
213 | (4) |
|
|
217 | (2) |
|
|
219 | (4) |
|
6.3.5 Command-Line Parameters |
|
|
223 | (1) |
|
|
224 | (1) |
|
|
224 | (1) |
|
|
225 | (1) |
|
6.3.7.2 Game Code Structure |
|
|
225 | (3) |
|
|
228 | (5) |
|
|
233 | (1) |
|
|
234 | (3) |
|
Chapter 7 Modularization of Data |
|
|
237 | (68) |
|
|
237 | (1) |
|
7.1 USER-DEFINED TYPES AS MODULES OF DATA |
|
|
238 | (23) |
|
7.1.1 Collision Detection |
|
|
244 | (2) |
|
7.1.2 Vanishing Prize: How to Make Objects Disappear |
|
|
246 | (1) |
|
7.1.3 Simple Game in Javascript |
|
|
247 | (5) |
|
|
252 | (2) |
|
7.1.5 Distance and Collision |
|
|
254 | (1) |
|
7.1.6 Lives and Scores in Python |
|
|
254 | (6) |
|
7.1.7 Movements and Collision |
|
|
260 | (1) |
|
|
261 | (1) |
|
7.2 ARRAYS AS MODULES OF DATA |
|
|
261 | (7) |
|
|
261 | (6) |
|
7.2.2 Arrays in Javascript and Python |
|
|
267 | (1) |
|
7.3 EXAMPLES OF USING ARRAYS |
|
|
268 | (17) |
|
|
268 | (5) |
|
7.3.2 Ground Levels in Games |
|
|
273 | (2) |
|
|
275 | (2) |
|
7.3.4 Scaling and Translation |
|
|
277 | (6) |
|
|
283 | (2) |
|
7.4 COMBINED DATA MODULES |
|
|
285 | (20) |
|
|
285 | (6) |
|
7.4.2 2D Game with Arrays |
|
|
291 | (7) |
|
|
298 | (3) |
|
7.4.4 Transparent Pixels and Background Image |
|
|
301 | (1) |
|
|
302 | (1) |
|
|
303 | (2) |
|
Chapter 8 Modularization of Code |
|
|
305 | (64) |
|
|
305 | (1) |
|
|
306 | (10) |
|
8.1.1 Using Functions to Build Modular Programs |
|
|
307 | (4) |
|
8.1.2 A Modular Command Processor |
|
|
311 | (2) |
|
8.1.3 What Is a Good Function? |
|
|
313 | (3) |
|
8.2 INFORMATION HIDING AND ABSTRACTION |
|
|
316 | (4) |
|
|
320 | (20) |
|
|
320 | (11) |
|
|
331 | (9) |
|
8.4 A MODULAR GAME PROGRAM |
|
|
340 | (29) |
|
8.4.1 2D Side-Scroller Game |
|
|
341 | (1) |
|
|
342 | (1) |
|
|
343 | (6) |
|
8.4.4 Physics: Platforms, Jumping, and Falling |
|
|
349 | (1) |
|
|
350 | (1) |
|
|
350 | (1) |
|
|
351 | (11) |
|
8.4.8 Timers and Callback Functions |
|
|
362 | (2) |
|
|
364 | (1) |
|
|
364 | (5) |
|
PART 4 Object-Oriented Programming |
|
|
|
Chapter 9 Modularization of Data and Code |
|
|
369 | (164) |
|
|
369 | (1) |
|
|
370 | (19) |
|
9.1.1 Abstract Data Types |
|
|
370 | (3) |
|
|
373 | (3) |
|
|
376 | (6) |
|
|
382 | (3) |
|
9.1.5 Python and Javascript Classes |
|
|
385 | (4) |
|
9.2 OBJECT-ORIENTED PROGRAMMING |
|
|
389 | (131) |
|
9.2.1 Identifying Classes and Objects |
|
|
391 | (2) |
|
|
393 | (117) |
|
12.2.3 Sample Image Effects |
|
|
510 | (3) |
|
|
513 | (4) |
|
12.2.5 Rendering with Effects |
|
|
517 | (1) |
|
12.2.6 Using Dynamic Polymorphism in Render Class |
|
|
518 | (1) |
|
12.2.7 Polymorphism in Python and Javascript |
|
|
519 | (1) |
|
12.3 PHYSICS CLASS REVISITED |
|
|
520 | (13) |
|
|
522 | (4) |
|
|
526 | (1) |
|
|
527 | (1) |
|
|
528 | (5) |
|
|
|
Chapter 13 Software Design |
|
|
533 | (10) |
|
|
533 | (1) |
|
|
534 | (2) |
|
|
536 | (2) |
|
13.3 SOFTWARE ARCHITECTURE |
|
|
538 | (2) |
|
|
540 | (3) |
|
|
540 | (1) |
|
|
541 | (2) |
|
Chapter 14 Software Projects |
|
|
543 | (4) |
|
|
543 | (1) |
|
|
544 | (1) |
|
|
545 | (2) |
|
Chapter 15 Concluding Notes |
|
|
547 | (4) |
|
|
547 | (1) |
|
15.1 SUMMARY OF KEY POINTS |
|
|
547 | (1) |
|
15.2 SOME PRACTICAL ADVICE |
|
|
548 | (3) |
Bibliography |
|
551 | (2) |
Index |
|
553 | |