Charles River Media - Game Programming With Python
Charles River Media - Game Programming With Python
GAME PROGRAMMING
WITH PYTHON
SEAN RILEY
Contents
Preface xvii
1 Overview 1
What This Book Is About 1
What Is Python? 1
What Is Game Development? 2
Can Python Be Used for Games? 3
The Contents of This Book 4
Prerequisites 4
SECTION I Introduction 5
2 Game Architecture 7
2.1 Architecture Diagram 8
2.2 Physical Simulations 9
2.3 Data Drivers 10
2.4 Graphics Engines 11
2D Engines 11
3D Engines 12
Graphics Engine Subcomponents 12
Competing APIs 12
v
c00(FM)_4178.qxd 10/2/03 11:22 AM Page vi
vi Contents
5 Simulation Concepts 35
5.1 The Physical Simulation 36
5.2 Components of the Physical Simulation 36
5.3 Implementing Simulations with Python 37
5.4 Reactive Simulation 37
c00(FM)_4178.qxd 10/2/03 11:22 AM Page vii
Contents vii
6 Data-Driven Simulations 55
6.1 Benefits of Data-Driven Systems 56
6.2 Data Sources 57
Text Files 57
XML 57
Relational Databases 58
Scripting Languages 58
6.3 Implementing a Data Repository 58
Summary 67
7 Collision Detection 69
7.1 Classifying Objects for Collision 70
7.2 Partitioning the World for Collision Detection 72
7.3 Methods of Collision Checking 74
Per Polygon 74
Per Pixel 75
Bounding Boxes 75
Bounding Spheres 75
Tiles 76
7.4 Coordinate Spaces 77
Coordinate Spaces for Collision Detection 77
Coordinate Spaces and Bounding Boxes 78
7.5 Axially Aligned Bounding Boxes 79
7.6 Bounding Spheres 82
c00(FM)_4178.qxd 10/2/03 11:22 AM Page viii
viii Contents
9 Audio 133
9.1 Audio Concepts 134
Amplitude 134
Frequency 134
Channels 134
Sample Rate 134
Pulse Code Modulation 135
9.2 Playing Sound Effects 135
9.3 Ambient Sounds 138
c00(FM)_4178.qxd 10/2/03 11:22 AM Page ix
Contents ix
10 Input 143
10.1 Message Handling 144
10.2 Keyboard Input 146
10.3 Mouse Input 148
10.4 Joystick Input 149
Summary 150
x Contents
Contents xi
xii Contents
Contents xiii
xiv Contents
Contents xv