Code Maintenance & Programming Rules

 This guide outlines essential best practices spanning code style, architectural design, debugging, testing, performance, and portability—all aimed at reducing the long-term cognitive load of code maintenance. 🎨 1. Style Code is written for humans to read, and only incidentally for computers to execute. Variable Naming : Use descriptive names for global variables, and short names for local variables. Precision and Consistency : Use active names for functions (e.g., calculateTotal ). Above all, keep your coding style consistent throughout the project. Structure & Expressions : Use a consistent indentation and brace ( {} ) style to show program structure visually. Use the natural form for expressions. Use parentheses to make the semantics unambiguous. Break up overly complex expressions to keep them clear. Side Effects & Macros : Beware of functions with side effects. Avoid function-like macros; if unavoidable, parenthesize the macro body and arguments carefully. Magic Numbe...

Scratch 3 遊戲:貓捉老鼠 (Scratch 3 Game: Cat Catch Mouse )

若您覺得文章寫得不錯,請點選文章上的廣告,來支持小編,謝謝。

「貓愛抓老鼠」是天性嗎?!真的是天性嗎?!不管是不是深植在貓的DNA裡頭,總之要跟可愛的Mickey Mouse說抱歉啦!你要被Hello Kitty追著跑囉!

示範影片:


製作步驟:(底下程式積木圖形僅供參考,設計方式不是只有一種。
1. 開啟Scratch,新增兩個變數:分數時間




2. 新增老鼠角色。


3. 在貓咪角色下,設計底下的程式積木。
貓咪隨著滑鼠移動程式積木:

計時程式積木:



4. 在老鼠角色下,設計底下的程式積木。


Scratch範例程式:https://scratch.mit.edu/projects/122093858/

這個網誌中的熱門文章