目錄
致謝....................................................................................................V
本書介紹...........................................................................................VII
第1章 準備開始.................................................................................1
什麼是 Scratch ..................................................................................2
Scratch 編程環境 ..............................................................................3
試一試 1-1 ......................................................................................3
舞台 .........................................................................................................4
角色列表 .................................................................................................5
試一試 1-2 ......................................................................................5
試一試 1-3 ......................................................................................6
積木區 .....................................................................................................7
試一試 1-4 ......................................................................................8
腳本區 .....................................................................................................8
試一試 1-5 ......................................................................................9
試一試 1-6 ....................................................................................10
造型標籤頁 ...........................................................................................10
聲音標籤頁 ...........................................................................................11
試一試 1-7 ....................................................................................11
試一試1-8 ....................................................................................12
背景標籤頁 ...........................................................................................12
角色信息 ...............................................................................................13
試一試 1-9 ....................................................................................13
工具列 ...................................................................................................14
繪圖編輯器 ......................................................................................15
設定圖像的中心 ...................................................................................15
試一試 1-10 ..................................................................................16
設定透明色 ...........................................................................................16
製作第一個 Scratch 遊戲 .................................................................17
第一步:準備背景 ...............................................................................18
第二步:加入反彈板和小球 ...............................................................18
第三步:讓角色動起來 .......................................................................19
試一試 1-11 ..................................................................................20
第四步:添加聲音更有趣 ...................................................................21
Scratch 積木一覽 ............................................................................22
算術運算符和函式 ...........................................................................23
算術運算符 ...........................................................................................23
隨機數 ...................................................................................................24
數學函式 ...............................................................................................25
本章小結 ..........................................................................................25
練習題 .............................................................................................25
第2章 動作和繪圖...........................................................................29
使用動作模組的積木 ........................................................................29
絕對動作 ...............................................................................................30
試一試 2-1 ....................................................................................31
相對動作 ...............................................................................................32
試一試 2-2 ....................................................................................34
其他動作積木 .......................................................................................34
畫筆模組和一個簡單的畫圖程式 ......................................................35
試一試 2-3 ....................................................................................36
神奇的重複執行 ...............................................................................37
試一試 2-4 ....................................................................................37
旋轉的正方形 .......................................................................................39
試一試 2-5 ....................................................................................39
試一試 2-6 ....................................................................................40
圖章積木 ...............................................................................................40
Scratch 項目 ....................................................................................41
貓咪收集錢袋 .......................................................................................41
試一試 2-7 ....................................................................................41
接蘋果遊戲 ...........................................................................................45
關於被克隆的角色 ...........................................................................48
本章小結 ..........................................................................................49
練習題 .............................................................................................50
第3章 外觀和聲音...........................................................................53
外觀模組 ..........................................................................................54
切換造型創建動畫 ...............................................................................54
試一試 3-1 ....................................................................................55
試一試 3-2 ....................................................................................56
讓角色思考並說話 ...............................................................................56
圖形特效 ...............................................................................................57
角色大小和可視狀態 ...........................................................................57
試一試 3-3 ....................................................................................58
角色間的圖層 .......................................................................................58
聲音模組 ..........................................................................................59
播放音頻檔案 .......................................................................................59
試一試 3-4 ....................................................................................59
彈奏鼓聲和其他聲音 ...........................................................................60
創作音樂 ...............................................................................................61
試一試 3-5 ....................................................................................62
試一試 3-6 ....................................................................................62
控制音量 ...............................................................................................62
設計 .......................................................................................................62
Scratch 項目 ....................................................................................63
在舞台上跳舞 .......................................................................................63
煙花效果 ...............................................................................................67
本章小結 ..........................................................................................69
練習題 .............................................................................................69
第4章 過程......................................................................................73
訊息的廣播和接收 ...........................................................................74
傳送訊息和接收訊息 ...........................................................................75
使用廣播機制協調多個角色 ...............................................................76
將大型程式分而治之 ........................................................................78
使用廣播模擬過程 ...............................................................................80
創建自己的積木塊 ...............................................................................81
給積木塊添加參數 ...............................................................................83
試一試 4-1 ....................................................................................87
過程的嵌套 ...........................................................................................88
試一試 4-2 ....................................................................................90
分析問題的思維方式 ........................................................................90
自頂向下分析 .......................................................................................91
試一試 4-3 ....................................................................................93
自底向上分析 .......................................................................................94
本章小結 ..........................................................................................96
練習題 .............................................................................................96
第5章 變數......................................................................................99
Scratch 的數據類型 .......................................................................100
參數凹槽與積木形狀 .........................................................................100
數據類型的自動轉換 .........................................................................101
變數詳解 ........................................................................................102
什麼是變數? .....................................................................................102
創建並使用變數 .................................................................................105
試一試 5-1 ..................................................................................108
變數的作用範圍 .................................................................................108
修改變數的值 ......................................................................................111
繪製蜘蛛網 .........................................................................................112
繪製風車 .............................................................................................112
克隆體中的變數 .................................................................................113
試一試 5-2 ..................................................................................113
變數值顯示器 .................................................................................116
在程式中使用變數值顯示器 ............................................................117
歐姆定律模擬實驗 .............................................................................117
串聯電路模擬實驗 .............................................................................119
試一試 5-3 ..................................................................................119
計算球體體積和表面積 ....................................................................121
試一試 5-4 ..................................................................................121
繪製玫瑰花瓣 .....................................................................................123
試一試 5-5 ..................................................................................123
葵花籽分布模型 .................................................................................125
試一試 5-6 ..................................................................................125
獲得用戶輸入 ................................................................................127
讀取數字 .............................................................................................127
試一試 5-7 ..................................................................................127
讀取字元 .............................................................................................128
執行算術運算 .....................................................................................128
本章小結 ........................................................................................129
練習題 ...........................................................................................129
第6章 用邏輯做決定......................................................................133
比較操作符 ....................................................................................134
布爾表達式的求值 .............................................................................136
比較字元和字元串 .............................................................................136
分支結構 ........................................................................................138
如果…那么積木塊 .............................................................................138
將變數作為標誌 .................................................................................139
如果…那么否則積木 .........................................................................141
嵌套分支結構 .....................................................................................142
選單驅動程式 .....................................................................................143
邏輯運算符 ....................................................................................144
且操作符(and) .................................................................................145
或操作符(or) ...................................................................................146
不成立操作符(not) ..........................................................................147
使用邏輯運算符檢查數值範圍 .........................................................148
Scratch 項目 ..................................................................................150
坐標猜測遊戲 .....................................................................................150
試一試 6-1 ..................................................................................152
三角形分類遊戲 .................................................................................152
試一試 6-2 ..................................................................................156
貓咪巡線 .............................................................................................156
試一試 6-3 ..................................................................................157
求解直線方程 .....................................................................................158
試一試 6-4 ..................................................................................162
其他應用程式 .....................................................................................162
本章小結 ........................................................................................162
練習題 ...........................................................................................162
第7章 深入循環.............................................................................165
循環結構 ........................................................................................166
重複執行直到積木 .............................................................................166
試一試 7-1 ..................................................................................168
將重複執行和如果…那么結合 .........................................................168
試一試 7-2 ..................................................................................169
停止積木 ........................................................................................170
試一試 7-3 ..................................................................................171
結束過程調用 .....................................................................................172
驗證用戶輸入 .....................................................................................173
循環計數器 ....................................................................................174
密碼驗證 .............................................................................................174
靈活的循環計數 .................................................................................175
試一試 7-4 ..................................................................................175
循環的嵌套 ....................................................................................177
遞歸:調用自身的過程 ..................................................................179
試一試 7-5 ..................................................................................179
Scratch 項目 ..................................................................................181
模擬時鐘 .............................................................................................181
試一試 7-6 ..................................................................................181
小鳥射擊遊戲 .....................................................................................183
試一試 7-7 ..................................................................................183
自由落體實驗 .....................................................................................187
試一試 7-8 ..................................................................................187
試一試 7-9 ..................................................................................190
拋體運動模擬器 .................................................................................190
其他應用程式 .....................................................................................193
本章小結 ........................................................................................193
試一試 7-10 ................................................................................193
練習題 ...........................................................................................194
第8章 字元串處理.........................................................................197
字元串數據類型 .............................................................................198
特殊字元統計 .....................................................................................198
字元比較 .............................................................................................199
字元串操作示例 .............................................................................201
Igpay Atinlay .......................................................................................201
試一試 8-1 ..................................................................................201
單詞修正 .............................................................................................203
試一試 8-2 ..................................................................................203
解密遊戲 .............................................................................................205
試一試 8-3 ..................................................................................205
Scratch 項目 ..................................................................................208
射擊遊戲 .............................................................................................208
二進制數到十進制數轉換 .................................................................211
試一試 8-4 ..................................................................................211
試一試 8-5 ..................................................................................212
試一試 8-6 ..................................................................................214
劊子手遊戲 .........................................................................................214
試一試 8-7 ..................................................................................219
分數運算教學工具 .............................................................................220
試一試 8-8 ..................................................................................224
本章小結 ........................................................................................225
練習題 ...........................................................................................225
第9章 鍊表....................................................................................227
Scratch 的鍊表 ..............................................................................228
創建鍊表 .............................................................................................228
試一試 9-1 ..................................................................................230
鍊表的積木 .........................................................................................231
添加和刪除 .........................................................................................231
插入和替換 .........................................................................................231
獲得鍊表中的變數 .............................................................................232
包含積木 .............................................................................................233
邊界檢查 .............................................................................................233
試一試 9-2 ..................................................................................233
動態鍊表 ........................................................................................234
向鍊表填充用戶輸入 .........................................................................234
繪製柱狀圖 .........................................................................................236
數字鍊表 ........................................................................................239
尋找最值 .............................................................................................239
試一試 9-3 ..................................................................................239
試一試 9-4 ..................................................................................240
計算平均數 .........................................................................................240
搜尋和排序 ....................................................................................241
線性搜尋 .............................................................................................241
試一試 9-5 ..................................................................................241
頻數統計 .............................................................................................242
試一試 9-6 ..................................................................................244
冒泡排序 .............................................................................................244
試一試 9-7 ..................................................................................246
尋找中位數 .........................................................................................247
Scratch 項目 ..................................................................................248
我是詩人 .............................................................................................248
四邊形分類遊戲 .................................................................................249
試一試 9-8 ..................................................................................249
試一試 9-9 ..................................................................................251
數學魔法師 .........................................................................................252
花的結構測驗 .....................................................................................255
試一試 9-10 ................................................................................255
其他應用程式 .....................................................................................257
試一試 9-11 ................................................................................257
本章小結 ........................................................................................258
練習題 ...........................................................................................258
附錄A 分享與合作..........................................................................261
創建 Scratch 賬號 .........................................................................261
使用書包功能 ................................................................................264
創建項目 ........................................................................................266
創建新的項目 .....................................................................................266
項目再創作 .........................................................................................267
項目頁 .................................................................................................268
分享項目 .............................................................................................268