Invent Your Own Computer Games with Python Al Sweigart download
Invent Your Own Computer Games with Python Al Sweigart download
Sweigart download
https://textbookfull.com/product/invent-your-own-computer-games-
with-python-al-sweigart/
https://textbookfull.com/product/invent-your-own-computer-games-
with-python-4th-edition-al-sweigart/
https://textbookfull.com/product/beyond-the-basic-stuff-with-
python-1st-edition-al-sweigart/
https://textbookfull.com/product/create-computer-games-design-
and-build-your-own-game-patrick-mccabe/
https://textbookfull.com/product/automate-the-boring-stuff-with-
python-2nd-edition-practical-programming-for-total-beginners-al-
sweigart/
Coding Games in Scratch A Step by Step Visual Guide to
Building Your Own Computer Games DK Help Your Kids
Woodcock
https://textbookfull.com/product/coding-games-in-scratch-a-step-
by-step-visual-guide-to-building-your-own-computer-games-dk-help-
your-kids-woodcock/
https://textbookfull.com/product/pro-html5-games-learn-to-build-
your-own-games-using-html5-and-javascript-aditya-ravi-shankar/
https://textbookfull.com/product/make-your-own-pixel-art-create-
graphics-for-games-animations-and-more-jennifer-dawe/
https://textbookfull.com/product/build-your-own-redis-with-c-c-
james-smith/
https://textbookfull.com/product/build-your-own-redis-with-c-c-
james-smith-2/
Contents
1. Cover
2. Title Page
3. Copyright Page
4. About the Author
5. About the Technical Reviewer
6. Brief Contents
7. Contents in Detail
8. Acknowledgments
9. Introduction
2. Evaluating Expressions
3. Syntax Errors
4. Storing Values in Variables
5. Summary
5. Naming Variables
6. Summary
12. Chapter 3: Guess the Number
1. Comparison Operators
2. Checking for True or False with Conditions
3. Experimenting with Booleans, Comparison
Operators, and Conditions
4. The Difference Between = and ==
10. if Statements
11. Leaving Loops Early with the break Statement
12. Checking Whether the Player Won
13. Checking Whether the Player Lost
14. Summary
13. Chapter 4: A Joke-Telling Program
1. def Statements
2. Calling a Function
3. Where to Put Function Definitions
7. Multiline Strings
8. How to Loop with while Statements
9. Boolean Operators
16. Summary
15. Chapter 6: Using the Debugger
1. Types of Bugs
2. The Debugger
5. Summary
5. Calling Methods
9. elif Statements
10. Making Sure the Player Entered a Valid Guess
11. Asking the Player to Play Again
12. Review of the Hangman Functions
13. The Game Loop
1. List References
2. Using List References in makeMove()
18. Summary
20. Chapter 11: The Bagels Deduction Game
14. Summary
21. Chapter 12: The Cartesian Coordinate System
12. Summary
23. Chapter 14: Caesar Cipher
4. Summary
1. Installing pygame
2. Hello World in pygame
3. Sample Run of pygame Hello World
4. Source Code for pygame Hello World
5. Importing the pygame Module
6. Initializing pygame
7. Setting Up the pygame Window
1. Tuples
2. Surface Objects
8. Setting Up Color Variables
9. Writing Text on the pygame Window
1. Drawing a Polygon
2. Drawing a Line
3. Drawing a Circle
4. Drawing an Ellipse
5. Drawing a Rectangle
6. Coloring Pixels
15. Summary
27. Chapter 18: Animating Graphics
1. Adding a Sprite
2. Changing the Size of a Sprite
1. i
2. ii
3. iii
4. iv
5. v
6. vi
7. vii
8. viii
9. ix
10. x
11. xi
12. xii
13. xiii
14. xiv
15. xv
16. xvi
17. xvii
18. xviii
19. xix
20. xx
21. xxi
22. xxii
23. xxiii
24. xxiv
25. xxv
26. xxvi
27. xxvii
28. xxviii
29. 1
30. 2
31. 3
32. 4
33. 5
34. 6
35. 7
36. 8
37. 9
38. 10
39. 11
40. 12
41. 13
42. 14
43. 15
44. 16
45. 17
46. 18
47. 19
48. 20
49. 21
50. 22
51. 23
52. 24
53. 25
54. 26
55. 27
56. 28
57. 29
58. 30
59. 31
60. 32
61. 33
62. 34
63. 35
64. 36
65. 37
66. 38
67. 39
68. 40
69. 41
70. 42
71. 43
72. 44
73. 45
74. 46
75. 47
76. 48
77. 49
78. 50
79. 51
80. 52
81. 53
82. 54
83. 55
84. 56
85. 57
86. 58
87. 59
88. 60
89. 61
90. 62
91. 63
92. 64
93. 65
94. 66
95. 67
96. 68
97. 69
98. 70
99. 71
100. 72
101. 73
102. 74
103. 75
104. 76
105. 77
106. 78
107. 79
108. 80
109. 81
110. 82
111. 83
112. 84
113. 85
114. 86
115. 87
116. 88
117. 89
118. 90
119. 91
120. 92
121. 93
122. 94
123. 95
124. 96
125. 97
126. 98
127. 99
128. 100
129. 101
130. 102
131. 103
132. 104
133. 105
134. 106
135. 107
136. 108
137. 109
138. 110
139. 111
140. 112
141. 113
142. 114
143. 115
144. 116
145. 117
146. 118
147. 119
148. 120
149. 121
150. 122
151. 123
152. 124
153. 125
154. 126
155. 127
156. 128
157. 129
158. 130
159. 131
160. 132
161. 133
162. 134
163. 135
164. 136
165. 137
166. 138
167. 139
168. 140
169. 141
170. 142
171. 143
172. 144
173. 145
174. 146
175. 147
176. 148
177. 149
178. 150
179. 151
180. 152
181. 153
182. 154
183. 155
184. 156
185. 157
186. 158
187. 159
188. 160
189. 161
190. 162
191. 163
192. 164
193. 165
194. 166
195. 167
196. 168
197. 169
198. 170
199. 171
200. 172
201. 173
202. 174
203. 175
204. 176
205. 177
206. 178
207. 179
208. 180
209. 181
210. 182
211. 183
212. 184
213. 185
214. 186
215. 187
216. 188
217. 189
218. 190
219. 191
220. 192
221. 193
222. 194
223. 195
224. 196
225. 197
226. 198
227. 199
228. 200
229. 201
230. 202
231. 203
232. 204
233. 205
234. 206
235. 207
236. 208
237. 209
238. 210
239. 211
240. 212
241. 213
242. 214
243. 215
244. 216
245. 217
246. 218
247. 219
248. 220
249. 221
250. 222
251. 223
252. 224
253. 225
254. 226
255. 227
256. 228
257. 229
258. 230
259. 231
260. 232
261. 233
262. 234
263. 235
264. 236
265. 237
266. 238
267. 239
268. 240
269. 241
270. 242
271. 243
272. 244
273. 245
274. 246
275. 247
276. 248
277. 249
278. 250
279. 251
280. 252
281. 253
282. 254
283. 255
284. 256
285. 257
286. 258
287. 259
288. 260
289. 261
290. 262
291. 263
292. 264
293. 265
294. 266
295. 267
296. 268
297. 269
298. 270
299. 271
300. 272
301. 273
302. 274
303. 275
304. 276
305. 277
306. 278
307. 279
308. 280
309. 281
310. 282
311. 283
312. 284
313. 285
314. 286
315. 287
316. 288
317. 289
318. 290
319. 291
320. 292
321. 293
322. 294
323. 295
324. 296
325. 297
326. 298
327. 299
328. 300
329. 301
330. 302
331. 303
332. 304
333. 305
334. 306
335. 307
336. 308
337. 309
338. 310
339. 311
340. 312
341. 313
342. 314
343. 315
344. 316
345. 317
346. 318
347. 319
348. 320
349. 321
350. 322
351. 323
352. 324
353. 325
354. 326
355. 327
356. 328
357. 329
358. 330
359. 331
360. 332
361. 333
362. 334
363. 335
364. 336
365. 337
366. 338
367. 339
368. 340
369. 341
370. 342
371. 343
372. 344
373. 345
374. 346
375. 347
376. 348
377. 349
INVENT YOUR OWN
COMPUTER GAMES WITH
PYTHON
4TH EDITION
Al Sweigart
San Francisco
INVENT YOUR OWN COMPUTER GAMES WITH PYTHON, 4TH
EDITION.
Some rights reserved. This work is licensed under the Creative Commons
Attribution-NonCommercial-ShareAlike 3.0 United States License. To view a
copy of this license, visit http://creativecommons.org/licenses/by-nc-
sa/3.0/us/ or send a letter to Creative Commons, PO Box 1866, Mountain
View, CA 94042, USA.
Printed in USA
First printing
20 19 18 17 16 123456789
ISBN-10: 1-59327-795-4
ISBN-13: 978-1-59327-795-6
www.nostarch.com
language)
(ebook)
| DDC 794.8/1526--dc23
No Starch Press and the No Starch Press logo are registered trademarks of
No Starch Press, Inc. Other product and company names mentioned herein
may be the trademarks of their respective owners. Rather than use a
trademark symbol with every occurrence of a trademarked name, we are
using the names only in an editorial fashion and to the benefit of the
trademark owner, with no intention of infringement of the trademark.
Cade, Jack, 297 and note 1032, 306, 445, 451, 452.
Calais, 26, 28, 32, 36, 39, 93, 94, 97, 138, 159, 235, 247, 253, 319;
conference at, 40, 41;
siege of, 248-250.
Cassidorus, 411.
Cato, 384.
—— VI., King of France, 13, 50, 77, 78, 86, 87, 117, 417.
Charles VII., King of France, 70, 85, 97, 98, 99, 100, 117, 201, 260, 264;
challenged by Henry V. to single combat, 26, 45;
fails to meet Henry V. at Rouen, 75;
truce with Burgundy, 139, 151;
treats with English at Arras, 244, 245;
peace with Burgundy, 246.
Chichele, Henry,
Archbishop of Canterbury, 14, 37, 115, 139, 176, 179, 212, 239, 262,
272, 397;
at conference of Meulan, 78;
at coronation of Catherine, 90;
opening speech in Parliament (1422), 113;
mediates between Gloucester and Beaufort, 172;
objects to Cardinal Legate in England, 192;
crowns Henry VI., 214;
one of the Duchess of Gloucester’s judges, 271;
quarrel with Pope Martin V., 324-327.
Church,
attitude towards French war, 12;
fear of Lollards, 195;
attack on endowments of, 222.
Clarence, Thomas, Duke of, 3, 7, 8, 13, 37, 78, 79, 80, 90, 98, 334, 347;
favours Armagnac party, 12;
summons jury to try Southampton conspirators, 16;
at siege of Harfleur, 21-26;
Constable of army (1417), 45;
at siege of Caen, 46-58;
at siege of Falaise, 53;
in command of army, 54;
opens up way to Rouen, 70;
at siege of Rouen, 70-74;
accompanies Henry V. to Mantes, 78;
defeated and slain at Beaugé, 91.
—— Reginald, commonly called Lord Cobham, 64 note 271, 165 and note
604, 248.
Constance, Council of, 36, 42, 127, 134, 192, 324, 345, 430.
Decembrio, Pier Candido, 323, 372, 380, 387, 388, 409, 412, 421, 426, 430;
translation of Greek classics, 353;
introduction to Gloucester, 354-356;
translation of Plato’s Republic, 354-357, 365;
Gloucester’s chief literary agent in Italy, 358;
correspondence with Gloucester, 358, 365, 367;
buys books for Gloucester, 363, 364, 365.
Disturbances,
rising in Wales (1403), 6;
rising in Wales (1423), 122;
disturbances in London (1425), 170;
disturbances in Norfolk (1427), 194;
disturbances in the Midlands (1428), 211;
Jack Sharpe’s insurrection, 222, 223, 226;
disturbances in South Wales (1441), 268;
Kentish rising (1450), 297;
disturbances in the West (1447) between the Earl of Devon and Sir
William Bonville, 314;
disturbances in York, Wales, Norwich, and Northampton, 314;
riots in London, Salisbury, and Derbyshire, 314.
Dordrecht, 42.
Dover, 32, 34, 36, 37, 89, 95, 97, 102, 138, 229, 235, 247, 297.
Eaton Tregoes, 2.
—— III., King of England, 3, 12, 19, 89, 100, 245, 347, 444.
Espreleques, 253.
Estouteville, 46.
Eu, 27;
capture of, 74.
Exeter, Thomas de Beaufort, Duke of, 70, 71, 342, 421, 444;
Captain of Harfleur, 26;
negotiates for marriage of Henry V., 78;
in Paris, 98;
governor of Paris, 101;
guardian of Henry VI., 103, 115, 163;
member of Council, 116;
commissioner to settle dispute between Beaufort and Gloucester, 179;
death, 189, 210, 212.
Fécamp, 27;
capture of, 74;
Abbot of, 139.
Gisors, 98;
capitulation of, 79.
Gloucester, Eleanor, Duchess of, 269, 275, 315, 323, 331, 408, 418, 434,
443, 453;
Gloucester’s mistress, 165;
marries Gloucester, 205;
receives robes of the Order of the Garter, 248;
accused of witchcraft and treason against Henry VI., 271;
cited to appear before special commission, 272;
trial and sentence, 272, 273;
interest in the Black Art, 275;
influence over the King, 278;
position in the kingdom, 277-279;
evil influence on Gloucester’s career, 289;
death, 274;
portrait, 447;
character, 335.
Gouda, 197.
Guisnes, 253;
castle of, 141.
Hadleigh Castle, 7.
Hainault, Jacqueline, Countess of, Duchess of Gloucester, 38, 102, 103, 108,
120, 124, 125, 137, 165, 206, 282, 311, 321, 325, 326, 327, 335, 349, 384,
390, 453;
early life, 91;
marriage to John of Brabant, 92;
flight to England, 93-95;
sponsor for Henry VI., 126;
marriage to Gloucester, 128;
received into the Fraternity of St. Albans, 129, 130;
the legality of her marriage to Gloucester, 133-135;
return to Hainault, 141, 142;
reception at Mons, 144;
validity of second marriage recognised, 128, 144;
left by Gloucester in Hainault, 159;
English sympathy with, 164;
letters to Gloucester, 165;
appeal to English Council for help, 197;
her divorce refused, 202;
sympathy of Londoners for, 203;
personal appearance and portraits, 126, 434, 447.
Henry IV., King of England, 1, 9, 11, 13, 21, 86, 312, 322, 342, 347, 397,
444;
marriage, 2;
claims the throne, 3;
establishes the Order of the Bath, 3;
conspiracy against, 5;
second marriage, 6;
battle of Shrewsbury, 6;
visits Bardney Abbey, 8;
death, 9.
Henry V., King of England, 7, 9, 16, 17, 18, 20, 26, 34, 85, 90, 91, 111, 113,
123, 129, 180, 208, 222, 245, 261, 284, 313, 322, 324, 397, 400, 444;
popularity, 6;
prepares for war with France, 11-13;
receives envoys from the Dauphin, 14-15;
the campaign of 1415, 21-32;
negotiations with Sigismund, 38, 39;
conference with Burgundy at Calais, 39, 40, 42;
second campaign, 44-80;
siege of Caen, 47;
siege of Falaise, 52;
siege of Rouen, 70-74;
negotiations for peace, 75, 77, 78;
Treaty of Troyes, 87;
invites Jacqueline to England, 95, 126;
third campaign, 97-101;
death-bed wishes, 103;
warns Gloucester not to quarrel with Burgundy, 104, 107;
relations with Beaufort, 107 and note 419;
objection to Cardinal Legate in England, 192, 324;
his foreign policy, 17, 18;
his interest in literature, 343.
Henry VI., King of England, 13, 85, 105, 206, 210, 239, 241, 303, 306, 312,
317, 319, 325, 340, 351, 376, 388, 397, 404, 407, 418, 435, 449;
present as a child in Parliament, 120, 163;
knighted, 188;
coronation in England, 214-215;
coronation in France, 220, 224;
appeases quarrel of Gloucester and Bedford, 244;
assumes the government of the kingdom, 257;
manifesto on the release of Orleans, 267;
marriage, 285;
alienated from Gloucester, 289-290;
in the hands of the Beaufort faction, 307.
—— John Holland II., Earl of, afterwards Duke of Exeter, 262, 265, 316;
defeats the Genoese fleet, 45;
at siege of Caen, 47;
captures Coutances, 59;
at siege of Rouen, 71, 72;
quarrel with Duke of Norfolk, 211, 219, 230, 313;
accompanies Gloucester to Flanders, 248, 249, 252;
commissioner of sorcery, 272.
Isocrates, 372.
—— Queen of Henry IV., 6, 137, 183, 257, 276, 278, 329, 338.
Josephus, 411.
Kenilworth, 274.
Könisberg, 1.
Livy (Titus Livius), 346, 361, 375, 376, 414, 416, 438.
Lollards, 16;
danger to Lancastrian dynasty of, 9;
repression of, 10;
charges against, 195, 222;
government policy towards, 223;
executions, 269, 270;
Gloucester’s attitude towards, 322.
London, 95;
welcomes Henry V. after Agincourt, 32;
visit of Sigismund to, 36;
reception of Queen Catherine, 89;
citizens support Gloucester, 84, 116, 170, 186, 319;
Beaufort attacks, 172;
welcomes Bedford, 176;
reception of Henry VI. on his return from France, 229;
Duchess of Gloucester’s public penance through, 273;
Queen Margaret arrives in, 285.
Lynn, 8, 385.
Maisoncelles, 28.
March, Edmund, Earl of, 16, 63, 122, 163, 309, 313;
Southampton conspiracy, 15;
claim to throne, 15 note 59;
Warden-general of marches of Duchy of Normandy, 64;
at coronation of Queen Catherine, 90;
accompanies Henry V. to France, 97;
member of the Council, 115;
Gloucester suspicious of, 125.
Margaret of Anjou, Queen of Henry VI., 282, 284, 290, 297, 300, 305, 307,
390, 393, 418;
marriage, 285, 286;
sides with Beaufort faction, 288;
poisons King’s mind against Gloucester, 289;
friend of Suffolk, 296;
desires Gloucester’s death, 301;
her share of Gloucester’s lands, 302 and note 1050;
endows a theological Lectureship at Oxford, 397.
Martin V., Pope, 127 and note 472, 169, 197, 221, 234, 257, 278, 323, 324,
325, 326, 328, 330, 388;
urged by Bedford to divorce Jacqueline and John of Brabant, 136;
correspondence with Gloucester, 139, 149, 327;
declares Bull of divorce a forgery, 139;
forbids duel between Gloucester and Burgundy, 167;
creates Beaufort a Cardinal, 192;
declares Jacqueline’s marriage with Brabant legal, 202;
induces English and French to hold a Congress at Arras, 244;
his contest with Chichele over Præmunire, 324-327.
Middle classes, popularity of Gloucester with, 42, 84, 110, 168, 172, 319,
320;
popularity of Sigismund with, 42;
growth in importance of, 43, 82, 83, 84, 341.
Montreuil, 98.
Norfolk, John de Mowbray II., Duke of, 211, 219, 230, 249, 311, 313.
Normandy, Duchy of, 55, 59, 61, 64, 70, 74, 77, 80, 97, 99, 247, 265, 268,
269.
Orleans, 101.
Ovid, 412.
Paris, 11, 31, 73, 79, 97, 98, 118, 138, 139, 151, 155, 202, 214, 224, 345,
369;
refuses help to Harfleur, 24, 25;
Sigismund visits, 36;
Armagnac party driven out of, 70;
Exeter, governor of, 101;
Gloucester, governor of, 101 note 403;
asks for help from England, 117.
—— Matthew, 432.
Pontefract, 444;
Hospital of St. John at, 315.
Poperinghes, 252.
Rimesture, 252.
St. Albans Monastery, 129, 137, 188, 194, 204, 207, 211, 278, 281, 294, 323,
329, 332, 336, 357, 384, 393, 395, 399, 439.
Sallust, 412.
Sele, Lord Say de, supports Queen Margaret and Suffolk, 298, 306;
suspected of murder of Gloucester, 302;
murdered, 288.
Selling, William, 423.
Seneca, 412.
Sigismund, of Luxemburg, Emperor, 75, 91, 95, 134, 155, 259, 376;
his policy, 35;
desire to reconcile France and England, 36;
reception at Dover, 36, 37;
journey to London, 37;
receives Order of the Garter, 38;
refuses to recognise Jacqueline’s claims to her father’s inheritance, 38;
Treaty of Canterbury, 39;
results of his visit to England, 39;
returns to Dordrecht, 42;
his character, 42, 43.
—— John Beaufort II., Earl of (created Duke, 1443), 282, 287, 288, 307.
Stoke, John, Abbot of St. Albans, 75 and note 314, 330, 331, 354.
Suetonius, 411.
—— William de la Pole, Earl of, 63, 85, 100, 230, 248, 287, 290, 303, 304,
307;
supposed plot to murder Burgundy, 140;
commissioner on sorcery, 272;
ordered to France, 248;
supports Beaufort faction, 282;
charged with murder of Gloucester, 296-297, 302, 303, 304;
supporter of Queen Margaret, 288, 302, 325;
murdered, 297, 306;
his share of Gloucester’s possessions, 302 and note 1050.
Terence, 412.
Valon-Chapelle, 252.
Visconti, Filippo Maria, Grand Duke of Milan, 353, 364, 365, 367, 368, 369.
Vitruvius, 365, 369.
Wheathampsted (John Bostock), Abbot of St. Albans, 129, 295, 328 note
1114, 329, 393, 395, 417, 427, 432, 454;
quarrel with Abbot Stoke, 330;
devotion to Gloucester, 338;
Gloucester’s literary adviser, 383;
interested in occult sciences, 384;
builds a Library for St. Albans, 384;
gift of books to Oxford, 404;
his Granarium, 411.
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
textbookfull.com