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

Commit

Permalink
rename (Dir -> TileDir) and move out of namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
tballmsft committed Sep 20, 2019
1 parent 8f49621 commit 98b195d
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 105 deletions.
6 changes: 3 additions & 3 deletions blockstile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ namespace TileWorld {
//% group="Events"
//% blockId=TWontilearrived block="on %code=colorindexpicker arrived"
//% blockAllowMultiple=1
export function onTileArrived(code: number, h: (tile: TileSprite, direction: Dir) => void) {
export function onTileArrived(code: number, h: (tile: TileSprite, direction: TileDir) => void) {
myWorld.onTileArrived(code, h)
}
/**
Expand All @@ -92,10 +92,10 @@ namespace TileWorld {
export function makeGroup(code: number, code2: number, code3: number = 0xff, code4: number = 0xff) {
return myWorld.makeGroup(code, code2, code3, code4)
}
export function isOneOf(d: Dir, c1: Dir, c2: Dir = 0xff, c3: Dir = 0xff) {
export function isOneOf(d: TileDir, c1: TileDir, c2: TileDir = 0xff, c3: TileDir = 0xff) {
myWorld.isOneOf(d, c1, c2, c3)
}
export function isNotOneOf(d: Dir, c1: Dir, c2: Dir = 0xff, c3: Dir = 0xff) {
export function isNotOneOf(d: TileDir, c1: TileDir, c2: TileDir = 0xff, c3: TileDir = 0xff) {
myWorld.isNotOneOf(d, c1, c2, c3)
}

Expand Down
38 changes: 19 additions & 19 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,14 +239,14 @@ world.onTileArrived(codes.Player, (tile) => {
})

world.onTileArrived(codes.Player, (tile, dir) => {
world.isNotOneOf(dir, tw.Dir.None)
world.isNotOneOf(dir, TileDir.None)
tile.hasNo(codes.Boulder, dir)
tile.hasNo(wallKind, dir)
tile.moveOne(dir)
})

world.onTileArrived(codes.Player, (tile, dir) => {
world.isOneOf(dir, tw.Dir.Left, tw.Dir.Right)
world.isOneOf(dir, TileDir.Left, TileDir.Right)
tile.has(codes.Space, dir, dir)
tile.has(codes.Boulder, dir)
tile.get(codes.Boulder, dir).moveOne(dir)
Expand All @@ -263,43 +263,43 @@ world.onTileTransition(codes.Player, (tile) => {

// rock starts falling if there is a space below it
world.onTileStationary(rockKind, (tile) => {
tile.has(codes.Space, tw.Dir.Down)
tile.moveOne(tw.Dir.Down)
tile.has(codes.Space, TileDir.Down)
tile.moveOne(TileDir.Down)
})

// rock falls to right
world.onTileStationary(rockKind, (tile) => {
tile.has(rockKind, tw.Dir.Down)
tile.has(codes.Space, tw.Dir.Right)
tile.has(codes.Space, tw.Dir.Right, tw.Dir.Down)
tile.moveOne(tw.Dir.Right)
tile.has(rockKind, TileDir.Down)
tile.has(codes.Space, TileDir.Right)
tile.has(codes.Space, TileDir.Right, TileDir.Down)
tile.moveOne(TileDir.Right)
})

// rock falls to left
world.onTileStationary(rockKind, (tile) => {
tile.has(rockKind, tw.Dir.Down)
tile.has(codes.Space, tw.Dir.Left)
tile.has(codes.Space, tw.Dir.Left, tw.Dir.Down)
tile.moveOne(tw.Dir.Left)
tile.has(rockKind, TileDir.Down)
tile.has(codes.Space, TileDir.Left)
tile.has(codes.Space, TileDir.Left, TileDir.Down)
tile.moveOne(TileDir.Left)
})

world.onTileArrived(rockKind, (tile, dir) => {
world.isOneOf(dir, tw.Dir.Down);
world.check(!world.tileIs(codes.Space, tile, tw.Dir.Down))
world.isOneOf(dir, TileDir.Down);
world.check(!world.tileIs(codes.Space, tile, TileDir.Down))
tile.deadStop();
})

world.onTileArrived(rockKind, (tile, dir) => {
world.isOneOf(dir, tw.Dir.Down);
tile.has(rockKind, tw.Dir.Down)
world.isOneOf(dir, TileDir.Down);
tile.has(rockKind, TileDir.Down)
tile.deadStop();
})

world.onTileArrived(rockKind, (tile, dir) => {
world.isNotOneOf(dir, tw.Dir.Down);
tile.has(codes.Space, tw.Dir.Down)
world.isNotOneOf(dir, TileDir.Down);
tile.has(codes.Space, TileDir.Down)
tile.deadStop();
tile.moveOne(tw.Dir.Down)
tile.moveOne(TileDir.Down)
})

world.onTileTransition(rockKind, (tile) => {
Expand Down
Loading

0 comments on commit 98b195d

Please sign in to comment.