# Scratch 06: 狗狗吃鑽石 ###### tags: `捲耳貓兒童程式創作學苑`, `Scratch` 📅 Update date: 2024-02-25 ## 1. 選擇內建主角: Puppy, Crystal  ## 2. 製作 Button3  ## 3. 製作 Button2 首先,我們需要設計【開始遊戲】的字卡  接著,我們需要設計【遊戲結束,按我重新開始】的字卡  ## 4. Puppy / 程式碼 ### 4-1. 碰到磚塊(button3)扣 1 分,碰到鑽石(crystal)加 1 分  ### 4-2. 控制小狗左右移動 * 按下 a 鍵 或 按下方向鍵左鍵 或 滑鼠點擊遊戲視窗左邊 ➡️ 向左移動 * 按下 d 鍵 或 按下方向鍵右鍵 或 滑鼠點擊遊戲視窗右邊 ➡️ 向右移動  ## 5. Button2 (字卡) / 程式碼 用【broadcast 重新設定磚塊、磚塊掉落、鑽石掉落】 代表:發送三個通知 給【Crystal (鑽石)】和【Button3 (磚塊)】 (要求他們接收到通知時,做某些事情)  ## 6. Crystal (鑽石) / 程式碼 當鑽石收到【重新設定磚塊】通知時 移動到(go to)指定的位置 並顯示(show)  當鑽石收到【磚塊掉落】通知時 重複以下的事情,直到倒數秒數為0 顯示(鑽石) 移動到指定位置(➡️ **隨機的**左右位置 x,固定的上下位置 y) 重複【往下掉落】(change y by -10),直到碰到(遊戲視窗)邊緣 隱藏(鑽石) 隱藏(鑽石)  ## 7. Button3 (磚塊) / 程式碼 與 [6. Crystal (鑽石)](https://hackmd.io/Ncm5V4fiQKykASIoLo0OnA?view#6-Crystal-%E9%91%BD%E7%9F%B3--%E7%A8%8B%E5%BC%8F%E7%A2%BC) 的程式碼完全相同 可以直接把【Crystal (鑽石)】的程式積木搬移(複製一份)到【Button3 (磚塊)】這邊  ## 8. 結果展示(2 倍速) 
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up