{{sellerTotalView > 1 ? __("sellers", {number: sellerTotalView}) : __("seller", {number: sellerTotalView}) }}, {{numTotalView > 1 ? __("items", {number: numTotalView}) : __("item", {number: numTotalView}) }}
free FREE

Change Your Zip Code

Inventory information and delivery speeds may vary for different locations.

Location History

{{email ? __('Got it!') : __('Restock Alert')}}

We will notify you by email when the item back in stock.

Cancel
Yami

Jingdong book

Python和Pygame游戏开发指南

{{buttonTypePin == 3 ? __("Scan to view more PinGo") : __("Scan to start")}}

Python和Pygame游戏开发指南

{{__(":people-members", {'people': item.limit_people_count})}} {{ itemCurrency }}{{ item.valid_price }} {{ itemCurrency }}{{ item.invalid_price }} {{ itemDiscount }}
Ends in
{{ itemCurrency }}{{ item.valid_price }}
{{ itemCurrency }}{{ priceFormat(item.valid_price / item.bundle_specification) }}/{{ item.unit }}
{{ itemDiscount }}
{{ itemCurrency }}{{ item.valid_price }} {{ itemCurrency }}{{ priceFormat(item.valid_price / item.bundle_specification) }}/{{ item.unit }} {{ itemCurrency }}{{ item.invalid_price }} {{itemDiscount}}
{{ itemCurrency }}{{ item.valid_price }}
Sale ends in
Sale will starts after Sale ends in
{{ getSeckillDesc(item.seckill_data) }}
{{ __( "Pay with Gift Card to get sale price: :itemCurrency:price", { 'itemCurrency' : itemCurrency, 'price' : (item.giftcard_price ? priceFormat(item.giftcard_price) : '0.00') } ) }} ({{ itemCurrency }}{{ priceFormat(item.giftcard_price / item.bundle_specification) }}/{{ item.unit }}) Details
Best before

Currently unavailable.

We don't know when or if this item will be back in stock.

Unavailable in your area.
Sold Out

Details

Full product details
Editer Recommend

本书作者在国外发布英文版后,受到普遍欢迎和很好的评价。
本书通过详细分析11款示例游戏的源代码,介绍Pygame库的用法。寓教于乐,轻松有趣。
本书所涉及的11款示例游戏,是诸如Nibbles、Tetris、Simon、Bejeweled、Othello、Connect Four、Flood It等经典游戏的翻版。
本书的Web站点https://inventwithpython.com/pygame,提供源代码下载等更多资源。
Content Description

Python语言和Pygame都是开发图形化的计算机游戏的得力工具。Pygame使得开发2D图形程序变得很容易,而且它可以免费下载和安装使用。
本书是一本中级编程图书。本书教你如何用Python语言和Pygame库,来编写图形化的计算机游戏。本书共包括10章。本书首先从Python和Pygame基础知识开始,简短地介绍了Pygame库是如何工作的,以及它提供了哪些功能。然后,结合7款不同的游戏实例的开发过程,详细介绍了应用的技能和技巧。本书针对一些真实的游戏给出了完整的源代码,并且详细说明了这些代码如何工作,以便你能够理解真正的游戏是如何使用Pygame的。
本书适合有一定Python基础知识的读者阅读和学习,进而掌握基本的游戏开发知识和技能,对于Python初学者来说,本书也可以作为通过游戏学习Python开发的实践教程。
Author Description

Al Sweigart是加利福尼亚州旧金山的一名软件开发者。他很喜欢骑自行车、当志愿者、泡咖啡吧以及制作有用的软件。《Making Games with Python & Pygame》是他编写的第二本书。他的另一本书是《Invent Your Own Computer Games with Python》。他生于德克萨斯的休斯顿。他在德克萨斯大学Austin分校读完了计算机科学学位。
Catalogue

第1章安装Python和Pygame 1
1.1 预备知识 1
1.2 下载和安装Python 1
1.3 Windows下的安装说明 1
1.4 Mac OS X上的安装说明 2
1.5 Ubuntu和Linux上的安装
说明 2
1.6 启动Python 2
1.7 安装Pygame 3
1.8 如何阅读本书 4
1.9 特色的程序 4
1.10 下载图形文件和声音文件 4
1.11 行号和空格 4
1.12 图书中的文本折行 5
1.13 在线检查代码 5
1.14 配套网站上的更多信息 6

第2章 Pygame基础知识 7
2.1 GUI vs. CLI 7
2.2 使用Pygame的Hello World程序
源代码 7
2.3 建立一个Pygame程序 8
2.4 游戏循环和游戏状态 10
2.5 pygame.event.Event对象 11
2.6 QUIT事件和pygame.quit()
函数 12
2.7 像素坐标 13
2.8 关于函数、方法、构造函数和
模块中的函数(及其差别)的
一些提示 13
2.9 Surface对象和窗口 14
2.10 颜色 15
2.11 颜色的透明度 16
2.12 pygame.Color对象 17
2.13 Rect对象 17
2.14 基本的绘制函数 19
2.15 pygame.PixelArray对象 22
2.16 pygame.display.update()函数 22
2.17 动画 22
2.18 帧速率和pygame.time.Clock
对象 25
2.19 用pygame.image.load()和blit()
绘制图像 26
2.20 字体 26
2.21 抗锯齿 28
2.22 播放声音 28
2.23 本章小结 29

第3章 Memory Puzzle游戏 31
3.1 如何玩Memory Puzzle游戏 31
3.2 嵌套的for循环 31
3.3 Memory Puzzle的源代码 33
3.4 声明和导入 40
3.5 幻数很糟糕 40
3.6 使用assert语句全面检查 41
3.7 判断一个数字是偶数还是奇数 42
3.8 较早崩溃和经常崩溃 42
3.9 让源代码更好看一些 43
3.10 使用常量变量而不是字符串 44
3.11 确保有足够的图标 44
3.12 元组vs.列表,不可变vs.可变 45
3.13 单项元组需要一个结尾的逗号 46
3.14 在列表和元组之间转换 46
3.15 global语句以及为什么全局变量
是罪恶的 47
3.16 数据结构和2D列表 48
3.17 “开始游戏”动画 49
3.18 游戏循环 50
3.19 事件处理循环 50
3.20 检查鼠标光标在哪一个方块
之上 51
3.21 处理第一次点击的方块 52
3.22 处理不一致的一对图标 53
3.23 处理玩家获胜 53
3.24 将游戏状态绘制到屏幕 54
3.25 创建“揭开的方块”数据结构 55
3.26 创建游戏板数据结构:第1步—获取所有可能的图标 55
3.27 第2步—打乱并截取所有图标
的列表 56
3.28 第3步—将图标放置到游戏
板上 56
3.29 将一个列表分割为列表的
列表 57
3.30 不同的坐标系 58
3.31 从像素坐标转换为方块坐标 59
3.32 绘制图标以及语法糖 59
3.33 获取游戏板控件的图标的形状和
颜色的语法糖 61
3.34 绘制盖住的方块 61
3.35 处理揭开和覆盖动画 62
3.36 绘制整个游戏板 63
3.37 绘制高亮边框 63
3.38 “开始游戏”动画 64
3.39 揭开和盖住成组的方块 64
3.40 “游戏获胜”动画 65
3.41 判断玩家是否已经获胜 65
3.42 为何要那么麻烦地使用main()
函数 66
3.43 为什么要为可读性操心 67
3.44 本章小结 71

第4章 Slide Puzzle 72
4.1 如何玩Slide Puzzle 72
4.2 Slide Puzzle的源代码 72
4.3 第二款游戏和第一款相同 80
4.4 设置按钮 81
4.5 使用愚笨的代码变聪明 83
4.6 主游戏循环 83
4.7 点击按钮 84
4.8 用鼠标滑动贴片 85
4.9 用键盘滑动贴片 85
4.10 使用in操作符实现“等于其中
之一”的技巧 86
4.11 WASD和箭头按键 86
4.12 实际执行贴片滑动 87
4.13 IDLE和终止Pygame程序 87
4.14 检查特定的事件并且将事件添加
到Pygame的事件队列 88
4.15 创建游戏板数据结构 89
4.16 不记录空白的位置 89
4.17 通过更新游戏板数据结构来
移动 90
4.18 何时不使用断言 90
4.19 获取一次并不是那么随机的
移动 91
4.20 将贴片坐标转换为像素坐标 92
4.21 将像素坐标转换为游戏板坐标 92
4.22 绘制一个贴片 93
4.23 让文本显示在屏幕上 93
4.24 绘制游戏板 94
4.25 绘制游戏板的边框 94
4.26 绘制按钮 95
4.27 实现贴片滑动动画 95
4.28 Surface的copy()方法 96
4.29 创建新的谜题 98
4.30 实现游戏板重置动画 99
4.31 时间vs.内存的权衡 100
4.32 没人在乎几个字节 101
4.33 没人在乎几百万个纳秒 101
4.34 本章小结 101

第5章Simulate 102
5.1 如何玩Simulate游戏 102
5.2 Simulate的源代码 102
5.3 常用初始内容 108
5.4 设置按钮 109
5.5 main()函数 110
5.6 程序中用到的一些局部变量 110
5.7 绘制游戏板并处理输入 111
5.8 检查鼠标点击 112
5.9 检查键盘按下 112
5.10 游戏循环的两种状态 113
5.11 搞清楚玩家是否按下了正确的
按钮 113
5.12 新纪元时间 115
5.13 将游戏板绘制到屏幕 116
5.14 相同的旧的terminate()函数 116
5.15 复用常量变量 117
5.16 实现按钮闪烁动画 117
5.17 绘制按钮 120
5.18 实现背景颜色改变的动画 120
5.19 游戏结束动画 121
5.20 将像素坐标转换为按钮 122
5.21 显式比隐式好 123

第6章Wormy 125
6.1 Wormy游戏的玩法 125
6.2 Wormy的源代码 125
6.3 栅格 131
6.4 设置代码 131
6.5 main()函数 132
6.6 单独的runGame()函数 133
6.7 事件处理循环 134
6.8 碰撞检测 134
6.9 检测和苹果的碰撞 135
6.10 移动虫子 136
6.11 insert()列表方法 136
6.12 绘制屏幕 137
6.13 在屏幕上绘制“Press a key”
文本 137
6.14 checkForKeyPress()函数 137
6.15 初始屏幕 138
6.16 旋转初始屏幕文本 139
6.17 旋转并不完美 140
6.18 决定苹果出现在哪里 141
6.19 游戏结束屏幕 141
6.20 绘制函数 142
6.21 不要复用变量名 144

第7章Tetromino 146
7.1 一些Tetromino术语 146
7.2 Tetromino的源代码 147
7.3 常用设置代码 159
7.4 设置按下键的定时常量 159
7.5 更多的设置代码 160
7.6 设置砖块模式 161
7.7 将“一行代码”分隔到多行 164
7.8 main()函数 165
7.9 开始新的游戏 166
7.10 游戏循环 167
7.11 事件处理循环 167
7.12 暂停游戏 167
7.13 使用移动变量来处理用户输入 168
7.14 检查移动或旋转是否有效 168
7.15 找到底部 171
7.16 通过按下按键来移动 172
7.17 让砖块“自然”落下 174
7.18 将所有内容绘制到屏幕上 175
7.19 制作文本的快捷函数
makeTextObjs() 176
7.20 相同的旧的terminate()函数 176
7.21 使用checkForKeyPress()函数等
待按键事件 176
7.22 通用文本屏幕函数
showTextScreen() 177
7.23 checkForQuit()函数 178
7.24 calculateLevelAndFallFreq()
函数 178
7.25 用函数getNewPiece()产生新的
砖块 180
7.26 给游戏板数据结构添加砖块 181
7.27 创建一个新的游戏板数据
结构 181
7.28 isOnBoard()和isValidPosition()
函数 182
7.29 检查、删除和填满一行 184
7.30 将游戏板坐标转换为像素坐标 186
7.31 在游戏板上或屏幕上的其他位置
绘制方块 187
7.32 将所有内容绘制到屏幕上 187
7.33 绘制得分和关卡文本 188
7.34 在游戏板上或屏幕的其他位置
绘制一个砖块 188
7.35 绘制“Next”砖块 189
7.36 本章小结 189

第8章Squirrel Eat Squirrel 191
8.1 如何玩Squirrel Eat Squirrel 191
8.2 Squirrel Eat Squirrel的设计 191
8.3 Squirrel Eat Squirrel的源代码 192
8.4 常用设置代码 202
8.5 描述数据结构 203
8.6 main()函数 204
8.7 pygame.transform.flip()函数 205
8.8 更为详细的游戏状态 205
8.9 常用的文本创建代码 206
8.10 相机 206
8.11 “活动区域” 208
8.12 记录游戏世界中的物体的位置 208
8.13 从一些草开始 209
8.14 游戏循环 209
8.15 检查去掉保护状态 209
8.16 移动敌人松鼠 210
8.17 删除较远的草对象和松鼠
对象 211
8.18 当从列表中删除项的时候,
反向遍历列表 211
8.19 添加新的草对象和松鼠对象 213
8.20 相机延迟以及移动相机视图 213
8.21 绘制背景、草、松鼠和生命值
指示 214
8.22 事件处理循环 216
8.23 移动玩家并考虑跳动 218
8.24 碰撞检测:吃或被吃 219
8.25 游戏结束屏幕 221
8.26 获胜 221
8.27 绘制图形化的生命值指标 221
8.28 相同的旧的terminate()函数 222
8.29 正弦函数 222
8.30 对Python 2的向后兼容 225
8.31 getRandomVelocity()函数 226
8.32 找到一个地方添加新的松鼠
和草 226
8.33 创建敌人松鼠数据结构 228
8.34 翻转松鼠图像 228
8.35 创建草数据结构 229
8.36 检查是否在活动区域之外 229
8.37 本章小结 230

第9章Star Pusher 231
9.1 如何玩Star Pusher 231
9.2 Star Pusher的源代码 232
9.3 初始化设置 245
9.4 Star Pusher中的数据结构 259
9.5 读取和写入文本文件 260
9.6 递归函数 268
9.7 栈溢出 269
9.8 使用基本条件防止栈溢出 271
9.9 漫水填充算法 271
9.10 绘制地图 273
9.11 检查关卡是否完成 275
9.12 本章小结 276

第10章4款其他游戏 277
10.1 Flippy,Othello的翻版 277
10.2 Flippy的源代码 279
10.3 Ink Spill,Flood It游戏的
翻版 291
10.4 Ink Spill的源代码 292
10.5 Four-In-A-Row,Connect Four
的翻版 303
10.6 Four-In-A-Row的源代码 304
10.7 Gemgem,Bejeweled的翻版 312
10.8 Gemgem的源代码 313
10.9 本章小结 326

术语表 328

Specifications

Brand Jingdong book
Brand Origin China

Disclaimer

Product packaging, specifications and price are subject to change without notice. All information about the products on our website is provided for information purposes only. Please always read labels, warnings and directions provided with the product before use.

View Full Terms of Use
Add to favorites
{{ $isZh ? coupon.coupon_name_sub : coupon.coupon_ename_sub | formatCurrency }}
{{__("Buy Directly")}} {{ itemCurrency }}{{ item.directly_price }}
Quantity
{{ quantity }}
{{ instockMsg }}
{{ limitText }}
{{buttonTypePin == 3 ? __("Scan to view more PinGo") : __("Scan to start")}}
Sold by JD@CHINA
Ship to
{{ __("Ship to United States only") }}
Free shipping over 69
Genuine guarantee

Added to Cart

Keep Shopping

More to Consider

{{ item.brand_name }}

{{ item.item_name }}

{{ item.currency }}{{ item.market_price }}

{{ item.currency }}{{ item.unit_price }}

{{ item.currency }}{{ item.unit_price }}

Coupons

{{ coupon.coupon_name_new | formatCurrency }}
Clip Clipped Over
{{ getCouponDescStr(coupon) }}
{{ coupon.use_time_desc }}
Expires soon {{ formatTime(coupon.use_end_time) }}

Share this item with friends

Cancel

Yami Gift Card

Get this exclusive deal when paying with gift card

Terms and Conditions

Gift card deals are special offers for selected products;

The gift card deals will automatically be activated if a customer uses gift card balance at check out and the balance is sufficient to pay for the total price of the shopping cart products with gift card deals;

You will not be able to activate the gift card deals if you choose other payment methods besides gift card. The products will be purchased at their normal prices;

If your account balance is not enough to pay for the products with gift card deals, you can choose to reload your gift card balance by clicking on the Reload button at either shopping cart page or check out page;

Products that have gift card deals can be recognized by a special symbol showing 'GC Deal';

For any additional questions or concerns, please contact our customer service;

Yamibuy reserves the right of final interpretation.

Sold by Yami

Service Guarantee

Yami Free Shipping over $49
Yami Easy Returns
Yami Ships from United States

Shipping

  • United States

    Standard Shipping is $5.99 (Excluding Alaska & Hawaii). Free on orders of $49 or more.

    Local Express is $5.99 (Available in Parts of CA, NJ, MA & PA). Free on orders of $49 or more.

    2-Day Express (Includes Alaska & Hawaii) starts at $19.99.

Return Policy

Yami is committed to provide our customers with a peace of mind when purchasing from us. Most items shipped from Yamibuy.com can be returned within 30 days of receipt of shipment (For Food, Beverages, Snacks, Dry Goods, Health supplements, Fresh Grocery and Perishables Goods, within 7 days of receipt of shipment due to damages or quality issues; To ensure that every customer receives safe and high-quality products, we do not provide refunds or returns for beauty products once they have been opened or used, except in the case of quality issues; Some products may have different policies or requirements associated with them, please see below for products under special categories, or contact Yami Customer Service for further assistance).
Thank you for your understanding and support.

Learn More

Sold by Yami

Terms and Conditions of Yami E-Gift Card

If you choose “Redeem automatically” as your delivery method, your gift card balance will be reload automatically after your order has been processed successfully;

If you choose “Send to Email”as your delivery method, the card number and CVV will be sent to the email address automatically;

Any user can use the card number and CVV to redeem the gift card, please keep your gift card information safely. If you have any trouble receiving email, please contact Yami customer service;

Yami gift card can be used to purchase both Yami owned or Marketplace products;

Yami gift card will never expire;

Yami gift card balance does not have to be used up at once;

All rights reserved by Yami.

Return Policy

Gift card that has already been consumed is non-refundable.

Sold by JD@CHINA

Service Guarantee

Yami Free Shipping over $49
Yami Easy Returns
Yami Ships from United States

Shipping

  • United States

    Standard Shipping is $5.99 (Excluding Alaska & Hawaii). Free on orders of $49 or more.

    Local Express is $5.99 (Available in Parts of CA, NJ, MA & PA). Free on orders of $49 or more.

    2-Day Express (Includes Alaska & Hawaii) starts at $19.99.

Return Policy

You may return product within 30 days upon receiving the product. Items returned must be new in it's original packing, including the original invoice for the purchase. Customer return product at their own expense.

Sold by JD@CHINA

Service Guarantee

Yami Cross-store Free Shipping over $69
Yami 30-days Return

Yami-China FC

Yami has a consolidation warehouse in China which collects multiple sellers’ packages and combines to one order. Our Yami consolidation warehouse will directly ship the packages to your door. Cross-store free shipping over $69.

Return Policy

You may return products within 30 days upon receiving the products. Sellers take responsibilities for any wrong shipment or missing items. Packing needs to be unopened for any other than quality issues return. We promise to pack carefully, but because goods are taking long journey to destinations, simple damages to packaging may occur. Any damages not causing internal goods quality problems are not allowed to return. If you open the package and any quality problem is found, please contact customer service within three days after receipt of goods.

Shipping Information

Yami Consolidation Service Shipping Fee $9.99(Free shipping over $69)

Sellers in China will ship their orders within 1-2 business days once the order is placed. Packages are sent to our consolidation warehouse in China and combined there. Our Yami consolidation warehouse will directly ship the packages to you via UPS. The average time for UPS to ship from China to the United States is about 10 working days and it can be traced using the tracking number. Due to the pandemic, the delivery time may be delayed by about 5 days. The package needs to be signed by the guest. If the receipt is not signed, the customer shall bear the risk of loss of the package.

Sold by JD@CHINA

Service Guarantee

Free shipping over 69
Genuine guarantee

Shipping

Yami Consolidated Shipping $9.99(Free shipping over $69)


Seller will ship the orders within 1-2 business days. The logistics time limit is expected to be 7-15 working days. In case of customs clearance, the delivery time will be extended by 3-7 days. The final receipt date is subject to the information of the postal company.

Yami Points information

All items are excluding from any promotion or points events on Yamibuy.com

Return Policy

You may return product within 30 days upon receiving the product. Items returned must be new in it's original packing, including the original invoice for the purchase. Customer return product at their own expense.

Yami

Download the Yami App

Back Top

Recommended for You

About the brand

Jingdong book

为您推荐

Yami
欣葉
2种选择
欣叶 御大福 芋头麻薯 180g

周销量 600+

$1.66 $1.99 83折
Yami
欣葉
2种选择
欣叶 御大福 芋头麻薯 180g

周销量 600+

$1.66 $1.99 83折
Yami
欣葉
2种选择
欣叶 御大福 芋头麻薯 180g

周销量 600+

$1.66 $1.99 83折
Yami
欣葉
2种选择
欣叶 御大福 芋头麻薯 180g

周销量 600+

$1.66 $1.99 83折
Yami
欣葉
2种选择
欣叶 御大福 芋头麻薯 180g

周销量 600+

$1.66 $1.99 83折
Yami
欣葉
2种选择
欣叶 御大福 芋头麻薯 180g

周销量 600+

$1.66 $1.99 83折

Reviews{{'('+ commentList.posts_count + ')'}}

Have your say. Be the first to help other guests.

Write a review
{{ totalRating }} Write a review
  • {{i}} star

    {{i}} stars

    {{ parseInt(commentRatingList[i]) }}%

Yami Yami
{{ comment.user_name }}

{{ showTranslate(comment) }}Show Less

{{ strLimit(comment,800) }}Show more

Show Original

{{ comment.content }}

Yami
Show All

{{ formatTime(comment.in_dtm) }} VERIFIED PURCHASE {{groupData}}

{{ comment.likes_count }} {{ comment.likes_count }} {{ comment.reply_count }} {{comment.in_user==uid ? __('Delete') : __('Report')}}
Yami Yami
{{ comment.user_name }}

{{ showTranslate(comment) }}Show Less

{{ strLimit(comment,800) }}Show more

Show Original

{{ comment.content }}

Yami
Show All

{{ formatTime(comment.in_dtm) }} VERIFIED PURCHASE {{groupData}}

{{ comment.likes_count }} {{ comment.likes_count }} {{ comment.reply_count }} {{comment.in_user==uid ? __('Delete') : __('Report')}}

No related comment~

Review

Yami Yami

{{ showTranslate(commentDetails) }}Show Less

{{ strLimit(commentDetails,800) }}Show more

Show Original

{{ commentDetails.content }}

Yami
Show All

{{ formatTime(commentDetails.in_dtm) }} VERIFIED PURCHASE {{groupData}}

{{ commentDetails.likes_count }} {{ commentDetails.likes_count }} {{ commentDetails.reply_count }} {{commentDetails.in_user==uid ? __('Delete') : __('Report')}}

Please write at least one word

Comments{{'(' + replyList.length + ')'}}

Yami Yami

{{ showTranslate(reply) }}Show Less

{{ strLimit(reply,800) }}Show more

Show Original

{{ reply.reply_content }}

{{ formatTime(reply.reply_in_dtm) }}

{{ reply.reply_likes_count }} {{ reply.reply_likes_count }} {{ reply.reply_reply_count }} {{reply.reply_in_user==uid ? __('Delete') : __('Report')}}

Please write at least one word

Cancel

That’s all the comments so far!

Write a review
How would you rate this item?

Please add your comment.

  • A nice nickname will make your comments more popular!
  • The nickname in your account will be changed to the same as here.
Thanks for your review
Our community rely on great reviews like yours to find the best of Asia.

Report

If you find this content inappropriate and think it should be removed from the Yami.com site, let us know please.

Cancel

Are you sure to delete your review?

Cancel

You’ve Recently Viewed

About the brand

Jingdong book