Skip to content

Instantly share code, notes, and snippets.

@41023137
41023137 / hw 1
Last active October 17, 2021 11:21
1.將左右碰撞移動的紅色方塊, 改為先移動到水平畫面中心點位置後, 接著上下碰撞移動。
from browser import html
from browser import document as doc
import browser.timer
canvas = html.CANVAS(width = 400, height = 100)
canvas.id = "game-board"
brython_div = doc["brython_div"]
brython_div <= canvas
ctx = canvas.getContext("2d")
px = 0
@41023137
41023137 / hw 2
Last active October 17, 2021 11:22
2.讓使用者可以利用按鈕啟動或中斷紅色方塊上下碰撞移動
from browser import html
from browser import document as doc
from browser import timer
canvas = html.CANVAS(width = 400, height = 100)
canvas.id = "game-board"
brython_div = doc["brython_div"]
brython_div <= canvas
brython_div <= html.BUTTON("啟動", id="power")
ctx = canvas.getContext("2d")
@41023137
41023137 / hw 3
Created October 17, 2021 15:58
3.英文打字(35min.28s)
Every gist is a Git repository, which means that it can be forked and cloned. If you are signed in to GitHub when you create a gist, the gist will be associated with your account and you will see it in your list of gists when you navigate to your gist home page.
Gist can be public or secret.Public gist show up in Discover, where people can browse new gists as they're created.They're also searchable, so you can use them if you 'd like other people to find and see your work.
Secret gists don't show up in Discover and are not searchable.Secret gists aren't private. If you send the URL of secret gist to a friend, they'll be able to see it.However, if someone you don't know discovers the URL, they'll also be able to see your gist. If you need to keep your code away from prying eyes, you may want to create a private respository instead.
After creating a gist you cannot convert it from public to secret.
You'll receive a notification when:
You are the author of a gist.
Someone mentions you in a gist.
You subscribe to
@41023137
41023137 / hw 4
Last active October 19, 2021 19:53
中文打字(10min.40s)
Gist是Github的一個子服務,且任何人都可以使用這個服務,不論你是否擁有Github帳號。
以開發者的角度來說,最基本的功能就是可以分享片段的原始碼。
有別於Github的Respository,Gist可以只分享專案中的某一個小檔案中的程式碼,
且擁有私人的選項,讓別人不會搜尋到你的Gist。
在Github的Respository設定Private是要付費的,但在Gist是不需要的。
除此之外Gist還有許多用處,包括可以直接執行我們就來一一介紹吧!
10:40
@41023137
41023137 / w13
Last active December 16, 2021 08:18
import random
r=10
for o in range(1,r+1):
l=random.randint(1,18)
i=random.randint(1,18)
print("第"+str(o)+"個紅色方塊座標為("+str(l)+","+str(i)+")")
# source from https://hawstein.com/2013/04/15/snake-ai/
# snake head is black
# add lightgrey grid
# 從 browser 導入 document 並設為 doc
from browser import document as doc
# 使用者可以透過 window 當作介面使用其他 Javascript 功能
from browser import html, window
# 用於定時執行特定函式
import browser.timer
# 導入數學模組
# 從 browser 導入 document 並設為 doc
from browser import document as doc
# 使用者可以透過 window 當作介面使用其他 Javascript 功能
from browser import html, window
# 用於定時執行特定函式
#import browser.timer
from browser import timer
# 導入數學模組
import math
# 導入亂數模組
@41023137
41023137 / w11_hw_1
Last active November 26, 2024 09:33
用星號繪製圓形圖案
import math
# 圓的半徑
r = 5
# 圓心座標
cx, cy = 4.5, 4.5
# 10x10 的區域
for y in range(10):
for x in range(10):
from browser import html
from browser import document as doc
import math
# 利用 html 建立 canvas 超文件物件
canvas = html.CANVAS(width=400, height=400)
brython_div = doc["brython_div1"]
brython_div <= canvas
# 每一格的 pixel 數
@41023137
41023137 / w12
Created November 27, 2024 03:18
w12
n = 11
space = '_'
center = n//2
#print(center)
for y in range(n):
for x in range(n):
print("(", x, ", ", y, ")", sep='')