Skip to content
This repository has been archived by the owner on Nov 8, 2019. It is now read-only.

Commit

Permalink
getting closer to blocks functioning
Browse files Browse the repository at this point in the history
  • Loading branch information
tballmsft committed Sep 23, 2019
1 parent 7dba711 commit 2e156b4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
23 changes: 7 additions & 16 deletions blockstile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,27 +71,27 @@ namespace TileWorld {
* @param body code to execute
*/
//% group="Events" color="#444488"
//% blockId=TWontilestationary block="on %code=colorindexpicker at rest"
//% blockId=TWontilestationary block="on $tile of kind $kind=spritekind at rest"
//% blockAllowMultiple=1 draggableParameters="reporter"
export function onTileStationary(code: number, h: (tile: TileSprite) => void) {
myWorld.onTileStationary(code, h);
export function onTileStationary(kind: number, h: (tile: TileSprite) => void) {
myWorld.onTileStationary(kind, h);
}
/**
* Act on a sprite that has moved to center of tile
* @param body code to execute
*/
//% group="Events" color="#444488"
//% blockId=TWontilearrived block="on %code=colorindexpicker arrived"
//% blockId=TWontilearrived block="on $tile of kind $kind=spritekind arrived"
//% blockAllowMultiple=1 draggableParameters="reporter"
export function onTileArrived(code: number, h: (tile: TileSprite, direction: TileDir) => void) {
myWorld.onTileArrived(code, h)
export function onTileArrived(kind: number, h: (tile: TileSprite, direction: TileDir) => void) {
myWorld.onTileArrived(kind, h)
}
/**
* Act on a sprite that has just moved into new tile
* @param body code to execute
*/
//% group="Events" color="#444488"
//% blockId=TWontiletransition block="on %code=colorindexpicker transition"
//% blockId=TWontiletransition block="on $tile of kind $kind=spritekind transition"
//% blockAllowMultiple=1 draggableParameters="reporter"
export function onTileTransition(code: number, h: (tile: TileSprite, col: number, row: number) => void) {
myWorld.onTileTransition(code, h)
Expand All @@ -117,13 +117,4 @@ namespace TileWorld {
export function isNotOneOf(d: number, c1: TileDir, c2: TileDir = 0xff, c3: TileDir = 0xff) {
myWorld.isNotOneOf(d, c1, c2, c3)
}

// actions
//% blockId=TWsettilecode block="set code %ts to %code"
//% draggableParameters = "reporter"
//% group="Actions" color="#88CC44"
export function setTileCode(ts: TileSprite, code: number) {
myWorld.setCode(ts, code)
}

}
6 changes: 6 additions & 0 deletions tileworld.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,13 @@ namespace TileWorld {
this.onArrived = undefined;
this.onStationary = undefined;
this.onTransition = undefined;
}
//% blockId=TWsettilecode block="set code at %tile(tile) to %code"
//% group="Actions" color="#88CC44"
setCode(code: number) {
this.parent.setCode(this, code)
}

// block
has(code: number, dir: TileDir = TileDir.None, dir2: TileDir = TileDir.None, dir3: TileDir = TileDir.None) {
this.parent.check(this.parent.containsAt(code, this, dir, dir2, dir3))
Expand Down

0 comments on commit 2e156b4

Please sign in to comment.