22 changed files with 54204 additions and 0 deletions
@ -0,0 +1,5 @@ |
|||||||
|
index.html linguist-generated=true |
||||||
|
assets/index.html linguist-generated=true |
||||||
|
assets/js/loader.js linguist-generated=true |
||||||
|
assets/js/binary.js linguist-generated=true |
||||||
|
assets/version.txt linguist-generated=true |
||||||
@ -0,0 +1,37 @@ |
|||||||
|
name: Check pxt.json |
||||||
|
|
||||||
|
on: |
||||||
|
push: |
||||||
|
branches: |
||||||
|
- 'master' |
||||||
|
- 'main' |
||||||
|
|
||||||
|
jobs: |
||||||
|
check-cfg: |
||||||
|
runs-on: ubuntu-latest |
||||||
|
strategy: |
||||||
|
matrix: |
||||||
|
node-version: [14.x] |
||||||
|
steps: |
||||||
|
- uses: actions/checkout@v2 |
||||||
|
- name: Use Node.js ${{ matrix.node-version }} |
||||||
|
uses: actions/setup-node@v1 |
||||||
|
with: |
||||||
|
node-version: ${{ matrix.node-version }} |
||||||
|
- name: npm install |
||||||
|
run: | |
||||||
|
npm install -g pxt |
||||||
|
pxt target arcade |
||||||
|
- name: Checkout current state |
||||||
|
run: | |
||||||
|
git checkout -- . |
||||||
|
git clean -fd |
||||||
|
- name: Fix files listed in config if necessary |
||||||
|
run: pxt checkpkgcfg |
||||||
|
- name: Create Pull Request |
||||||
|
uses: peter-evans/create-pull-request@v3 |
||||||
|
continue-on-error: true |
||||||
|
with: |
||||||
|
title: 'Removing missing files from pxt.json' |
||||||
|
commit-message: 'Removing missing files from pxt.json' |
||||||
|
delete-branch: true |
||||||
@ -0,0 +1,63 @@ |
|||||||
|
name: MakeCode Arcade Release |
||||||
|
|
||||||
|
on: |
||||||
|
release: |
||||||
|
types: |
||||||
|
- created |
||||||
|
jobs: |
||||||
|
build: |
||||||
|
|
||||||
|
runs-on: ubuntu-latest |
||||||
|
|
||||||
|
strategy: |
||||||
|
matrix: |
||||||
|
node-version: [8.x] |
||||||
|
|
||||||
|
steps: |
||||||
|
- uses: actions/checkout@v1 |
||||||
|
- name: install node.js ${{ matrix.node-version }} |
||||||
|
uses: actions/setup-node@v1 |
||||||
|
with: |
||||||
|
node-version: ${{ matrix.node-version }} |
||||||
|
- name: install makecode |
||||||
|
run: | |
||||||
|
npm install -g pxt |
||||||
|
pxt target arcade |
||||||
|
- name: build js |
||||||
|
run: | |
||||||
|
pxt clean |
||||||
|
pxt install |
||||||
|
pxt build --cloud |
||||||
|
- name: build D51 |
||||||
|
continue-on-error: true |
||||||
|
run: | |
||||||
|
pxt clean |
||||||
|
pxt install --hw samd51 |
||||||
|
pxt build --hw samd51 --cloud |
||||||
|
cp ./built/binary.uf2 binary-d51.uf2 |
||||||
|
- name: build F4 |
||||||
|
continue-on-error: true |
||||||
|
run: | |
||||||
|
pxt clean |
||||||
|
pxt install --hw stm32f401 |
||||||
|
pxt build --hw stm32f401 --cloud |
||||||
|
cp ./built/binary.uf2 binary-f4.uf2 |
||||||
|
- name: build P0 |
||||||
|
continue-on-error: true |
||||||
|
run: | |
||||||
|
pxt clean |
||||||
|
pxt install --hw rpi |
||||||
|
pxt build --hw rpi --cloud |
||||||
|
cp ./built/binary.uf2 binary-p0.uf2 |
||||||
|
- name: bundle all |
||||||
|
run: | |
||||||
|
cat binary-*.uf2 > built/arcade.uf2 |
||||||
|
- name: upload bundled |
||||||
|
uses: actions/upload-release-asset@v1.0.1 |
||||||
|
env: |
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
||||||
|
with: |
||||||
|
upload_url: ${{ github.event.release.upload_url }} |
||||||
|
asset_path: ./built/arcade.uf2 |
||||||
|
asset_name: arcade.uf2 |
||||||
|
asset_content_type: application/octet-stream |
||||||
@ -0,0 +1,29 @@ |
|||||||
|
name: MakeCode |
||||||
|
|
||||||
|
on: [push] |
||||||
|
|
||||||
|
jobs: |
||||||
|
build: |
||||||
|
|
||||||
|
runs-on: ubuntu-latest |
||||||
|
|
||||||
|
strategy: |
||||||
|
matrix: |
||||||
|
node-version: [14.x] |
||||||
|
|
||||||
|
steps: |
||||||
|
- uses: actions/checkout@v1 |
||||||
|
- name: Use Node.js ${{ matrix.node-version }} |
||||||
|
uses: actions/setup-node@v1 |
||||||
|
with: |
||||||
|
node-version: ${{ matrix.node-version }} |
||||||
|
- name: npm install |
||||||
|
run: | |
||||||
|
npm install -g pxt |
||||||
|
pxt target arcade |
||||||
|
- name: build |
||||||
|
run: | |
||||||
|
pxt install |
||||||
|
pxt build --cloud |
||||||
|
env: |
||||||
|
CI: true |
||||||
@ -0,0 +1,23 @@ |
|||||||
|
{ |
||||||
|
"editor.formatOnType": true, |
||||||
|
"files.autoSave": "afterDelay", |
||||||
|
"files.watcherExclude": { |
||||||
|
"**/.git/objects/**": true, |
||||||
|
"**/built/**": true, |
||||||
|
"**/node_modules/**": true, |
||||||
|
"**/yotta_modules/**": true, |
||||||
|
"**/yotta_targets": true, |
||||||
|
"**/pxt_modules/**": true |
||||||
|
}, |
||||||
|
"files.associations": { |
||||||
|
"*.blocks": "html", |
||||||
|
"*.jres": "json" |
||||||
|
}, |
||||||
|
"search.exclude": { |
||||||
|
"**/built": true, |
||||||
|
"**/node_modules": true, |
||||||
|
"**/yotta_modules": true, |
||||||
|
"**/yotta_targets": true, |
||||||
|
"**/pxt_modules": true |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,30 @@ |
|||||||
|
|
||||||
|
// A task runner that calls the MakeCode (PXT) compiler |
||||||
|
{ |
||||||
|
"version": "2.0.0", |
||||||
|
"tasks": [{ |
||||||
|
"label": "pxt deploy", |
||||||
|
"type": "shell", |
||||||
|
"command": "pxt deploy --local", |
||||||
|
"group": "build", |
||||||
|
"problemMatcher": [ "$tsc" ] |
||||||
|
}, { |
||||||
|
"label": "pxt build", |
||||||
|
"type": "shell", |
||||||
|
"command": "pxt build --local", |
||||||
|
"group": "build", |
||||||
|
"problemMatcher": [ "$tsc" ] |
||||||
|
}, { |
||||||
|
"label": "pxt install", |
||||||
|
"type": "shell", |
||||||
|
"command": "pxt install", |
||||||
|
"group": "build", |
||||||
|
"problemMatcher": [ "$tsc" ] |
||||||
|
}, { |
||||||
|
"label": "pxt clean", |
||||||
|
"type": "shell", |
||||||
|
"command": "pxt clean", |
||||||
|
"group": "test", |
||||||
|
"problemMatcher": [ "$tsc" ] |
||||||
|
}] |
||||||
|
} |
||||||
@ -0,0 +1,2 @@ |
|||||||
|
source 'https://rubygems.org' |
||||||
|
gem 'github-pages', group: :jekyll_plugins |
||||||
@ -0,0 +1,10 @@ |
|||||||
|
all: deploy |
||||||
|
|
||||||
|
build: |
||||||
|
pxt build |
||||||
|
|
||||||
|
deploy: |
||||||
|
pxt deploy |
||||||
|
|
||||||
|
test: |
||||||
|
pxt test |
||||||
@ -0,0 +1,33 @@ |
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
> 在 [https://htc805.github.io/class-1304/](https://htc805.github.io/class-1304/) 打開此頁面 |
||||||
|
|
||||||
|
## 作為擴充功能使用 |
||||||
|
|
||||||
|
可以在 MakeCode 中將此儲存庫新增為**擴充功能**。 |
||||||
|
|
||||||
|
* 開啟 [https://arcade.makecode.com/](https://arcade.makecode.com/) |
||||||
|
* 按一下**新專案** |
||||||
|
* 按一下工具齒輪選單下的**擴充功能** |
||||||
|
* 搜索 **https://github.com/htc805/class-1304** 並匯出 |
||||||
|
|
||||||
|
## 編輯此專案  |
||||||
|
|
||||||
|
編輯 MakeCode 中的儲存庫。 |
||||||
|
|
||||||
|
* 開啟 [https://arcade.makecode.com/](https://arcade.makecode.com/) |
||||||
|
* 按一下**匯入**,然後按一下**匯入 URL** |
||||||
|
* 貼上 **https://github.com/htc805/class-1304** 並按一下匯入 |
||||||
|
|
||||||
|
## 預覽程式積木 |
||||||
|
|
||||||
|
此影像顯示了主分支中最後一次提交的方塊程式碼。 |
||||||
|
此影像可能需要幾分鐘的時間重新整理。 |
||||||
|
|
||||||
|
 |
||||||
|
|
||||||
|
#### 中繼資料 (用於搜索、渲染) |
||||||
|
|
||||||
|
* for PXT/arcade |
||||||
|
<script src="https://makecode.com/gh-pages-embed.js"></script><script>makeCodeRender("{{ site.makecode.home_url }}", "{{ site.github.owner_name }}/{{ site.github.repository_name }}");</script> |
||||||
@ -0,0 +1,8 @@ |
|||||||
|
makecode: |
||||||
|
target: arcade |
||||||
|
platform: arcade |
||||||
|
home_url: https://arcade.makecode.com/ |
||||||
|
theme: jekyll-theme-slate |
||||||
|
include: |
||||||
|
- assets |
||||||
|
- README.md |
||||||
@ -0,0 +1,106 @@ |
|||||||
|
<!DOCTYPE html> |
||||||
|
<html> |
||||||
|
<head> |
||||||
|
<meta charset="utf-8"> |
||||||
|
<script type="text/javascript" src="./js/loader.js"></script> |
||||||
|
<script type="text/javascript" src="./js/custom.js"></script> |
||||||
|
<style> |
||||||
|
body { |
||||||
|
background: black; |
||||||
|
color: white; |
||||||
|
font-family: monospace; |
||||||
|
overflow: hidden; |
||||||
|
font-size: 14pt; |
||||||
|
} |
||||||
|
|
||||||
|
iframe { |
||||||
|
position: absolute; |
||||||
|
top: 0; |
||||||
|
left: 0; |
||||||
|
width: 100%; |
||||||
|
height: 100%; |
||||||
|
border: none; |
||||||
|
} |
||||||
|
#fullscreen { |
||||||
|
position: absolute; |
||||||
|
right: 0.25rem; |
||||||
|
bottom: 0; |
||||||
|
cursor: pointer; |
||||||
|
} |
||||||
|
.lds-ripple { |
||||||
|
width: 80px; |
||||||
|
height: 80px; |
||||||
|
margin: auto; |
||||||
|
position: absolute; |
||||||
|
margin: auto; |
||||||
|
top: 0; |
||||||
|
right: 0; |
||||||
|
bottom: 0; |
||||||
|
left: 0; |
||||||
|
z-index: -1; |
||||||
|
} |
||||||
|
|
||||||
|
.lds-ripple div { |
||||||
|
position: absolute; |
||||||
|
border: 4px solid #fff; |
||||||
|
opacity: 1; |
||||||
|
border-radius: 50%; |
||||||
|
animation: lds-ripple 1s cubic-bezier(0, 0.2, 0.8, 1) infinite; |
||||||
|
} |
||||||
|
|
||||||
|
.lds-ripple div:nth-child(2) { |
||||||
|
animation-delay: -0.5s; |
||||||
|
} |
||||||
|
|
||||||
|
@keyframes lds-ripple { |
||||||
|
0% { |
||||||
|
top: 36px; |
||||||
|
left: 36px; |
||||||
|
width: 0; |
||||||
|
height: 0; |
||||||
|
opacity: 1; |
||||||
|
} |
||||||
|
|
||||||
|
100% { |
||||||
|
top: 0px; |
||||||
|
left: 0px; |
||||||
|
width: 72px; |
||||||
|
height: 72px; |
||||||
|
opacity: 0; |
||||||
|
} |
||||||
|
} |
||||||
|
</style> |
||||||
|
</head> |
||||||
|
|
||||||
|
<body id="root"> |
||||||
|
<div id="loader" class="lds-ripple"> |
||||||
|
<div></div> |
||||||
|
<div></div> |
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" x="0" y="0" viewBox="0 0 32 32" xml:space="preserve" |
||||||
|
id="svg2"> |
||||||
|
<style type="text/css" id="style4"></style> |
||||||
|
<g id="g4212" transform="matrix(.79626 0 0 .79626 -68.322 9.868)"> |
||||||
|
<path |
||||||
|
d="M105.989-5.487v.01a1.91 1.91 0 00-1.613 1.83c0 .779.417 1.119.417 1.15.413.435.238.913-.589.874 0 0-3.009.015-3.066 0a.724.724 0 00-.53.696v9.894c-.001.39.314.705.705.705h9.848c.39 0 .705-.314.705-.705V5.475c-.126-.423-.489-.463-.827-.141-.032 0-.369.417-1.147.417-.93-.03-1.69-.72-1.83-1.616h-.013a6.771 6.771 0 010-.494h.012c.142-.897.9-1.587 1.83-1.616.78 0 1.116.417 1.148.417.329.313.695.238.827-.138V-.927a.72.72 0 00-.527-.696c-.057.015-3.07 0-3.07 0-.74.06-.998-.44-.585-.874 0-.031.417-.371.417-1.15-.029-.93-.72-1.69-1.616-1.83v-.01a6.241 6.241 0 00-.496 0z" |
||||||
|
id="path167" fill="#fff" fill-opacity="1" stroke-width="1.57" /> |
||||||
|
<path |
||||||
|
d="M98.633-7.18c-.917 0-1.624.252-2.158.774-.534.521-.802 1.208-.822 2.094a552.379 552.379 0 01-.062 2.732c-.02.776-.081 1.354-.187 1.766-.118.46-.331.853-.637 1.168-.272.28-.684.587-1.254.938-.255.156-.368.387-.368.748 0 .351.077.481.11.521.12.145.32.3.592.463.376.226.702.494.972.795.3.334.518.786.662 1.38.052.213.112.882.172 4.228.006.566.138 1.07.39 1.502.25.431.584.753 1.02.984.443.235.971.356 1.57.356.974 0 1.055-.377 1.055-.764 0-.266-.054-.465-.157-.591a.501.501 0 00-.334-.2c-.374-.042-.66-.103-.87-.187a1.29 1.29 0 01-.678-.622c-.127-.244-.206-.588-.242-1.049a22.82 22.82 0 01-.046-1.68c0-.707-.034-1.327-.099-1.846a4.868 4.868 0 00-.31-1.26 2.848 2.848 0 00-.52-.843 4.267 4.267 0 00-.874-.702l-.773-.485.773-.487c.502-.318.88-.657 1.128-1.012.244-.35.413-.783.503-1.282.099-.55.153-1.333.169-2.333 0-.713.014-1.247.042-1.625.032-.437.105-.774.221-1.027.147-.317.382-.548.68-.672.214-.086.506-.152.896-.205a.429.429 0 00.224-.089.622.622 0 00.178-.251 1.11 1.11 0 00.089-.451c0-.268-.07-.45-.215-.57-.175-.144-.456-.215-.84-.215z" |
||||||
|
id="path165" fill="#fff" fill-opacity="1" stroke-width="1.57" /> |
||||||
|
<path |
||||||
|
d="M113.887-7.182c-.974 0-1.055.377-1.055.763 0 .267.05.467.153.592.1.12.205.182.338.2.374.042.658.103.867.186.294.116.524.326.678.623.127.245.206.588.242 1.048.032.397.046.945.046 1.68 0 .708.034 1.328.098 1.846.06.49.166.917.31 1.264.138.332.313.616.521.843.22.239.511.473.871.699l.773.487-.77.488c-.502.317-.882.656-1.128 1.009-.244.35-.414.78-.503 1.278-.099.551-.154 1.338-.169 2.337 0 .712-.015 1.246-.043 1.625-.03.437-.1.77-.217 1.024a1.294 1.294 0 01-.68.674c-.214.087-.506.154-.896.206a.44.44 0 00-.227.089.64.64 0 00-.178.251c-.06.135-.086.282-.086.45 0 .268.066.45.212.571.174.144.458.218.843.218.917 0 1.62-.254 2.155-.776.534-.522.802-1.205.822-2.091.023-1.095.046-2.007.064-2.735.02-.777.079-1.355.184-1.766.12-.46.333-.854.638-1.168.273-.28.684-.587 1.254-.938.254-.157.368-.385.368-.746 0-.35-.077-.483-.11-.524-.119-.143-.316-.298-.589-.463a4.268 4.268 0 01-.975-.794c-.3-.334-.515-.784-.66-1.377-.051-.213-.114-.885-.174-4.23-.007-.568-.138-1.072-.39-1.503a2.524 2.524 0 00-1.02-.984c-.443-.235-.968-.356-1.567-.356z" |
||||||
|
id="path163" fill="#fff" fill-opacity="1" stroke-width="1.57" /> |
||||||
|
</g> |
||||||
|
<path |
||||||
|
d="M28.621 31.422c.224-.102.208 1.099.208-15.49 0-16.588.016-15.388-.208-15.49-.144-.065-24.6-.065-24.744 0-.223.102-.207-1.1-.206 15.498.001 12.58.01 15.259.052 15.334.112.203-.702.19 12.515.192 9.446.001 12.307-.01 12.383-.044zm-9.415-1.705c-.283-.11-.57-.4-.678-.687a1.216 1.216 0 011.131-1.655c.669 0 1.213.544 1.213 1.213 0 .853-.862 1.437-1.666 1.129zm-8.337-1.054v-.757H9.353v-1.668h1.516V24.723H12.536V26.238h1.516v1.668h-1.516V29.42H10.869zm10.99-1.22c-.284-.109-.57-.399-.678-.686a1.204 1.204 0 01.276-1.298c.762-.762 2.067-.222 2.067.855 0 .854-.862 1.438-1.666 1.13zM4.765 23.475l-.111-.11V1.377l.11-.111.111-.11h22.746l.11.11.112.11V23.366l-.111.11-.11.111H4.875z" |
||||||
|
id="path4210" fill="#fff" fill-opacity="1" /> |
||||||
|
</svg> |
||||||
|
</div> |
||||||
|
<iframe id="simframe" allowfullscreen="allowfullscreen" |
||||||
|
sandbox="allow-popups allow-forms allow-scripts allow-same-origin"> |
||||||
|
</iframe> |
||||||
|
<div id="fullscreen">⇲</div> |
||||||
|
<script type="text/javascript"> |
||||||
|
makeCodeRun({ js: "./js/binary.js"}) |
||||||
|
</script> |
||||||
|
</body> |
||||||
|
</html> |
||||||
File diff suppressed because one or more lines are too long
@ -0,0 +1,11 @@ |
|||||||
|
/** |
||||||
|
* This will be loaded before starting the simulator. |
||||||
|
* If you wish to add custom javascript, |
||||||
|
* ** make sure to add this line to pxt.json** |
||||||
|
* |
||||||
|
* "disableTargetTemplateFiles": true |
||||||
|
* |
||||||
|
* otherwise MakeCode will override your changes. |
||||||
|
* |
||||||
|
* To register a constrol simmessages, use addSimMessageHandler |
||||||
|
*/ |
||||||
@ -0,0 +1,169 @@ |
|||||||
|
var channelHandlers = {} |
||||||
|
|
||||||
|
function addSimMessageHandler(channel, handler) { |
||||||
|
channelHandlers[channel] = handler; |
||||||
|
} |
||||||
|
|
||||||
|
function makeCodeRun(options) { |
||||||
|
var code = ""; |
||||||
|
var isReady = false; |
||||||
|
var simState = {} |
||||||
|
var simStateChanged = false |
||||||
|
var started = false; |
||||||
|
var meta = undefined; |
||||||
|
|
||||||
|
// hide scrollbar
|
||||||
|
window.scrollTo(0, 1); |
||||||
|
// init runtime
|
||||||
|
initSimState(); |
||||||
|
fetchCode(); |
||||||
|
|
||||||
|
// helpers
|
||||||
|
function fetchCode() { |
||||||
|
sendReq(options.js, function (c, status) { |
||||||
|
if (status != 200) |
||||||
|
return; |
||||||
|
code = c; |
||||||
|
// find metadata
|
||||||
|
code.replace(/^\/\/\s+meta=([^\n]+)\n/m, function (m, metasrc) { |
||||||
|
meta = JSON.parse(metasrc); |
||||||
|
}) |
||||||
|
var vel = document.getElementById("version"); |
||||||
|
if (meta.version && meta.repo && vel) { |
||||||
|
var ap = document.createElement("a"); |
||||||
|
ap.download = "arcade.uf2"; |
||||||
|
ap.href = "https://github.com/" + meta.repo + "/releases/download/v" + meta.version + "/arcade.uf2"; |
||||||
|
ap.innerText = "v" + meta.version; |
||||||
|
vel.appendChild(ap); |
||||||
|
} |
||||||
|
// load simulator with correct version
|
||||||
|
document.getElementById("simframe") |
||||||
|
.setAttribute("src", meta.simUrl); |
||||||
|
initFullScreen(); |
||||||
|
}) |
||||||
|
} |
||||||
|
|
||||||
|
function startSim() { |
||||||
|
if (!code || !isReady || started) |
||||||
|
return |
||||||
|
setState("run"); |
||||||
|
started = true; |
||||||
|
const runMsg = { |
||||||
|
type: "run", |
||||||
|
parts: [], |
||||||
|
code: code, |
||||||
|
partDefinitions: {}, |
||||||
|
cdnUrl: meta.cdnUrl, |
||||||
|
version: meta.target, |
||||||
|
storedState: simState, |
||||||
|
frameCounter: 1, |
||||||
|
options: { |
||||||
|
"theme": "green", |
||||||
|
"player": "" |
||||||
|
}, |
||||||
|
id: "green-" + Math.random() |
||||||
|
} |
||||||
|
postMessage(runMsg); |
||||||
|
} |
||||||
|
|
||||||
|
function stopSim() { |
||||||
|
setState("stopped"); |
||||||
|
postMessage({ |
||||||
|
type: "stop" |
||||||
|
}); |
||||||
|
started = false; |
||||||
|
} |
||||||
|
|
||||||
|
window.addEventListener('message', function (ev) { |
||||||
|
var d = ev.data |
||||||
|
if (d.type == "ready") { |
||||||
|
var loader = document.getElementById("loader"); |
||||||
|
if (loader) |
||||||
|
loader.remove(); |
||||||
|
isReady = true; |
||||||
|
startSim(); |
||||||
|
} else if (d.type == "simulator") { |
||||||
|
switch (d.command) { |
||||||
|
case "restart": |
||||||
|
stopSim(); |
||||||
|
startSim(); |
||||||
|
break; |
||||||
|
case "setstate": |
||||||
|
if (d.stateValue === null) |
||||||
|
delete simState[d.stateKey]; |
||||||
|
else |
||||||
|
simState[d.stateKey] = d.stateValue; |
||||||
|
simStateChanged = true; |
||||||
|
break; |
||||||
|
} |
||||||
|
} else if (d.type === "messagepacket" && d.channel) { |
||||||
|
const handler = channelHandlers[d.channel] |
||||||
|
if (handler) { |
||||||
|
try { |
||||||
|
const buf = d.data; |
||||||
|
const str = uint8ArrayToString(buf); |
||||||
|
const data = JSON.parse(str) |
||||||
|
handler(data); |
||||||
|
} catch (e) { |
||||||
|
console.log(`invalid simmessage`) |
||||||
|
console.log(e) |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
}, false); |
||||||
|
|
||||||
|
// helpers
|
||||||
|
function uint8ArrayToString(input) { |
||||||
|
let len = input.length; |
||||||
|
let res = "" |
||||||
|
for (let i = 0; i < len; ++i) |
||||||
|
res += String.fromCharCode(input[i]); |
||||||
|
return res; |
||||||
|
} |
||||||
|
|
||||||
|
function setState(st) { |
||||||
|
var r = document.getElementById("root"); |
||||||
|
if (r) |
||||||
|
r.setAttribute("data-state", st); |
||||||
|
} |
||||||
|
|
||||||
|
function postMessage(msg) { |
||||||
|
const frame = document.getElementById("simframe"); |
||||||
|
if (frame) |
||||||
|
frame.contentWindow.postMessage(msg, meta.simUrl); |
||||||
|
} |
||||||
|
|
||||||
|
function sendReq(url, cb) { |
||||||
|
var xhttp = new XMLHttpRequest(); |
||||||
|
xhttp.onreadystatechange = function () { |
||||||
|
if (xhttp.readyState == 4) { |
||||||
|
cb(xhttp.responseText, xhttp.status) |
||||||
|
} |
||||||
|
}; |
||||||
|
xhttp.open("GET", url, true); |
||||||
|
xhttp.send(); |
||||||
|
} |
||||||
|
|
||||||
|
function initSimState() { |
||||||
|
try { |
||||||
|
simState = JSON.parse(localStorage["simstate"]) |
||||||
|
} catch (e) { |
||||||
|
simState = {} |
||||||
|
} |
||||||
|
setInterval(function () { |
||||||
|
if (simStateChanged) |
||||||
|
localStorage["simstate"] = JSON.stringify(simState) |
||||||
|
simStateChanged = false |
||||||
|
}, 200) |
||||||
|
} |
||||||
|
|
||||||
|
function initFullScreen() { |
||||||
|
var sim = document.getElementById("simframe"); |
||||||
|
var fs = document.getElementById("fullscreen"); |
||||||
|
if (fs && sim.requestFullscreen) { |
||||||
|
fs.onclick = function() { sim.requestFullscreen(); } |
||||||
|
} else if (fs) { |
||||||
|
fs.remove(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,187 @@ |
|||||||
|
--- |
||||||
|
# this is an empty front matter |
||||||
|
--- |
||||||
|
<!DOCTYPE html> |
||||||
|
<html> |
||||||
|
|
||||||
|
<head> |
||||||
|
<meta charset="utf-8"> |
||||||
|
<title>{{ site.github.project_title }}</title> |
||||||
|
<meta name="description" content="{{ site.github.project_tagline }}" /> |
||||||
|
<meta name="author" content="{{ site.github.owner_name }}"> |
||||||
|
<meta name="twitter:card" content="summary" /> |
||||||
|
<meta name="twitter:site" content="/" /> |
||||||
|
<meta name="twitter:title" content="{{ site.github.project_tagline }}" /> |
||||||
|
<meta name="twitter:description" content="{{ site.github.project_tagline }}" /> |
||||||
|
<meta name="twitter:image" content="./icon.png" /> |
||||||
|
<meta name="mobile-web-app-capable" content="yes"> |
||||||
|
<meta name="apple-mobile-web-app-capable" content="yes"> |
||||||
|
<meta name="apple-mobile-web-app-title" content="{{ site.github.project_title }}"> |
||||||
|
<meta name="apple-mobile-web-app-status-bar-style" content="translucent-black"> |
||||||
|
<meta name="format-detection" content="telephone=no"> |
||||||
|
<meta name="application-name" content="{{ site.github.project_title }}"> |
||||||
|
<meta name="theme-color" content="#000"> |
||||||
|
<meta property="og:title" content="{{ site.github.project_title }}" /> |
||||||
|
<meta property="og:site_name" content="{{ site.github.project_title }}" /> |
||||||
|
<meta property="og:description" content="{{ site.github.project_tagline }}" /> |
||||||
|
<meta property="og:image" content="./icon.png" /> |
||||||
|
<link rel="apple-touch-icon" href="./icon.png"> |
||||||
|
<link rel="icon" type="image/png" href="./icon.png"> |
||||||
|
<link rel="shortcut icon" href="./icon.png"> |
||||||
|
<script type="text/javascript" src="./assets/js/loader.js?v={{ site.github.build_revision }}"></script> |
||||||
|
<script type="text/javascript" src="./assets/js/custom.js?v={{ site.github.build_revision }}"></script> |
||||||
|
<style> |
||||||
|
body { |
||||||
|
background: black; |
||||||
|
color: white; |
||||||
|
font-family: monospace; |
||||||
|
overflow: hidden; |
||||||
|
font-size: 14pt; |
||||||
|
} |
||||||
|
|
||||||
|
.embed { |
||||||
|
background: transparent; |
||||||
|
} |
||||||
|
|
||||||
|
iframe { |
||||||
|
position: absolute; |
||||||
|
top: 0; |
||||||
|
left: 0; |
||||||
|
width: 100%; |
||||||
|
height: calc(100% - 1.5em); |
||||||
|
border: none; |
||||||
|
} |
||||||
|
|
||||||
|
.nofooter iframe { |
||||||
|
height: 100%; |
||||||
|
} |
||||||
|
|
||||||
|
footer { |
||||||
|
color: grey; |
||||||
|
position: absolute; |
||||||
|
bottom: 0; |
||||||
|
width: 100%; |
||||||
|
left: 0; |
||||||
|
z-index: 100; |
||||||
|
text-align: center; |
||||||
|
font-size: 1em; |
||||||
|
margin-bottom: 0.25em; |
||||||
|
} |
||||||
|
|
||||||
|
footer a { |
||||||
|
color: grey; |
||||||
|
} |
||||||
|
|
||||||
|
.embed footer, |
||||||
|
.embed footer a { |
||||||
|
color: black; |
||||||
|
} |
||||||
|
|
||||||
|
#fullscreen { |
||||||
|
position: absolute; |
||||||
|
right: 0.25rem; |
||||||
|
bottom: 0; |
||||||
|
cursor: pointer; |
||||||
|
} |
||||||
|
.lds-ripple { |
||||||
|
width: 80px; |
||||||
|
height: 80px; |
||||||
|
margin: auto; |
||||||
|
position: absolute; |
||||||
|
margin: auto; |
||||||
|
top: 0; |
||||||
|
right: 0; |
||||||
|
bottom: 0; |
||||||
|
left: 0; |
||||||
|
z-index: -1; |
||||||
|
} |
||||||
|
|
||||||
|
.lds-ripple div { |
||||||
|
position: absolute; |
||||||
|
border: 4px solid #fff; |
||||||
|
opacity: 1; |
||||||
|
border-radius: 50%; |
||||||
|
animation: lds-ripple 1s cubic-bezier(0, 0.2, 0.8, 1) infinite; |
||||||
|
} |
||||||
|
|
||||||
|
.lds-ripple div:nth-child(2) { |
||||||
|
animation-delay: -0.5s; |
||||||
|
} |
||||||
|
|
||||||
|
@keyframes lds-ripple { |
||||||
|
0% { |
||||||
|
top: 36px; |
||||||
|
left: 36px; |
||||||
|
width: 0; |
||||||
|
height: 0; |
||||||
|
opacity: 1; |
||||||
|
} |
||||||
|
|
||||||
|
100% { |
||||||
|
top: 0px; |
||||||
|
left: 0px; |
||||||
|
width: 72px; |
||||||
|
height: 72px; |
||||||
|
opacity: 0; |
||||||
|
} |
||||||
|
} |
||||||
|
</style> |
||||||
|
</head> |
||||||
|
|
||||||
|
<body id="root"> |
||||||
|
<div id="loader" class="lds-ripple"> |
||||||
|
<div></div> |
||||||
|
<div></div> |
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" x="0" y="0" viewBox="0 0 32 32" xml:space="preserve" |
||||||
|
id="svg2"> |
||||||
|
<style type="text/css" id="style4"></style> |
||||||
|
<g id="g4212" transform="matrix(.79626 0 0 .79626 -68.322 9.868)"> |
||||||
|
<path |
||||||
|
d="M105.989-5.487v.01a1.91 1.91 0 00-1.613 1.83c0 .779.417 1.119.417 1.15.413.435.238.913-.589.874 0 0-3.009.015-3.066 0a.724.724 0 00-.53.696v9.894c-.001.39.314.705.705.705h9.848c.39 0 .705-.314.705-.705V5.475c-.126-.423-.489-.463-.827-.141-.032 0-.369.417-1.147.417-.93-.03-1.69-.72-1.83-1.616h-.013a6.771 6.771 0 010-.494h.012c.142-.897.9-1.587 1.83-1.616.78 0 1.116.417 1.148.417.329.313.695.238.827-.138V-.927a.72.72 0 00-.527-.696c-.057.015-3.07 0-3.07 0-.74.06-.998-.44-.585-.874 0-.031.417-.371.417-1.15-.029-.93-.72-1.69-1.616-1.83v-.01a6.241 6.241 0 00-.496 0z" |
||||||
|
id="path167" fill="#fff" fill-opacity="1" stroke-width="1.57" /> |
||||||
|
<path |
||||||
|
d="M98.633-7.18c-.917 0-1.624.252-2.158.774-.534.521-.802 1.208-.822 2.094a552.379 552.379 0 01-.062 2.732c-.02.776-.081 1.354-.187 1.766-.118.46-.331.853-.637 1.168-.272.28-.684.587-1.254.938-.255.156-.368.387-.368.748 0 .351.077.481.11.521.12.145.32.3.592.463.376.226.702.494.972.795.3.334.518.786.662 1.38.052.213.112.882.172 4.228.006.566.138 1.07.39 1.502.25.431.584.753 1.02.984.443.235.971.356 1.57.356.974 0 1.055-.377 1.055-.764 0-.266-.054-.465-.157-.591a.501.501 0 00-.334-.2c-.374-.042-.66-.103-.87-.187a1.29 1.29 0 01-.678-.622c-.127-.244-.206-.588-.242-1.049a22.82 22.82 0 01-.046-1.68c0-.707-.034-1.327-.099-1.846a4.868 4.868 0 00-.31-1.26 2.848 2.848 0 00-.52-.843 4.267 4.267 0 00-.874-.702l-.773-.485.773-.487c.502-.318.88-.657 1.128-1.012.244-.35.413-.783.503-1.282.099-.55.153-1.333.169-2.333 0-.713.014-1.247.042-1.625.032-.437.105-.774.221-1.027.147-.317.382-.548.68-.672.214-.086.506-.152.896-.205a.429.429 0 00.224-.089.622.622 0 00.178-.251 1.11 1.11 0 00.089-.451c0-.268-.07-.45-.215-.57-.175-.144-.456-.215-.84-.215z" |
||||||
|
id="path165" fill="#fff" fill-opacity="1" stroke-width="1.57" /> |
||||||
|
<path |
||||||
|
d="M113.887-7.182c-.974 0-1.055.377-1.055.763 0 .267.05.467.153.592.1.12.205.182.338.2.374.042.658.103.867.186.294.116.524.326.678.623.127.245.206.588.242 1.048.032.397.046.945.046 1.68 0 .708.034 1.328.098 1.846.06.49.166.917.31 1.264.138.332.313.616.521.843.22.239.511.473.871.699l.773.487-.77.488c-.502.317-.882.656-1.128 1.009-.244.35-.414.78-.503 1.278-.099.551-.154 1.338-.169 2.337 0 .712-.015 1.246-.043 1.625-.03.437-.1.77-.217 1.024a1.294 1.294 0 01-.68.674c-.214.087-.506.154-.896.206a.44.44 0 00-.227.089.64.64 0 00-.178.251c-.06.135-.086.282-.086.45 0 .268.066.45.212.571.174.144.458.218.843.218.917 0 1.62-.254 2.155-.776.534-.522.802-1.205.822-2.091.023-1.095.046-2.007.064-2.735.02-.777.079-1.355.184-1.766.12-.46.333-.854.638-1.168.273-.28.684-.587 1.254-.938.254-.157.368-.385.368-.746 0-.35-.077-.483-.11-.524-.119-.143-.316-.298-.589-.463a4.268 4.268 0 01-.975-.794c-.3-.334-.515-.784-.66-1.377-.051-.213-.114-.885-.174-4.23-.007-.568-.138-1.072-.39-1.503a2.524 2.524 0 00-1.02-.984c-.443-.235-.968-.356-1.567-.356z" |
||||||
|
id="path163" fill="#fff" fill-opacity="1" stroke-width="1.57" /> |
||||||
|
</g> |
||||||
|
<path |
||||||
|
d="M28.621 31.422c.224-.102.208 1.099.208-15.49 0-16.588.016-15.388-.208-15.49-.144-.065-24.6-.065-24.744 0-.223.102-.207-1.1-.206 15.498.001 12.58.01 15.259.052 15.334.112.203-.702.19 12.515.192 9.446.001 12.307-.01 12.383-.044zm-9.415-1.705c-.283-.11-.57-.4-.678-.687a1.216 1.216 0 011.131-1.655c.669 0 1.213.544 1.213 1.213 0 .853-.862 1.437-1.666 1.129zm-8.337-1.054v-.757H9.353v-1.668h1.516V24.723H12.536V26.238h1.516v1.668h-1.516V29.42H10.869zm10.99-1.22c-.284-.109-.57-.399-.678-.686a1.204 1.204 0 01.276-1.298c.762-.762 2.067-.222 2.067.855 0 .854-.862 1.438-1.666 1.13zM4.765 23.475l-.111-.11V1.377l.11-.111.111-.11h22.746l.11.11.112.11V23.366l-.111.11-.11.111H4.875z" |
||||||
|
id="path4210" fill="#fff" fill-opacity="1" /> |
||||||
|
</svg> |
||||||
|
</div> |
||||||
|
<iframe id="simframe" allowfullscreen="allowfullscreen" |
||||||
|
sandbox="allow-popups allow-forms allow-scripts allow-same-origin"> |
||||||
|
</iframe> |
||||||
|
<footer id="footer"> |
||||||
|
<a target="blank" rel="nofollow noopener" href="https://{{ site.github.owner_name }}.github.io/{{ site.github.repository_name }}/README">Manual</a> |
||||||
|
<a target="blank" rel="nofollow noopener" href="https://arcade.makecode.com/#pub:github:{{ site.github.owner_name }}/{{ site.github.repository_name }}">Edit</a> |
||||||
|
<a target="blank" rel="nofollow noopener" href="https://github.com/{{ site.github.owner_name }}/{{ site.github.repository_name }}">GitHub</a> |
||||||
|
<span id="version"></span> |
||||||
|
<div id="fullscreen">⇲</div> |
||||||
|
</footer> |
||||||
|
<script type="text/javascript"> |
||||||
|
makeCodeRun({ js: "./assets/js/binary.js?v={{ site.github.build_revision }}" }); |
||||||
|
|
||||||
|
if (window.location && window.location.search) { |
||||||
|
var noFooter = /nofooter=1/i.test(window.location.search); |
||||||
|
var embed = /embed=1/i.test(window.location.search); |
||||||
|
var root = document.querySelector("#root"); |
||||||
|
|
||||||
|
if (noFooter) { |
||||||
|
var footer = document.querySelector("#footer"); |
||||||
|
if (root) |
||||||
|
root.className += " nofooter"; |
||||||
|
if (footer) |
||||||
|
footer.remove(); |
||||||
|
} |
||||||
|
|
||||||
|
if (embed && root) { |
||||||
|
root.className += " embed"; |
||||||
|
} |
||||||
|
} |
||||||
|
</script> |
||||||
|
</body> |
||||||
|
|
||||||
|
</html> |
||||||
File diff suppressed because one or more lines are too long
@ -0,0 +1,80 @@ |
|||||||
|
controller.A.onEvent(ControllerButtonEvent.Pressed, function () { |
||||||
|
projectile = sprites.createProjectileFromSprite(img` |
||||||
|
. . . . . . . . . . . . . . . . |
||||||
|
. . . . . . . . . . . . . . . . |
||||||
|
. . . . . . . . . . . . . . . . |
||||||
|
. . . . . . . . . . . . . . . . |
||||||
|
. . . . . . . . . . . . . . . . |
||||||
|
. . . . . . . . . . . . . . . . |
||||||
|
. . . . . . . . . . . . . . . . |
||||||
|
. . . . . . . . . . . . . . . . |
||||||
|
. . . . . . . . . . . . . . . . |
||||||
|
. . . . . . . . . . . . . . . . |
||||||
|
. . . . . . . . . . . . . . . . |
||||||
|
. . . . . . . 7 7 . . . . . . . |
||||||
|
. . . . . . . 7 7 . . . . . . . |
||||||
|
. . . . . . . 7 7 . . . . . . . |
||||||
|
. . . . . . . 7 7 . . . . . . . |
||||||
|
. . . . . . . 7 7 . . . . . . . |
||||||
|
`, mySprite, 0, -60)
|
||||||
|
music.pewPew.play() |
||||||
|
}) |
||||||
|
sprites.onOverlap(SpriteKind.Enemy, SpriteKind.Projectile, function (sprite, otherSprite) { |
||||||
|
otherSprite.destroy() |
||||||
|
sprite.destroy(effects.disintegrate, 500) |
||||||
|
info.changeScoreBy(1) |
||||||
|
}) |
||||||
|
sprites.onOverlap(SpriteKind.Player, SpriteKind.Enemy, function (sprite, otherSprite) { |
||||||
|
otherSprite.destroy(effects.fire, 500) |
||||||
|
scene.cameraShake(4, 500) |
||||||
|
info.changeLifeBy(-1) |
||||||
|
}) |
||||||
|
let projectile2: Sprite = null |
||||||
|
let projectile: Sprite = null |
||||||
|
let mySprite: Sprite = null |
||||||
|
info.setScore(0) |
||||||
|
info.setLife(3) |
||||||
|
effects.starField.startScreenEffect() |
||||||
|
mySprite = sprites.create(img` |
||||||
|
. . . . . . . c d . . . . . . . |
||||||
|
. . . . . . . c d . . . . . . . |
||||||
|
. . . . . . . c d . . . . . . . |
||||||
|
. . . . . . . c b . . . . . . . |
||||||
|
. . . . . . . f f . . . . . . . |
||||||
|
. . . . . . . c 7 . . . . . . . |
||||||
|
. . . . . . . f f . . . . . . . |
||||||
|
. . . . . . . 8 7 . . . . . . . |
||||||
|
. . . . . . 8 8 5 6 . . . . . . |
||||||
|
. . . . . . 8 7 5 6 . . . . . . |
||||||
|
. . . . . c c c 6 6 6 . . . . . |
||||||
|
. . . . 8 8 7 7 7 5 6 6 . . . . |
||||||
|
. . 8 f f f c c 6 6 f f 6 6 . . |
||||||
|
. 8 8 8 8 6 6 7 7 7 7 5 7 6 6 . |
||||||
|
8 8 8 8 8 8 6 6 7 7 7 5 7 7 6 6 |
||||||
|
8 8 8 8 8 8 6 6 7 7 7 7 5 7 6 6 |
||||||
|
`, SpriteKind.Player)
|
||||||
|
mySprite.setPosition(76, 108) |
||||||
|
controller.moveSprite(mySprite) |
||||||
|
mySprite.setStayInScreen(true) |
||||||
|
game.onUpdateInterval(1000, function () { |
||||||
|
projectile2 = sprites.createProjectileFromSide(img` |
||||||
|
. . . . . . . . . c c 8 . . . . |
||||||
|
. . . . . . 8 c c c f 8 c c . . |
||||||
|
. . . c c 8 8 f c a f f f c c . |
||||||
|
. . c c c f f f c a a f f c c c |
||||||
|
8 c c c f f f f c c a a c 8 c c |
||||||
|
c c c b f f f 8 a c c a a a c c |
||||||
|
c a a b b 8 a b c c c c c c c c |
||||||
|
a f c a a b b a c c c c c f f c |
||||||
|
a 8 f c a a c c a c a c f f f c |
||||||
|
c a 8 a a c c c c a a f f f 8 a |
||||||
|
. a c a a c f f a a b 8 f f c a |
||||||
|
. . c c b a f f f a b b c c 6 c |
||||||
|
. . . c b b a f f 6 6 a b 6 c . |
||||||
|
. . . c c b b b 6 6 a c c c c . |
||||||
|
. . . . c c a b b c c c . . . . |
||||||
|
. . . . . c c c c c c . . . . . |
||||||
|
`, 0, randint(30, 60))
|
||||||
|
projectile2.setKind(SpriteKind.Enemy) |
||||||
|
projectile2.x = randint(0, scene.screenWidth()) |
||||||
|
}) |
||||||
@ -0,0 +1,24 @@ |
|||||||
|
{ |
||||||
|
"name": "503", |
||||||
|
"description": "", |
||||||
|
"dependencies": { |
||||||
|
"device": "*" |
||||||
|
}, |
||||||
|
"files": [ |
||||||
|
"main.blocks", |
||||||
|
"main.ts", |
||||||
|
"README.md", |
||||||
|
"assets.json" |
||||||
|
], |
||||||
|
"testFiles": [ |
||||||
|
"test.ts" |
||||||
|
], |
||||||
|
"targetVersions": { |
||||||
|
"target": "1.8.22", |
||||||
|
"targetId": "arcade" |
||||||
|
}, |
||||||
|
"supportedTargets": [ |
||||||
|
"arcade" |
||||||
|
], |
||||||
|
"preferredEditor": "blocksprj" |
||||||
|
} |
||||||
Loading…
Reference in new issue