發表文章
朱冠宇Bro Code貪吃蛇python snake game
- 取得連結
- X
- 以電子郵件傳送
- 其他應用程式
from tkinter import * import random GAME_WIDTH = 1000 GAME_HEIGHT = 700 SPEED = 500 SPACE_SIZE = 50 BODY_PARTS = 3 SNAKE_COLOR = "#00FF00" FOOD_COLOR = "#FF0000" 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 = random . randint ( 0 , ( GA...
朱冠宇eval=evaluate函數calculator美國男生印度女生.調色板
- 取得連結
- X
- 以電子郵件傳送
- 其他應用程式
w3schools eval() 美國男生bro code from tkinter import * def button_press(num): global equation_text equation_text = equation_text + str(num) equation_label.set(equation_text) def equals(): global equation_text try: total = str(eval(equation_text)) equation_label.set(total) equation_text = total except SyntaxError: equation_label.set("syntax error") equation_text = "" except ZeroDivisionError: equation_label.set("arithmetic error") equation_text = "" def clear(): global equation_text equation_label.set("") equation_text = "" window = Tk() window.title("劉任昌計算機calculator") window.geometry("500x500") equation_text = "" equation_label = StringVar() label = Label(window, textvariable=equation_label, font=('consolas',20), bg="white", width=24, height=2) label.pack() frame = Frame(w...
朱冠宇tkinter繪圖套件time時間sleep方法
- 取得連結
- X
- 以電子郵件傳送
- 其他應用程式
程式碼 from tkinter import * #下載程式碼,從tkinter輸入所有函式 import time x = [ ' \U0001F600 ' , ' \U0001F601 ' , ' \U0001F602 ' , ' \U0001F615 ' , ' \U0001F622 ' ] #定義一個串列 y = [] #追蹤特定視窗用途,尚未使用 for i in range ( 5 ): window = Tk () #建構視窗,名為window建構一個房子 window . title ( '朱冠宇python第 %d 視窗' % ( i + 1 )) window . geometry ( '400x400+ %d +100' % ( 400 * i )) b1 = Label ( window , text = x [ i ], font = 'Arial 250 bold' ). pack () time . sleep ( 1 ) window . update () y . append ( window ) #追蹤特定視窗用途,尚未使用 window . mainloop ()
朱冠宇python期中考javascript按鈕button事件onchange
- 取得連結
- X
- 以電子郵件傳送
- 其他應用程式
js程式碼 const space = ' ' , slash = '/' , backslash = ' \\ ' , cr = ' \n ' ; function row1 ( k , m ){ for ( let i = 0 ; i < k ; i ++ ){ for ( let ii = 0 ; ii < m ; ii ++ ){ for ( let j = 0 ; j < k - i - 1 ; j ++ ) out += space ; out += slash ; for ( let j = 0 ; j < 2 * i ; j ++ ) out += space ; out += backslash ; for ( let j = 0 ; j < k - i - 1 ; j ++ ) out += space ;}; out += cr ;};}; function row2 ( k , m ){ for ( let i = 0 ; i < k ; i ++ ){ for ( let ii = 0 ; ii < m ; ii ++ ){ ...