這個網誌中的熱門文章
劉庭妤bro code貪吃蛇
程式碼貼上要用撰寫模式 from tkinter import * import random GAME_WIDTH , GAME_HEIGHT = 1000 , 800 SPEED = 1000 SPACE_SIZE , BODY_PARTS = 50 , 3 #左邊變數 assigning value SNAKE_COLOR = "#00FF00" FOOD_COLOR = "white" BACKGROUND_COLOR = "#000000" class Snake : def __init__ ( self ): self . body_size = BODY_PARTS self . coordinates = [] self . squares = [] for i in range ( 0 , BODY_PARTS ): self . coordinates . append ([ 0 , 0 ]) for x , y in self . coordinates : square = canvas . create_rectangle ( x , y , x + SPACE_SIZE , y + SPACE_SIZE , fill = SNAKE_COLOR , tag = "snake" ) self . squares . append ( square ) class Food : def __init__ ( self ): x ...
劉庭妤bro code貪吃蛇import module教育學習網
https://steam.oxxostudio.tw/category/python/basic/import.html 匯入模組 import Module 在 Python 裡,「模組」是一個存在於任意程式碼中的檔案,任何 Python 的程式碼也都可以當作模組使用,透過 import 陳述式,可以引用其他模組的程式碼,進一步使用其他模組的程式和變數,讓程式更精簡更好維護。 改寫自bro code貪吃蛇 from tkinter import * import random GAME_WIDTH , GAME_HEIGHT = 1000 , 800 SPEED = 1000 SPACE_SIZE , BODY_PARTS = 50 , 3 #左邊變數 assigning value SNAKE_COLOR = "#00FF00" FOOD_COLOR = "white" BACKGROUND_COLOR = "#000000" class Snake : def __init__ ( self ): self . body_size = BODY_PARTS self . coordinates = [] self . squares = [] for i in range ( 0 , BODY_PARTS ): self . coordinates . append ([ 0 , 0 ]) for x , y in self . coordinates : square = canvas . create_rectangle ( x , y , x + SPACE_SIZE , y + SPACE_SI...
截圖空白或黑色太多,沒有呈現重點。
回覆刪除