第1章 设置你的电脑 ·······················1
准备好你的Windows PC ························· 2
安装Minecraft ······································ 2
安装Python ··········································· 3
安装Java ··············································· 4
安装Minecraft Python API和Spigot ···· 6
运行插件并创建游戏 ·························· 7
重新开始一个新的世界 ······················ 9
离线游戏 ············································ 10
改为生存模式 ···································· 11
准备好你的Mac ····································· 12
安装Minecraft ···································· 13
安装Python ········································· 15
安装Java ············································· 15
安装Minecraft Python API和Spigot····· 16
运行Spigot并创建游戏 ······················ 18
重新开始一个新的世界 ···················· 19
离线游戏 ············································ 20
改为生存模式 ···································· 20
设置你的Raspberry Pi ··························· 21
认识IDLE ··············································· 22
认识Python Shell ······························· 23
和IDLE的文本编辑器问好 ··············· 23
什么时候使用Python,什么时候
使用文本编辑器 ···························· 25
本书中使用的提示符 ························ 26
测试你的Minecraft Python是否能运行 ··· 26
第2章 使用变量传送 ·····················28
什么是程序 ············································ 28
使用变量存储数据 ································ 29
程序语言的结构 ································ 30
变量的语法规则 ································ 31
如何改变变量的值 ···························· 32
整数 ···················································· 32
任务#1 传送你的角色 ···················· 33
浮点数 ················································ 38
任务#2 去你想去的地方 ················ 39
使用时间模块降低传送速度 ················ 40
任务#3 传送之旅 ···························· 41
排除bug ·················································· 43
任务#4 修正一个充满bug的
传送程序 ········································ 44
你学到了什么 ········································ 46
第3章 利用数学快速搭建和长途
旅行 ···························································47
表达式和语句 ········································ 47
运算符号 ················································ 48
加法 ························································· 48
任务#5 堆砖块 ··································· 49
任务#6 超级跳 ··································· 51
减法 ························································· 52
任务#7 改变你脚下的砖块 ·············· 52
在参数中使用数学符号 ······················· 53
任务#8 快速搭建 ······························· 55
乘法 ························································· 58
除法 ························································· 58
任务#9 壮观的尖塔 ··························· 58
指数 ························································ 60
括号和运算顺序 ···································· 61
方便的数学技巧 ···································· 61
缩略符 ················································ 61
用随机数字玩游戏 ···························· 62
任务#10 跳到一个新的地方 ·········· 63
你学到了什么 ········································ 64
第4章 利用字符串聊天 ················65
什么是字符串 ········································ 66
print()函数 ·············································· 66
任务#11 你好,Minecraft世界 ······ 67
input()函数 ············································· 68
任务#12 写你自己的聊天信息 ······ 69
连接字符串 ············································ 71
将数字转换为字符串 ························ 71
连接整数与浮点数 ···························· 72
任务#13 在聊天中加入用户名 ······ 73
使用int()将字符串转变为整数 ············· 74
任务#14 使用input命令建立砖块 ··· 74
从异常中恢复 ········································ 76
任务#15 数字通行 ·························· 77
任务#16 神奇的记录仪 ·················· 79
你学到了什么 ········································ 81
第5章 通过布尔运算判断真假 ···82
布尔运算基础 ········································ 83
任务#17 停止打碎砖块 ·················· 83
关联布尔运算 ········································ 84
比较符号 ················································ 85
等于 ···················································· 85
任务#18 我在游泳吗 ······················ 86
不等于 ················································ 87
任务#19 我没有站在空气中吗 ······ 88
大于和小于 ········································ 89
大于或等于和小于或等于 ················ 90
任务#20 我在地面上吗 ·················· 91
任务#21 我在家附近吗 ·················· 92
逻辑算符 ················································ 93
and ······················································ 94
任务#22 我是否完全在水下 ·········· 95
or ························································· 96
任务#23 我在树上吗 ······················ 96
not ······················································· 97
任务#24 这个砖块不是西瓜吗 ······ 98
逻辑算符的顺序 ································ 99
我的数字在其他两个数之间吗 ······ 100
任务#25 我在房子里吗 ················ 100
你学到了什么 ······································ 102
第6章 用if语句做小游戏 ···········103
使用if语句 ············································ 104
任务#26 炸出一个坑 ···················· 105
else语句 ············································ 107
任务#27 是否阻止打碎砖块 ········ 108
elif语句 ············································· 109
任务#28 提供礼物 ························ 111
连接elif语句 ····································· 112
任务#29 传送到正确的位置 ········ 113
嵌套if语句 ········································ 115
任务#30 开一个秘密通道 ············ 115
用if语句来检测一个值的范围 ············ 117
任务#31 限制传送位置 ················ 118
布尔运算和if语句 ································ 120
任务#32 洗澡 ································ 121
你学到了什么 ······································ 123
第7 章 用w h i l e循环制作舞会
和花卉游行 ·······················124
简单的while循环 ································· 124
任务#33 随机的传送旅程 ············ 126
用变量count控制循环 ························· 128
任务#34 水的诅咒 ························ 129
无限while循环 ································· 130
任务#35 花朵小径 ························ 131
奇特的条件 ·········································· 132
任务#36 潜水比赛 ························ 133
布尔运算符和while循环 ················· 135
在while循环中检测值的范围 ········· 136
任务#37 做一个舞池 ···················· 136
嵌套if语句和while循环 ··················· 138
任务#38 点石成金 ························ 139
用break语句来结束while循环 ············ 140
任务#39 用循环创建永久聊天 ···· 140
while-else语句 ·································· 142
任务#40 热和冷 ···························· 142
你学到了什么 ······································ 145
第8章 函数赐予你超能力 ·········146
定义你自己的函数 ······························ 147
调用函数 ·········································· 147
带有参数的函数 ······························ 148
任务#41 创建一片森林 ················ 149
重构程序 ·········································· 151
任务#42 重构 ································ 152
用文档字符串做注释 ······················ 153
参数中的换行符 ······························ 154
函数返回值 ······································ 154
任务#43 砖块ID提醒器 ················ 156
在函数中使用if语句和while循环 ······· 157
if语句 ················································ 158
任务#44 羊毛颜色助手 ················ 159
while循环 ········································· 160
任务#45 到处摆放砖块 ················ 161
全局变量和局部变量 ·························· 163
任务#46 移动的砖块 ···················· 164
你学到了什么 ······································ 166
第9章 用表和字典击打东西 ····167
使用表 ·················································· 168
使用一个表项目 ······························ 168
改变表项目 ······································ 169
任务#47 高和低 ···························· 169
操作表 ·················································· 171
添加项目 ·········································· 171
插入项目 ·········································· 172
删除项目 ·········································· 173
任务#48 进度条 ···························· 173
把字符串看作表 ·································· 175
元组 ······················································ 175
用元组来设置变量 ·························· 176
任务#49 滑行 ································ 177
返回元组 ·········································· 178
表的其他有用的特征 ·························· 179
表的长度 ·········································· 179
任务#50 击打砖块 ························ 180
随机选取一个项目 ·························· 182
任务#51 随机砖块 ························ 183
复制表 ·············································· 184
项目和if语句 ···································· 185
任务#52 夜视剑 ···························· 186
字典 ······················································ 188
定义一个字典 ·································· 188
使用字典中的项目 ·························· 189
任务#53 观光指南 ························ 190
在字典中改变或添加项目 ·············· 191
在字典中删除项目 ·························· 192
任务#54 击打砖块的分数 ············ 192
你学到了什么 ······································ 194
第10章 Minecraft的for循环
魔法 ··································195
一个简单的for循环······························ 195
任务#55 魔杖 ································ 196
函数range() ······································ 198
任务#56 魔法楼梯 ························ 199
用range()玩耍 ·································· 200
其他表函数 ·········································· 201
任务#57 柱子 ································ 202
任务#58 金字塔 ···························· 204
循环一个字典 ······································ 205
任务#59 记分牌 ···························· 206
for-else循环 ·········································· 207
退出for-else循环 ······························ 207
任务#60 钻石勘探者 ···················· 208
嵌套for循环和多维表·························· 209
考虑两个维度 ·································· 209
使用二维表中的值 ·························· 213
任务#61 像素艺术 ························ 214
用循环生成二维表 ·························· 216
任务#62 风化剥蚀的墙 ················ 217
考虑三个维度 ·································· 218
输出三维表 ······································ 219
使用三维表中的值 ·························· 223
任务#63 复制一座建筑 ················ 225
学到了什么 ·········································· 229
第11章 从文件及模块中保存
和读取建筑 ··················231
使用文件 ·············································· 232
打开一个文件 ·································· 232
目录 XI
写入并保存一个文件 ······················ 233
读取一个文件 ·································· 234
读取文件中的一行 ·························· 235
任务#64 提醒单 ···························· 236
第一部分 写提醒单 ······················ 236
第二部分 展示提醒单 ·················· 237
使用模块 ·············································· 238
使用pickle模块 ································ 239
导入pickle ········································ 239
使用from语句导入一个函数 ·········· 241
使用*来调用全部的函数 ················ 242
给模块起个“外号” ······················ 242
任务#65 保存一座建筑 ················ 243
第一部分 保存建筑 ······················ 243
第二部分 读取建筑 ······················ 246
使用shelve模块存储大量数据 ············ 248
使用shelve打开一个文件 ················ 248
使用shelve添加、修改和
访问项目 ······································ 248
任务#66 存储一系列建筑 ············ 249
第一部分 将一座建筑保存到
收藏夹中 ······································ 250
第二部分 从收藏夹中读取
一座建筑 ······································ 250
使用pip安装新的模块 ························· 253
在Windows中使用pip ······················ 254
在Mac或者树莓派中使用pip ·········· 255
使用pip安装的模块:Flask ················ 255
任务#67 位置网站 ························ 257
你学到了什么 ······································ 257
第12章 用面向对象编程将程序
变优雅 ·······························259
面向对象编程基础 ······························ 260
创建一个类 ·········································· 260
创建一个对象 ·································· 261
获取对象属性 ·································· 262
任务#68 位置对象 ························ 262
理解方法 ·············································· 264
任务#69 幽灵屋 ···························· 266
方法的返回值 ······································ 268
任务#70 幽灵城堡 ························ 269
创造多个对象 ······································ 271
任务#71 幽灵城 ···························· 272
类的属性 ·············································· 273
认识和了解继承 ·································· 275
继承一个类 ······································ 276
在子类中加入新方法 ······················ 277
任务#72 幽灵酒店 ························ 278
重写方法和属性 ·································· 280
任务#73 幽灵树 ···························· 283
你学到了什么 ······································ 284
· · · · · · (
收起)