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

Commit

Permalink
a start on blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
tballmsft committed Sep 20, 2019
1 parent f6d5e83 commit d5dbe89
Showing 1 changed file with 31 additions and 6 deletions.
37 changes: 31 additions & 6 deletions blockstile.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//% weight=1000 color="#442255" icon="\uf45c"
//% groups='["Tiles", "Events", "Logic"]'
//% groups='["Tiles", "Events", "Conditions", "Actions"]'
//% blockGap=8
namespace TileWorld {

Expand All @@ -13,18 +13,36 @@ namespace TileWorld {
export function setTileMap(map: Image) {
myWorld.setMap(map)
}
/**
* Set the background tile for sprites
* @param color
*/
//% group="Tiles"
//% blockId=TWsetbackgroundtile block="set background tile to %color=colorindexpicker"
export function setBackgroundTile(code: number) {
myWorld.setBackgroundTile(code)
}
export function setTileCode(ts: TileSprite, code: number) {
myWorld.setCode(ts, code)
}
export function addTile(code: number, image: Image) {
/**
* Set an image as a tile at the given index. Tiles should be a 16x16 image
* @param index
* @param img
*/
//% blockId=TWsettile block="set tile %index=colorindexpicker to %img=tile_image_picker"
//% group="Tiles"
export function setTile(code: number, image: Image) {
myWorld.addTiles(code, image)
}
/**
* Set an image as a sprite at the given index. Sprites should be a 16x16 image
* @param index
* @param img
*/
//% blockId=TWsetsprite block="set sprite %index=colorindexpicker to %img=tile_image_picker"
//% group="Tiles"
export function addTileSprite(code: number, image: Image) {
myWorld.addTileSprites(code, image)
}

export function getTileSprite(code: number) {
return myWorld.getSprite(code)
}
Expand All @@ -33,11 +51,18 @@ namespace TileWorld {
}

// notifications
//% group="Events"
export function onTileStationary(code: number, h: (ts: TileSprite) => void) { }
export function onTileArrived(code: number, h: (ts: TileSprite, d: Dir) => void) { }
export function onTileTransition(code: number, h: (ts: TileSprite, col: number, row: number) => void) { }
// logic

// checks
export function isOneOf(d: Dir, c1: Dir, c2: Dir = 0xff, c3: Dir = 0xff) { }
export function isNotOneOf(d: Dir, c1: Dir, c2: Dir = 0xff, c3: Dir = 0xff) { }

// actions
export function setTileCode(ts: TileSprite, code: number) {
myWorld.setCode(ts, code)
}

}

0 comments on commit d5dbe89

Please sign in to comment.