Python and Pygame game development pdf

Source: Internet
Author: User

Python and Pygame game development

Directory

1th. Installing Python and Pygame 1
1. 1 Preliminary Knowledge 1
1. 2 Downloading and installing Python 1
1. 3 Installation instructions under Windows 1
1. 4 Installation Instructions on MAC OS x 2
1. 5 installation on Ubuntu and Linux
Description 2
1. 6 Starting Python 2
1. 7 Installing Pygame 3
1. 8 How to read this book 4
1. 9 Featured Programs 4
1. 10 downloading graphics files and sound files 4
1. 11 Line numbers and Spaces 4
1. 12 text wrapping in a book 5
1. 13 Online Check Code 5
1. 14 additional information on the companion website 6

2nd Chapter Pygame Basic Knowledge 7
2. 1 GUI vs. CLI 7
2. 2 using Pygame's Hello World program
Source Code 7
2. 3 Setting up a Pygame program 8
2. 4 game loop and game status 10
2. 5 Pygame. Event Event Object 11
2. 6 Quit events and Pygame. Quit ()
function 12
2. 7 Pixel coordinates 13
2. 8 about functions, methods, constructors, and
The functions in the module (and their differences)
Some tips 13
2. 9 Surface objects and Windows 14
2. 10 Color 15
2. 11 transparency of Colors 16
2. Pygame. Color Object 17
2. Rect Object 17
2. 14 Basic drawing Functions 19
2. Pygame. Pixelarray Object 22
2. Pygame. Display Update () function 22
2. 17 Animations 22
2. 18 frame rate and pygame. Time Clock
Object 25
2. 19 with Pygame. Image Load () and Blit ()
Drawing an Image 26
2. 20 Font 26
2. 21 Anti-aliasing 28
2. 22 Playing sound 28
2. 23 Summary of this chapter 29

3rd Chapter Memory Puzzle game 31
3. 1 How to play memory puzzle games 31
3. 2 Nested for Loop 31
3. 3 Memory Puzzle Source code 33
3. 4 Declaration and Import 40
3. 5 Magic numbers are bad 40
3. 6 full check with Assert statement 41
3. 7 Determine whether a number is even or odd 42
3. 8 earlier crashes and frequent crashes 42
3. 9 make the source code look better 43
3. 10 using constant quantity instead of string 44
3. 11 Make sure there are enough icons for 44
3. 12 tuples vs. list, immutable vs. Variable 45
3. 13 individual tuples require a trailing comma 46
3. 14 converting between lists and tuples 46
3. And why global variables
It's a sin. 47
3. 16 Data structures and 2D listings 48
3. 17 "Start Game" animation 49
3. 18 Game Loop 50
3. 19 Event Processing Loop 50
3. 20 Check which block the mouse cursor is in
Above 51
3. 21 processing the second click of the Block 52
3. 22 handling inconsistent pair of icons 53
3. 23 Handling player wins 53
3. 24 Draw the game state to the screen 54
3. 25 creating a "uncovered block" data structure 55
3. 26 Creating a game board data structure: 1th step-get all possible icons 55
3. 27 2nd Step-disrupt and intercept all icons
List of 56
3. 28 3rd Step-Place the icon in the game
On board 56
3. 29 splitting a list into a list
Listing 57
3. 30 different coordinate Systems 58
3. 31 convert from pixel coordinates to block coordinates 59
3. 32 drawing icons and syntax sugar 59
3. 33 gets the shape of the icon for the GamePad control and
Color syntax for sugar 61
3. 34 draw the covered block 61
3. 35 handling uncover and overlay animations 62
3. 36 drawing the entire game board 63
3. 37 draw a highlighted border 63
3. 38 "Start Game" animation 64
3. 39 uncovering and capping a group of squares 64
3. 40 "game wins" animation 65
3. 41 determine if the player has won 65
3. 42 Why it's so troublesome to use main ()
Function 66
3. 43 Why bother about readability 67
3. 44 Summary of this chapter 71

4th Chapter Slide Puzzle 72
4. 1 How to play slide Puzzle 72
4. 2 Slide Puzzle Source code 72
4. 3 games and the same paragraph 80
4. 4 Setting the button 81
4. 5 use stupid code to become smart 83
4. 6 Main game Loop 83
4. 7 Click Button 84
4. 8 Slide The patch with the mouse 85
4. 9 Slide the patch with the keyboard 85
4. 10 use the In operator to "equal to
One of the "tricks 86
4. WASD and ARROW keys 86
4. 12 actually performing SMD Slide 87
4. 87 idle and Terminate Pygame programs
4. 14 Check for specific events and add events
Event Queue 88 to Pygame
4. 15 Creating a game board data structure 89
4. 16 where blank is not recorded 89
4. 17 by updating the game board data structure to
Move 90
4. 18 When to not use assertion 90
4. 19 getting once is not so random.
Move 91
4. 20 converting the patch coordinates to pixel coordinates 92
4. 21 converting pixel coordinates to game board coordinates 92
4. 22 Drawing a Patch 93
4. 23 Let the text appear on the screen 93
4. 24 Draw the game board 94
4. 25 draw the bezel of the GamePad 94
4. 26 Draw Button 95
4. 27 Implementing SMD Slide Animations 95
4. Copy () method 96 on surface
4. 29 Creating a new Puzzle 98
4. 30 Implementing GamePad Reset animations 99
4. 31 Time vs. Memory trade-Offs 100
4. 32 No one cares about a few bytes 101
4. 33 No one cares millions of nanoseconds 101
4. 34 Summary of this chapter 101

5th Chapter Simulate 102
5. 1 How to play simulate games 102
5. 2 source code for simulate 102
5. 3 Common initial content 108
5. 4 Setting the button 109
5. 5 main () function 110
5. 6 Some local variables used in the program 110
5. 7 Draw GamePad and process input 111
5. 8 Check Mouse click 112
5. 9 Check the keyboard press 112
5. 10 two states of the game Loop 113
5. 11 figure out if the player has pressed the correct
Button 113
5. 12 New Era Time 115
5. 13 draw the GamePad to the screen 116
5. 14 Same old terminate () function 116
5. 15 Multiplexing Constant Volume 117
5. 16 Implement button Flicker animation 117
5. 17 Draw Button 120
5. 18 animating the background color change 120
5. 19 Game over animation 121
5. 20 convert pixel coordinates to button 122
5. 21 explicit ratio implicit good 123

6th Chapter Wormy 125
6. 1 Gameplay of Wormy 125
6. 2 source code for Wormy 125
6. 3 Grid 131
6. 4 setting Code 131
6. 5 main () function 132
6. 6 separate Rungame () function 133
6. 7 Event Processing Loop 134
6. 8 Collision Detection 134
6. 9 detection and collision of Apple 135
6. 10 Moving Worms 136
6. Insert () List method 136
6. 12 Drawing the Screen 137
6. 13 Draw "Press a key" on the screen
Text 137
6. Checkforkeypress () function 137
6. 15 splash Screen 138
6. 16 Rotating the splash screen text 139
6. 17 Rotation not 140
6. 18 decide where the Apple appears 141
6. 19 Game Over screen 141
6. 20 Drawing Functions 142
6. 21 do not reuse variable names 144

7th Chapter Tetromino 146
7. 1 Some Tetromino terms 146
7. 2 source code for Tetromino 147
7. 3 Common Settings Code 159
7. 4 Set the timer constant for pressing the key 159
7. 5 more setup codes for 160
7. 6 Setting Brick Mode 161
7. 7 separating "One line of code" into multiple lines 164
7. 8 Main () function 165
7. 9 Starting a new game 166
7. 10 Game Loop 167
7. 11 Event Processing Loop 167
7. 12 Pause Game 167
7. 13 using the move variable to process user input 168
7. 14 check that movement or rotation is valid 168
7. 15 Find Bottom 171
7. 16 move 172 by pressing the key
7. 17 Let the Brick "natural" fall 174
7. 18 Draw all content onto the screen 175
7. 19 shortcut functions for making text
MAKETEXTOBJS (176)
7. 20 Same old terminate () function 176
7. 21 using the checkforkeypress () function, etc.
Pending key Event 176
7. 22 General text Screen functions
Showtextscreen (177)
7. Checkforquit () function 178
7. Calculatelevelandfallfreq ()
Function 178
7. 25 Using the function getnewpiece () to generate a new
Bricks 180
7. 26 adding bricks to the game board data structure 181
7. 27 Creating a new game board data
Structure 181
7. Isonboard () and Isvalidposition ()
Function 182
7. 29 checking, deleting, and filling a line 184
7. 30 converting game board coordinates to pixel coordinates 186
7. 31 on the game board or other location on the screen
Draw Block 187
7. 32 Draw all content onto the screen 187
7. 33 Draw score and level text 188
7. 34 on the game board or elsewhere on the screen
Draw a Brick 188
7. 35 Draw "Next" bricks 189
7. 36 Summary of this chapter 189

8th Chapter Squirrel Eat Squirrel 191
8. 1 How to play Squirrel Eat Squirrel 191
8. 2 design of Squirrel Eat Squirrel 191
8. 3 Squirrel Eat Squirrel source code 192
8. 4 Common Settings Code 202
8. 5 describing data Structures 203
8. 6 main () function 204
8. 7 Pygame. Transform Flip () function 205
8. 8 more detailed game state 205
8. 9 Common text Creation Code 206
8. 10 Camera 206
8. 11 "Active Area" 208
8. 12 recording the position of objects in the game world 208
8. 13 starting from some grass 209
8. 14 Game Loop 209
8. 15 Check Remove protection status 209
8. 16 Moving Enemy Squirrel 210
8. 17 Delete the farther grass objects and squirrels
Object 211
8. 18 When you remove an item from the list,
Reverse Traverse List 211
8. 19 Adding a new grass object and Squirrel object 213
8. 20 camera delay and mobile camera view 213
8. 21 Draw background, grass, squirrels and health values
Indication 214
8. 22 Event Processing Loop 216
8. 23 move the player and consider the bounce 218
8. 24 Collision Detection: eat or be eaten 219
8. 25 Game Over screen 221
8. 26 wins 221
8. 27 Plotting a graphical health indicator 221
8. 28 Same old terminate () function 222
8. 29 sine Function 222
8. 30 backwards compatibility with Python 2 225
8. Getrandomvelocity () function 226
8. 32 Find a place to add new squirrels
and Grass 226
8. 33 Creating enemy squirrel data Structures 228
8. 34 flipping the squirrel image 228
8. 35 Creating a grass data structure 229
8. 36 Check whether outside the active area 229
8. 37 Summary of this chapter 230

9th Star Pusher 231
9. 1 How to play Star pusher 231
9. 2 Star Pusher Source code 232
9. 3 Initialization Settings 245
9. 4 data structures in Star pusher 259
9. 5 reading and writing to a text file 260
9. 6 Recursive Functions 268
9. 7 Stack Overflow 269
9. 8 using basic conditions to prevent stack overflow 271
9. 9 Diffuse water filling algorithm 271
9. 10 Drawing a Map 273
9. 11 Check if the level is complete 275
9. 12 Summary of this chapter 276

10th Chapter 4 Other games 277
10. 1 Flippy,othello of the pirated 277
10. 2 source code for Flippy 279
10. 3 Ink Spill,flood It game
Pirated 291
10. 4 source code for INK spill 292
10. 5 Four-in-a-row,connect Four
Replica of 303
10. 6 source code for Four-in-a-row 304
10. 7 gemgem,bejeweled of the pirated 312
10. 8 Source code for Gemgem 313
10. 9 Summary of this chapter 326

Glossary 328

: Https://pan.baidu.com/s/17i0-_USHUjEgRaY7DHe9yw

Follow the public number get extract code:

Input: PYPG Get Extract Code

Tags: Unity 3D Network Game Combat (full), Unity 3D Network Game Combat (full) PDF

Python and Pygame game development pdf

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.