diff --git a/blockstile.ts b/blockstile.ts index 8a7d925..e9af4b6 100644 --- a/blockstile.ts +++ b/blockstile.ts @@ -42,7 +42,18 @@ namespace TileWorld { export function addTileSprite(code: number, image: Image, kind: number) { myWorld.addTileSprites(code, image, kind) } - + /** + * Set the player + * @param color + */ + //% group="Tiles" + //% blockId=TWsetplayer block="set player to %color=colorindexpicker" + export function setPlayer(code: number) { + let player = myWorld.getSprite(code) + bindToController(player) + scene.cameraFollowSprite(player) + } + // notifications /** @@ -56,7 +67,7 @@ namespace TileWorld { myWorld.onTileStationary(kind, h); } /** - * Act on a sprite that has moved to center of tile + * Sprite is at center of tile and received request to move * @param body code to execute */ //% group="Events" color="#444488" @@ -66,13 +77,13 @@ namespace TileWorld { myWorld.onTileArrived(kind, h) } /** - * Act on a sprite that has just moved into new tile + * Sprite has just move into (entered) a tile * @param body code to execute */ //% group="Events" color="#444488" //% blockId=TWontiletransition block="enter $tile of kind $kind=spritekind" //% blockAllowMultiple=1 draggableParameters="reporter" - export function onTileTransition(kind: number, h: (tile: TileSprite, col: number, row: number) => void) { + export function onTileTransition(kind: number, h: (tile: TileSprite) => void) { myWorld.onTileTransition(kind, h) } diff --git a/main.ts b/main.ts index 803038d..6a9336a 100644 --- a/main.ts +++ b/main.ts @@ -1,3 +1,5 @@ + + /* // Rules of the game: diff --git a/pxt.json b/pxt.json index 7fefd3c..b96fbc1 100644 --- a/pxt.json +++ b/pxt.json @@ -14,6 +14,6 @@ ], "testFiles": [], "public": false, - "installedVersion": "workspace:61b7f103-b0d4-4907-c2e8-9edc8ab9a6b9", + "installedVersion": "workspace:8fa74bb4-4622-48be-98e5-0a7f5d98f336", "preferredEditor": "tsprj" } \ No newline at end of file diff --git a/tileworld.ts b/tileworld.ts index 6815075..a509606 100644 --- a/tileworld.ts +++ b/tileworld.ts @@ -356,11 +356,6 @@ namespace TileWorld { if (code == pixel) this.tileMap.setPixel(x, y, this.backgroundTile) } } - // TODO: check for multiple player sprites - if (kind == SpriteKind.Player) { - bindToController(this.sprites[code][0]) - scene.cameraFollowSprite(this.sprites[code][0]) - } } private setKind(code: number, kind: number) {