From 0e90b07d878b21b6be2fc1797411f06ba3ce4028 Mon Sep 17 00:00:00 2001 From: Justin Oros Date: Fri, 29 May 2020 14:56:50 -0700 Subject: [PATCH] Initial files for MakeCode project --- .github/workflows/makecode.yml | 29 ++++++++++++++++ .vscode/settings.json | 23 +++++++++++++ .vscode/tasks.json | 36 +++++++++++++++++++ Makefile | 10 ++++++ README.md | 34 ++++++++++++++++++ main.blocks | 45 ++++++++++++++++++++++++ main.ts | 63 ++++++++++++++++++++++++++++++++++ pxt.json | 16 +++++++++ test.ts | 1 + tsconfig.json | 9 +++++ 10 files changed, 266 insertions(+) create mode 100644 .github/workflows/makecode.yml create mode 100644 .vscode/settings.json create mode 100644 .vscode/tasks.json create mode 100644 Makefile create mode 100644 README.md create mode 100644 main.blocks create mode 100644 main.ts create mode 100644 pxt.json create mode 100644 test.ts create mode 100644 tsconfig.json diff --git a/.github/workflows/makecode.yml b/.github/workflows/makecode.yml new file mode 100644 index 0000000..ad5e9f3 --- /dev/null +++ b/.github/workflows/makecode.yml @@ -0,0 +1,29 @@ +name: MakeCode + +on: [push] + +jobs: + build: + + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [8.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 diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..f8106d4 --- /dev/null +++ b/.vscode/settings.json @@ -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 + } +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..39ccded --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,36 @@ + +// 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" ] + }, { + "label": "pxt serial", + "type": "shell", + "command": "pxt serial", + "group": "test", + "problemMatcher": [ "$tsc" ] + }] +} diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..9068464 --- /dev/null +++ b/Makefile @@ -0,0 +1,10 @@ +all: deploy + +build: + pxt build + +deploy: + pxt deploy + +test: + pxt test diff --git a/README.md b/README.md new file mode 100644 index 0000000..2103f27 --- /dev/null +++ b/README.md @@ -0,0 +1,34 @@ +# baby-yoda-vs-tie-fighters ![Build status badge](https://github.com/justinoros/baby-yoda-vs-tie-fighters/workflows/MakeCode/badge.svg) + + + +## Use this extension + +This repository can be added as an **extension** in MakeCode. + +* open https://arcade.makecode.com/ +* click on **New Project** +* click on **Extensions** under the gearwheel menu +* search for the URL of this repository and import + +## Edit this extension + +To edit this repository in MakeCode. + +* open https://arcade.makecode.com/ +* click on **Import** then click on **Import URL** +* paste the repository URL and click import + +## Blocks preview + +This image shows the blocks code from the last commit in master. +This image may take a few minutes to refresh. + +![A rendered view of the blocks](https://github.com/justinoros/baby-yoda-vs-tie-fighters/raw/master/.makecode/blocks.png) + +## Supported targets + +* for PXT/arcade +* for PXT/arcade +(The metadata above is needed for package search.) + diff --git a/main.blocks b/main.blocks new file mode 100644 index 0000000..9d1fbb7 --- /dev/null +++ b/main.blocks @@ -0,0 +1,45 @@ +PlayerProjectileFoodEnemybabyYodabogeyprojectilebulletotherSpritespritebabyYoda0img` +. . . b b b b b . 7 7 7 . . . . +. . b b d d c . 7 7 7 7 7 . . . +. b b d d b . 7 7 7 c c c . . . +. b d d b c 7 7 7 7 7 c c . . . +b b d d c . 7 7 7 7 7 7 7 . . . +b d d d b 7 7 7 7 e e 7 7 . . . +b b d d c 7 . . e e e e e . . . +. b b b b . . . 7 7 7 e e . . . +b b d b c b c b 7 7 f f f b c b +b d d d b d d d d 7 f d d d d b +b b d b b b b b b b b b b b b b +. b b b d d d d d d d d d d b . +. . b d d d d d d d d d d d b . +. . b b b d d d d d d d b b b . +. . . . b b d d d d d b b . . . +. . . . . b b b b b b b . . . . +`PlayerSpriteFlag.StayInScreenbabyYodatrue3babyYoda200200spritePlayerotherSpriteEnemyotherSprite-1controller.AControllerButtonEvent.Pressedbullet0img` +. . . . +. . . . +4 4 5 5 +. . . . +`img` +. . . . +. . . . +5 5 5 5 +. . . . +`babyYoda2000spriteProjectileotherSpriteEnemyotherSpriteeffects.firesprite1001500bogey0img` +. . . . . . . . . . . . . . . . +. . . . . . . b b b b b b b . . +. . . . . . b b c b c c c c b b +. . . . . b b c c b c c c c c b +. b b b b c c c b c c c c c c b +b c c c c c c c b c c c c c b b +b b b b b b b b b b b b b b b . +. . . . . . . b 1 b b c c c b b +. . . . . . b b c b c c c c c b +. . . . . . . b 1 b b c c c b b +b b b b b b b b b b b b b b b . +b c c c c c c c b c c c c c b b +. b b b b c c c b c c c c c c b +. . . . . b b c c b c c c c c b +. . . . . . b b c b c c c b b b +. . . . . . . b b b b b b b . . +`Enemybogey-1000bogey1801200120 \ No newline at end of file diff --git a/main.ts b/main.ts new file mode 100644 index 0000000..c2e9661 --- /dev/null +++ b/main.ts @@ -0,0 +1,63 @@ +sprites.onOverlap(SpriteKind.Projectile, SpriteKind.Enemy, function (sprite, otherSprite) { + otherSprite.destroy() + sprite.destroy(effects.fire, 100) + info.changeScoreBy(1) +}) +controller.A.onEvent(ControllerButtonEvent.Pressed, function () { + bullet = sprites.createProjectileFromSprite(img` +. . . . +. . . . +5 5 5 5 +. . . . +`, babyYoda, 200, 0) +}) +sprites.onOverlap(SpriteKind.Player, SpriteKind.Enemy, function (sprite, otherSprite) { + otherSprite.destroy() + info.changeLifeBy(-1) +}) +let bogey: Sprite = null +let bullet: Sprite = null +let babyYoda: Sprite = null +babyYoda = sprites.create(img` +. . . b b b b b . 7 7 7 . . . . +. . b b d d c . 7 7 7 7 7 . . . +. b b d d b . 7 7 7 c c c . . . +. b d d b c 7 7 7 7 7 c c . . . +b b d d c . 7 7 7 7 7 7 7 . . . +b d d d b 7 7 7 7 e e 7 7 . . . +b b d d c 7 . . e e e e e . . . +. b b b b . . . 7 7 7 e e . . . +b b d b c b c b 7 7 f f f b c b +b d d d b d d d d 7 f d d d d b +b b d b b b b b b b b b b b b b +. b b b d d d d d d d d d d b . +. . b d d d d d d d d d d d b . +. . b b b d d d d d d d b b b . +. . . . b b d d d d d b b . . . +. . . . . b b b b b b b . . . . +`, SpriteKind.Player) +babyYoda.setFlag(SpriteFlag.StayInScreen, true) +info.setLife(3) +controller.moveSprite(babyYoda, 200, 200) +game.onUpdateInterval(500, function () { + bogey = sprites.create(img` +. . . . . . . . . . . . . . . . +. . . . . . . b b b b b b b . . +. . . . . . b b c b c c c c b b +. . . . . b b c c b c c c c c b +. b b b b c c c b c c c c c c b +b c c c c c c c b c c c c c b b +b b b b b b b b b b b b b b b . +. . . . . . . b 1 b b c c c b b +. . . . . . b b c b c c c c c b +. . . . . . . b 1 b b c c c b b +b b b b b b b b b b b b b b b . +b c c c c c c c b c c c c c b b +. b b b b c c c b c c c c c c b +. . . . . b b c c b c c c c c b +. . . . . . b b c b c c c b b b +. . . . . . . b b b b b b b . . +`, SpriteKind.Enemy) + bogey.setVelocity(-100, 0) + bogey.setPosition(180, Math.randomRange(0, 120)) +}) diff --git a/pxt.json b/pxt.json new file mode 100644 index 0000000..d333912 --- /dev/null +++ b/pxt.json @@ -0,0 +1,16 @@ +{ + "name": "Baby Yoda vs Tie Fighters!", + "dependencies": { + "device": "*" + }, + "description": "", + "files": [ + "main.blocks", + "main.ts", + "README.md" + ], + "preferredEditor": "blocksprj", + "testFiles": [ + "test.ts" + ] +} diff --git a/test.ts b/test.ts new file mode 100644 index 0000000..7bf240c --- /dev/null +++ b/test.ts @@ -0,0 +1 @@ +// tests go here; this will not be compiled when this package is used as an extension. diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..a2079ff --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,9 @@ +{ + "compilerOptions": { + "target": "es5", + "noImplicitAny": true, + "outDir": "built", + "rootDir": "." + }, + "exclude": ["pxt_modules/**/*test.ts"] +}