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...

Python 遊戲設計:軟體安裝 ( Python Game Development: Software Installation )


想要用Python來開發遊戲的話,Pygame是其中一種選擇。

1. 從官網https://www.python.org/downloads/,下載最新版的Python。


2. 從http://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame,下載pygame‑1.9.2rc1‑cp35‑cp35m‑win32.whl。

3. 將pygame‑1.9.2rc1‑cp35‑cp35m‑win32.whl複製到 C:\Users\YOUR_USER_ACCOUNT\AppData\Local\Programs\Python\Python35-32\Scripts\ 資料夾下,注意其中的YOUR_USER_ACCOUNT為你的Windows 10使用者名稱。


4. 在C:\Users\YOUR_USER_ACCOUNT\AppData\Local\Programs\Python\Python35-32\Scripts\ 資料夾下,按住鍵盤上的Shift同時按下滑鼠右鍵,選擇「在此處開啟命令視窗」,並輸入pip3 install pygame‑1.9.2rc1‑cp35‑cp35m‑win32.whl指令。


5. 開啟IDLE測試下面的Pygame的範例:
import pygame
import pygame.examples.aliens as game
game.main()



6. 若出現下面畫面就代表安裝成功了。


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

留言

這個網誌中的熱門文章