- Page 4:
This page intentionally left blank
- Page 8:
© 2004 by Thomson Course Technolog
- Page 12:
AcknowledgmentsAbook of this size i
- Page 16:
Contents at a GlanceIntroduction .
- Page 20:
ContentsIntroduction . . . . . . .
- Page 24:
xiiContentsChapter 4 Writing Your F
- Page 28:
xivContentsStory . . . . . . . . .
- Page 32:
xviContentsChapter 10 Programming T
- Page 36:
xviiiContentsSummary . . . . . . .
- Page 40:
xxContentsChapter 18 Introduction t
- Page 44:
xxiiContentsChapter 5 . . . . . . .
- Page 48:
This page intentionally left blank
- Page 52:
xxviIntroductionCross-Platform Game
- Page 56:
xxviiiIntroductionsource code. When
- Page 60:
xxxIntroduction■■■Part II: 2D
- Page 64:
Welcome to Part I of Game Programmi
- Page 68:
4Chapter 1 ■Demystifying Game Dev
- Page 72:
6Chapter 1 ■Demystifying Game Dev
- Page 76:
8Chapter 1 ■Demystifying Game Dev
- Page 80:
10Chapter 1 ■Demystifying Game De
- Page 84:
12Chapter 1 ■Demystifying Game De
- Page 88:
14Chapter 1 ■Demystifying Game De
- Page 92:
16Chapter 1 ■Demystifying Game De
- Page 96:
18Chapter 1 ■Demystifying Game De
- Page 100:
20Chapter 1 ■Demystifying Game De
- Page 104:
22Chapter 1 ■Demystifying Game De
- Page 108:
24Chapter 1 ■Demystifying Game De
- Page 112:
26Chapter 1 ■Demystifying Game De
- Page 116:
28Chapter 1 ■Demystifying Game De
- Page 120:
30Chapter 1 ■Demystifying Game De
- Page 124:
32Chapter 1 ■Demystifying Game De
- Page 128:
34Chapter 2 ■Getting Started with
- Page 132:
36Chapter 2 ■Getting Started with
- Page 136:
38Chapter 2 ■Getting Started with
- Page 140:
40Chapter 2 ■Getting Started with
- Page 144:
42Chapter 2 ■Getting Started with
- Page 148:
44Chapter 2 ■Getting Started with
- Page 152:
46Chapter 2 ■Getting Started with
- Page 156:
48Chapter 2 ■Getting Started with
- Page 160:
50Chapter 2 ■Getting Started with
- Page 164:
52Chapter 2 ■Getting Started with
- Page 168:
54Chapter 2 ■Getting Started with
- Page 172:
56Chapter 2 ■Getting Started with
- Page 176:
58Chapter 2 ■Getting Started with
- Page 180:
60Chapter 2 ■Getting Started with
- Page 184:
62Chapter 2 ■Getting Started with
- Page 188:
64Chapter 2 ■Getting Started with
- Page 192:
66Chapter 2 ■Getting Started with
- Page 196:
68Chapter 2 ■Getting Started with
- Page 200:
This page intentionally left blank
- Page 204:
72Chapter 3 ■Basic 2D Graphics Pr
- Page 208:
74Chapter 3 ■Basic 2D Graphics Pr
- Page 212:
76Chapter 3 ■Basic 2D Graphics Pr
- Page 216:
78Chapter 3 ■Basic 2D Graphics Pr
- Page 220:
80Chapter 3 ■Basic 2D Graphics Pr
- Page 224:
82Chapter 3 ■Basic 2D Graphics Pr
- Page 228:
84Chapter 3 ■Basic 2D Graphics Pr
- Page 232:
86Chapter 3 ■Basic 2D Graphics Pr
- Page 236:
88Chapter 3 ■Basic 2D Graphics Pr
- Page 240:
90Chapter 3 ■Basic 2D Graphics Pr
- Page 244:
92Chapter 3 ■Basic 2D Graphics Pr
- Page 248:
94Chapter 3 ■Basic 2D Graphics Pr
- Page 252:
96Chapter 3 ■Basic 2D Graphics Pr
- Page 256:
98Chapter 3 ■Basic 2D Graphics Pr
- Page 260:
100Chapter 3 ■Basic 2D Graphics P
- Page 264:
102Chapter 3 ■Basic 2D Graphics P
- Page 268:
104Chapter 3 ■Basic 2D Graphics P
- Page 272:
106Chapter 3 ■Basic 2D Graphics P
- Page 276:
108Chapter 3 ■Basic 2D Graphics P
- Page 280:
110Chapter 3 ■Basic 2D Graphics P
- Page 284:
112Chapter 3 ■Basic 2D Graphics P
- Page 288:
114Chapter 3 ■Basic 2D Graphics P
- Page 292:
116Chapter 3 ■Basic 2D Graphics P
- Page 296:
This page intentionally left blank
- Page 300:
120Chapter 4 ■Writing Your First
- Page 304:
122Chapter 4 ■Writing Your First
- Page 308:
124Chapter 4 ■Writing Your First
- Page 312:
126Chapter 4 ■Writing Your First
- Page 316:
128Chapter 4 ■Writing Your First
- Page 320:
130Chapter 4 ■Writing Your First
- Page 324:
132Chapter 4 ■Writing Your First
- Page 328:
134Chapter 4 ■Writing Your First
- Page 332:
136Chapter 4 ■Writing Your First
- Page 336:
138Chapter 4 ■Writing Your First
- Page 340:
140Chapter 4 ■Writing Your First
- Page 344:
142Chapter 4 ■Writing Your First
- Page 348:
This page intentionally left blank
- Page 352:
146Chapter 5 ■Programming the Key
- Page 356:
148Chapter 5 ■Programming the Key
- Page 360:
150Chapter 5 ■Programming the Key
- Page 364:
152Chapter 5 ■Programming the Key
- Page 368:
154Chapter 5 ■Programming the Key
- Page 372:
156Chapter 5 ■Programming the Key
- Page 376:
158Chapter 5 ■Programming the Key
- Page 380:
160Chapter 5 ■Programming the Key
- Page 384:
162Chapter 5 ■Programming the Key
- Page 388:
164Chapter 5 ■Programming the Key
- Page 392:
166Chapter 5 ■Programming the Key
- Page 396:
168Chapter 5 ■Programming the Key
- Page 400:
170Chapter 5 ■Programming the Key
- Page 404:
172Chapter 5 ■Programming the Key
- Page 408:
174Chapter 5 ■Programming the Key
- Page 412:
176Chapter 5 ■Programming the Key
- Page 416:
178Chapter 5 ■Programming the Key
- Page 420:
180Chapter 5 ■Programming the Key
- Page 424:
182Chapter 5 ■Programming the Key
- Page 428:
184Chapter 5 ■Programming the Key
- Page 432:
Welcome to Part II of Game Programm
- Page 436:
188Chapter 6 ■Introduction to Gam
- Page 440:
190Chapter 6 ■Introduction to Gam
- Page 444:
192Chapter 6 ■Introduction to Gam
- Page 448:
194Chapter 6 ■Introduction to Gam
- Page 452:
196Chapter 6 ■Introduction to Gam
- Page 456:
198Chapter 6 ■Introduction to Gam
- Page 460:
200Chapter 6 ■Introduction to Gam
- Page 464:
202Chapter 6 ■Introduction to Gam
- Page 468:
204Chapter 6 ■Introduction to Gam
- Page 472:
206Chapter 6 ■Introduction to Gam
- Page 476:
208Chapter 6 ■Introduction to Gam
- Page 480:
210Chapter 6 ■Introduction to Gam
- Page 484:
212Chapter 6 ■Introduction to Gam
- Page 488:
214Chapter 6 ■Introduction to Gam
- Page 492:
216Chapter 7 ■Basic Bitmap Handli
- Page 496:
218Chapter 7 ■Basic Bitmap Handli
- Page 500:
220Chapter 7 ■Basic Bitmap Handli
- Page 504:
222Chapter 7 ■Basic Bitmap Handli
- Page 508:
224Chapter 7 ■Basic Bitmap Handli
- Page 512:
226Chapter 7 ■Basic Bitmap Handli
- Page 516:
228Chapter 7 ■Basic Bitmap Handli
- Page 520: 230Chapter 7 ■Basic Bitmap Handli
- Page 524: 232Chapter 7 ■Basic Bitmap Handli
- Page 528: 234Chapter 7 ■Basic Bitmap Handli
- Page 532: 236Chapter 7 ■Basic Bitmap Handli
- Page 536: 238Chapter 8 ■Basic Sprite Progra
- Page 540: 240Chapter 8 ■Basic Sprite Progra
- Page 544: 242Chapter 8 ■Basic Sprite Progra
- Page 548: 244Chapter 8 ■Basic Sprite Progra
- Page 552: 246Chapter 8 ■Basic Sprite Progra
- Page 556: 248Chapter 8 ■Basic Sprite Progra
- Page 560: 250Chapter 8 ■Basic Sprite Progra
- Page 564: 252Chapter 8 ■Basic Sprite Progra
- Page 568: 254Chapter 8 ■Basic Sprite Progra
- Page 574: Basic Sprite Handling 257Figure 8.1
- Page 578: Enhancing Tank War259sprite around
- Page 582: Enhancing Tank War 261New TanksNow
- Page 586: Enhancing Tank War 263//define some
- Page 590: Enhancing Tank War 265{}int x = tan
- Page 594: Enhancing Tank War 267}explode_bmp
- Page 598: Enhancing Tank War 269}bullet_bmp =
- Page 602: Enhancing Tank War 271/////////////
- Page 606: Enhancing Tank War 273void setuptan
- Page 610: Enhancing Tank War 275allegro_init(
- Page 614: Chapter Quiz 2775. Which function d
- Page 618: chapter 9Advanced SpriteProgramming
- Page 622:
Animated Sprites 281Figure 9.2 The
- Page 626:
Animated Sprites 283}rest(10);retur
- Page 630:
Animated Sprites 285Now that we hav
- Page 634:
Animated Sprites 287Figure 9.4 The
- Page 638:
Animated Sprites 289//simple screen
- Page 642:
Animated Sprites 291ball->x, ball->
- Page 646:
Animated Sprites 293The SpriteGrabb
- Page 650:
Animated Sprites 295}//update frame
- Page 654:
Animated Sprites 297//initialize th
- Page 658:
Animated Sprites 299}sprites[n]->yd
- Page 662:
Animated Sprites 301updatesprite(sp
- Page 666:
Animated Sprites 303}}if (—spr->c
- Page 670:
Animated Sprites 305}destroy_bitmap
- Page 674:
Run-Length Encoded Sprites 307Creat
- Page 678:
Run-Length Encoded Sprites 309The a
- Page 682:
Run-Length Encoded Sprites 311}spr-
- Page 686:
Compiled Sprites 313dragon->animdir
- Page 690:
Compiled Sprites 315The bitmap in t
- Page 694:
Collision Detection 317There is one
- Page 698:
The CollisionTest Program 319I have
- Page 702:
The CollisionTest Program 321int in
- Page 706:
The CollisionTest Program 323void m
- Page 710:
Enhancing Tank War 325you’ll foll
- Page 714:
Enhancing Tank War 327}void eraseta
- Page 718:
Enhancing Tank War 329}explode_bmp
- Page 722:
fire bullet in direction tank is fa
- Page 726:
Enhancing Tank War 333void turnrigh
- Page 730:
Enhancing Tank War 335//load bullet
- Page 734:
Chapter Quiz 337important points we
- Page 738:
chapter 10ProgrammingTile-Based Bac
- Page 742:
A Limited View of the World 341scro
- Page 746:
A Limited View of the World 343note
- Page 750:
Introduction to Tile-Based Backgrou
- Page 754:
Introduction to Tile-Based Backgrou
- Page 758:
Introduction to Tile-Based Backgrou
- Page 762:
Introduction to Tile-Based Backgrou
- Page 766:
Introduction to Tile-Based Backgrou
- Page 770:
Enhancing Tank War 355{}for (tilex=
- Page 774:
Enhancing Tank War 357Figure 10.11
- Page 778:
Enhancing Tank War 359Figure 10.15
- Page 782:
Enhancing Tank War 361{//new elemen
- Page 786:
Enhancing Tank War 363{}explode_bmp
- Page 790:
Enhancing Tank War 365}}//draw expl
- Page 794:
Enhancing Tank War 367/////////////
- Page 798:
Enhancing Tank War 369#include “t
- Page 802:
Enhancing Tank War 371{}tank_bmp[0]
- Page 806:
Enhancing Tank War 373}}blit(grabfr
- Page 810:
Enhancing Tank War 375int map[MAPW*
- Page 814:
Enhancing Tank War377//draw scrolli
- Page 818:
Chapter Quiz 3792. What does a scro
- Page 822:
chapter 11Timers, InterruptHandlers
- Page 826:
Timers 383The rest1 callback functi
- Page 830:
Timers 385void updatesprite(SPRITE
- Page 834:
Timers 387sprites[0]->x = 500;sprit
- Page 838:
Timers 389sprites[3]->animdir = 1;/
- Page 842:
Timers 391//update the spritesfor (
- Page 846:
Interrupt Handlers 393Not all opera
- Page 850:
Using Timed Game Loops 395//update
- Page 854:
Multi-Threading 397framerate = tick
- Page 858:
Multi-Threading 399Math-intensive p
- Page 862:
Multi-Threading 401Creating a New T
- Page 866:
Multi-Threading 403You must destroy
- Page 870:
Multi-Threading 405Figure 11.5 Addi
- Page 874:
Multi-Threading 407}}spr->framecoun
- Page 878:
Multi-Threading 409}}balls[n]->fram
- Page 882:
Multi-Threading 411//erase sprite 1
- Page 886:
Enhancing Tank War 413//unlock the
- Page 890:
Enhancing Tank War 415Figure 11.8 T
- Page 894:
Enhancing Tank War 417draw_sprite(b
- Page 898:
Enhancing Tank War 419}{scrolly[num
- Page 902:
Enhancing Tank War 421//load second
- Page 906:
Enhancing Tank War 423}}}else{explo
- Page 910:
Enhancing Tank War 425textprintf(bu
- Page 914:
Chapter Quiz 4271. Why is it import
- Page 918:
chapter 12Creating a GameWorld: Edi
- Page 922:
Creating the Game World 431Figure 1
- Page 926:
Creating the Game World 433Figure 1
- Page 930:
Creating the Game World435I’ll sh
- Page 934:
Loading and Drawing Mappy Level Fil
- Page 938:
Loading and Drawing Mappy Level Fil
- Page 942:
Loading and Drawing Mappy Level Fil
- Page 946:
Loading and Drawing Mappy Level Fil
- Page 950:
Enhancing Tank War 445yoffset-=4;if
- Page 954:
Enhancing Tank War 447Figure 12.14
- Page 958:
Enhancing Tank War 449if (scroll ==
- Page 962:
Enhancing Tank War 451{}scrollx[num
- Page 966:
Chapter Quiz 453Only one more chang
- Page 970:
chapter 13Vertical ScrollingArcade
- Page 974:
Building a Vertical Scroller Engine
- Page 978:
Building a Vertical Scroller Engine
- Page 982:
Building a Vertical Scroller Engine
- Page 986:
Building a Vertical Scroller Engine
- Page 990:
Writing a Vertical Scrolling Shoote
- Page 994:
Writing a Vertical Scrolling Shoote
- Page 998:
Writing a Vertical Scrolling Shoote
- Page 1002:
Writing a Vertical Scrolling Shoote
- Page 1006:
Writing a Vertical Scrolling Shoote
- Page 1010:
Writing a Vertical Scrolling Shoote
- Page 1014:
Writing a Vertical Scrolling Shoote
- Page 1018:
Writing a Vertical Scrolling Shoote
- Page 1022:
Writing a Vertical Scrolling Shoote
- Page 1026:
Writing a Vertical Scrolling Shoote
- Page 1030:
Writing a Vertical Scrolling Shoote
- Page 1034:
Chapter Quiz 487SummaryVertical scr
- Page 1038:
chapter 14Horizontal ScrollingPlatf
- Page 1042:
Creating Horizontal Platform Levels
- Page 1046:
Creating Horizontal Platform Levels
- Page 1050:
Creating Horizontal Platform Levels
- Page 1054:
Creating Horizontal Platform Levels
- Page 1058:
Developing a Scrolling Platform Gam
- Page 1062:
Developing a Scrolling Platform Gam
- Page 1066:
Developing a Scrolling Platform Gam
- Page 1070:
Developing a Scrolling Platform Gam
- Page 1074:
Chapter Quiz 507Chapter QuizYou can
- Page 1078:
PART IIITaking it to theNext LevelC
- Page 1082:
chapter 15Mastering the AudibleReal
- Page 1086:
The PlayWave Program 513//initializ
- Page 1090:
Sound Initialization Routines 515wh
- Page 1094:
Standard Sample Playback Routines 5
- Page 1098:
Low-Level Sample Playback Routines
- Page 1102:
Low-Level Sample Playback Routines
- Page 1106:
The SampleMixer Program 523Figure 1
- Page 1110:
Enhancing Tank War525destroy_sample
- Page 1114:
Enhancing Tank War 527if (install_s
- Page 1118:
Enhancing Tank War 529Now scroll do
- Page 1122:
Enhancing Tank War 531}}//player 2
- Page 1126:
Enhancing Tank War 533{key_count[nu
- Page 1130:
Enhancing Tank War 535}return;//set
- Page 1134:
Chapter Quiz 537SummaryThis chapter
- Page 1138:
chapter 16Using Datafiles toStore G
- Page 1142:
Creating Allegro Datafiles 541If yo
- Page 1146:
Creating Allegro Datafiles 543dat -
- Page 1150:
Testing Allegro Datafiles 545noteIf
- Page 1154:
Testing Allegro Datafiles 547//init
- Page 1158:
Chapter Quiz 5497. What is the data
- Page 1162:
chapter 17Playing FLIC MoviesFLI is
- Page 1166:
Playing FLI Animation Files 553Figu
- Page 1170:
Loading FLIs into Memory 555Opening
- Page 1174:
Loading FLIs into Memory 557Figure
- Page 1178:
Loading FLIs into Memory 559Figure
- Page 1182:
Chapter Quiz 561SummaryThis chapter
- Page 1186:
chapter 18Introduction toArtificial
- Page 1190:
The Fields of Artificial Intelligen
- Page 1194:
The Fields of Artificial Intelligen
- Page 1198:
The Fields of Artificial Intelligen
- Page 1202:
Deterministic Algorithms 571Random
- Page 1206:
Deterministic Algorithms573kDistanc
- Page 1210:
Finite State Machines 575GuardPatte
- Page 1214:
Fuzzy Logic 577}// State 4if (Dista
- Page 1218:
Fuzzy Logic 579You can also see tha
- Page 1222:
Summary 581You can use this method
- Page 1226:
Chapter Quiz 5836. Which type of in
- Page 1230:
chapter 19The MathematicalSide of G
- Page 1234:
Trigonometry 587Equation 19.1Equati
- Page 1238:
Trigonometry 589What is the differe
- Page 1242:
Vectors591Figure 19.4 A 2D vectorco
- Page 1246:
Vectors 593Equation 19.16noteIn Fig
- Page 1250:
Vectors 595a length of 1.0, you mus
- Page 1254:
Vectors 597Equation 19.23Equation 1
- Page 1258:
Matrices599Equation 19.28Equation 1
- Page 1262:
Matrices 601Equation 19.34Matrix Co
- Page 1266:
Probability 603ProbabilityProbabili
- Page 1270:
Functions 605Figure 19.10 Intersect
- Page 1274:
Functions 607How do you know the in
- Page 1278:
Chapter Quiz 6095. Which C function
- Page 1282:
chapter 20Publishing Your GameYou h
- Page 1286:
Whose Door to Knock On 613If you ha
- Page 1290:
Milestones 615is to run the contrac
- Page 1294:
Interviews 617Q: What was it like h
- Page 1298:
Interviews 619A: I’ve been told t
- Page 1302:
Interviews 621California and took a
- Page 1306:
Interviews 623very easy to learn an
- Page 1310:
Summary 625Q: From a developer’s
- Page 1314:
Chapter Quiz 6274. What is an impor
- Page 1318:
EpilogueItend to say this each time
- Page 1322:
PART IVAppendixesAppendix AChapter
- Page 1326:
Appendix AChapter QuizAnswersChapte
- Page 1330:
Chapter 4 635Chapter 31. What is th
- Page 1334:
Chapter 6 6376. Which function is u
- Page 1338:
Chapter 9 639Chapter 81. What is th
- Page 1342:
Chapter 11 6415. Which process uses
- Page 1346:
Chapter 14 643Chapter 131. In which
- Page 1350:
Chapter 16 6455. What function woul
- Page 1354:
Chapter 18 647Chapter 181. Which of
- Page 1358:
Chapter 20 6493. What is the second
- Page 1362:
Appendix BUseful TablesThis appendi
- Page 1366:
ASCII Table 653ASCII TableThis is a
- Page 1370:
Char Value Char Value Char ValueASC
- Page 1374:
Appendix CNumbering Systems:Binary
- Page 1378:
Hexadecimal 659Using this table you
- Page 1382:
Hexidecimal 661Table C.4 Hexadecima
- Page 1386:
Appendix DRecommended Booksand Web
- Page 1390:
Recommended Books 665Samu Games: ht
- Page 1394:
Recommended Books 667C++ Programmin
- Page 1398:
Recommended Books 669Programming Ro
- Page 1402:
Appendix EConfiguring Allegrofor Mi
- Page 1406:
Microsoft Visual C++ 673Figure E.2
- Page 1410:
Dev-C++ 675dx80_mgw.zip to C:\Dev-C
- Page 1414:
Dev-C++ 677If you choose to create
- Page 1418:
KDevelop for Linux 679That’s all
- Page 1422:
KDevelop for Linux 681Figure E.10 S
- Page 1426:
Final Comments 683Returning to the
- Page 1430:
Appendix FCompiling theAllegro Sour
- Page 1434:
Borland C++/C++Builder 687That is f
- Page 1438:
KDevelop for LinuxI’m going to ha
- Page 1442:
Appendix GUsing the CD-ROMThe CD th
- Page 1446:
INDEXNumbers1942, 4552D games marke
- Page 1450:
Index 695book, thisartwork, 353goal
- Page 1454:
Index 697DDR graphics, 73-74debuggi
- Page 1458:
Index 699game designbackups, 189-19
- Page 1462:
Index 701Tank War, 229-334transpare
- Page 1466:
Index 703keyboard_needs_poll functi
- Page 1470:
Index 705non-disclosure agreements
- Page 1474:
Index 707random motion deterministi
- Page 1478:
Index 709hyperspace program, 165-16
- Page 1482:
Index 711tankscreating, 120-122movi
- Page 1486:
GNU GENERAL PUBLIC LICENSEVersion 2
- Page 1490:
These requirements apply to the mod
- Page 1494:
8. If the distribution and/or use o
- Page 1498:
License Agreement/Notice of Limited