Invent Your Own Computer Games with Python Al Sweigart instant download
Invent Your Own Computer Games with Python Al Sweigart instant 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.
At the open space before the temple to the Sun they all 110
stopped and the Inca descended.
111
There they were led and young girls of a pretty red-
bronze, with long black hair, came to attend to their
wants while the crowds outside shouted and applauded
until the door was shut.
“All right for you!” grumbled Nicky. “They have some 113
joke about me. If you don’t want to tell——”
“They have a name for you,” Bill chuckled. “Never mind
the exact word, but it means He-Who-Sits-Down-Upon-
Llamas!”
114
CHAPTER XII
CLIFF FACES A PROBLEM
“You fellows are having all the fun,” Cliff said ruefully,
while the disguised five sat around after dinner the third
day they spent in Quichaka. “You can go all over town
and see all the sights and I have to sit like a judge, all
alone in my temple.”
“It won’t be for long,” Nicky cheered him up. “Bill saw
your father again—how was he, Bill?”
“I had a chat with Inca Capac,” Bill said. “I hinted that it 117
was in the mind of Chasca to become as a mortal youth
and try his skill against the noble youths and the son
who is the Inca’s favorite. He liked the idea.”
When they returned, Tom and Mr. Whitley took the plan
well; the young history instructor saw a splendid chance
to give his young charges a real insight into Inca sports
while he, with Bill, could be away in the mountains,
searching for certain chemicals or ore deposits from
which to extract certain mineral salts for his insecticide.
Cliff, as Chasca, but less the supposed god than the real
youth, was very popular with all the people as he
walked in the temple grounds. He and Tom and Nicky
strolled about, the day before the great contest,
admiring the marvels all about them.
“Why,” Nicky cried, “it’s Caya. It’s the girl who called me 120
the fellow who sits on llamas. What’s the matter, Caya?”
She sat up, her dusky face streaming with tears, and
shook her head, for Nicky had forgotten and spoken in
English.
In great buildings far from the everyday life of the tribe 121
they kept certain chosen maidens who were employed
in the service of the Sun-god, spinning and weaving
tapestries, garments and ornamental cloth. From among
these a sacrifice was chosen, when the rare occasion
came for such a terrible need.
“Well, you stop crying and——” Bill nudged him. Cliff, 122
too, was using English. He hesitated, and Bill lifted the
slim, quivering girl to her feet.
“Run and tell Mr. Whitley,” he urged Tom. “If he can get
his chemicals ready in time we may save Caya’s sister.”
123
CHAPTER XIII
THE GAMES
Not far beyond Quichaka there was a sudden rise of the 124
hills in front of whose sharp slope a large tract had been
leveled off. From early dawn the lesser natives had
streamed to their places on the hillside, and after an
early and ample breakfast Cliff and his companions had
gone forth with the Inca and his retinue, Cliff being
honored by a seat in a hamaca, as had been his fortune
on their arrival. He and Bill, Mr. Whitley and Nicky, sat
near one another, watching Tom in the foot races. Cliff
sat in the place of honor at one side of the Inca whose
other place on the further side was given to the high
priest of the temple of the Sun. Below them, among the
nobles, were his friends.
As in the first strife the trickery of one was met by the 128
quick thought and agility of the other, so, during the
long minutes, for they wrestled continuously from start
to final defeat of one or the other, each saw himself
equaled. When Challcuchima secured the Inca
equivalent of a half-nelson, Cliff knew how to create
overconfidence and eventually disarm the holder and
himself get an advantage; when he seized a fortunate
instant to drive through into a hammerlock,
Challcuchima had a trick that made Cliff’s teeth snap in
the pain of suddenly stressed muscles and he had to
release. For it seemed that each of them knew some
principles of the science of causing a surprise reflex by
some hold that taxed a sensitive nerve more than a
straining muscle; and both used their knowledge.
Cliff smiled queerly, turning his head away; his chums 129
wondered why. The rest of the ceremonial was rather
tedious; long and flowery speeches were made by the
Inca and his chief priest, extolling the virtues of his son
and exhorting him to carry the wise and generous rule
forward when he became Inca. Garlands were placed on
the heads of all the contestants, made of bright flowers
with evergreen woven into that of Challcuchima to show
his endurance. Then he was crowned with the special,
tasseled fillet of vicuna wool, yellow in color, which
attested his appointment to be the next ruler.
“No—but I will.”
“Oh!” Nicky was quick to see the idea in Cliff’s mind. “At 130
the Feast of Raymi—before the sacrifice—Caya’s sister.”
131
CHAPTER XIV
GOLD, AND A SURPRISE
“Four days more and you will see your father,” Bill told
Cliff. “He is much better. I saw him today.”
“If only I could slip away and see him, just for a
minute.” Cliff spoke wistfully. Bill shook his head.
Cliff consulted Bill with his eyes and Bill, with a very tiny 134
wink and nod, bade him go. The chums, not invited,
looked downcast as Cliff walked across the gardens of
gold and silver with his young guide; but Bill soothed
them by telling them what he had seen underground.
Cliff was to see far more than was permitted to the eyes
of his supposed scholarly servant.
Wide and long was the chamber. The light, flaring and
flickering as the torches leaped up and burned down,
was filled with gold and silver objects. There were
utensils of every sort, from plates, cups and rude pots,
to wonderful statues and urns and placques of precious
metal. It was a very treasure-house.
Cliff hurried after the servants with their torches and his
royal young guide turned swiftly into a passage they
had not used, which brought them out into one of the
small houses just beyond the Sun temple, a dwelling of
one of the priests.
Cliff met his comrades at the edge of the group: some 137
fell back respectfully to give passage to the young Inca-
to-be and to Chasca and the high priest. They pressed
to the point of interest.
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