Skip to content

Commit 2c0e522

Browse files
2 parents 63c973f + 7711d74 commit 2c0e522

5 files changed

Lines changed: 20 additions & 17 deletions

File tree

.github/makecode/blocksdiff.png

-38.8 KB
Loading

main.blocks

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<xml xmlns="https://developers.google.com/blockly/xml"><variables><variable type="KIND_SpriteKind" id="`}O?dISCnE!;@dE3J%0_">Player</variable><variable type="KIND_SpriteKind" id="(c{hv0CHhW$MCn=D{xrr">Projectile</variable><variable type="KIND_SpriteKind" id="vr!fYKM264Ic1]xg03Sc">Food</variable><variable type="KIND_SpriteKind" id="9ur_~EqG0TwKF?WC1Reh">Enemy</variable><variable id="WR{lx^-=?vmD;j/?h|c|">mySprite</variable><variable id="A,{^bz[yv}GoxP|3,~)a">value</variable><variable id=",iYv.,6Qo,4orRY:G@L-">list</variable></variables><block type="pxt-on-start" id="w[XHg?FkCqS6:M;.~I!z" x="0" y="0"><statement name="HANDLER"><block type="set_current_tilemap" id="qy5|%3EpVF6cL]Bqk82#"><value name="tilemap"><shadow type="tiles_tilemap_editor"></shadow><block type="maze_generateTilemap" id="*Rx9}]dQE1I(sl5pbu3*"><mutation xmlns="http://www.w3.org/1999/xhtml" _expanded="1" _input_init="true"></mutation><field name="algorithm">MazeAlgorithm.Ellers</field><value name="mazeWidth"><shadow type="math_number" id="C-w1G171ecowxZhS.-^W"><field name="NUM">8</field></shadow></value><value name="mazeHeight"><shadow type="math_number" id="4RQ-#0yp{.|sxXD*1`os"><field name="NUM">8</field></shadow></value><value name="wall"><shadow type="tileset_tile_picker" id="(%s*@w%bUkJ@Z_z5TsSn"><field name="tile">sprites.dungeon.floorDark0</field></shadow></value><value name="floor"><shadow type="tileset_tile_picker" id="g3;B2MCw,=7,4a-^DWor"><field name="tile">sprites.castle.tileGrass2</field></shadow></value><value name="corridorSize"><shadow type="math_number" id="0itND.9pQ(jMK6`n!]tr"><field name="NUM">2</field></shadow></value><value name="seed"><shadow type="math_number" id="3fm(bPnbcymXHGYg:K`e"><field name="NUM">0</field></shadow></value></block></value><next><block type="variables_set" id="_cDI{EFHzUgbgY_.[@vz"><field name="VAR" id="WR{lx^-=?vmD;j/?h|c|">mySprite</field><value name="VALUE"><shadow type="math_number"><field name="NUM">0</field></shadow><block type="spritescreate" id="jt}uU::S13(+xmA$*1pW"><value name="img"><shadow type="screen_image_picker" id="H%h*C/IU:r(-{iCq9fnk"><field name="img">img`
1+
<xml xmlns="https://developers.google.com/blockly/xml"><variables><variable type="KIND_SpriteKind" id="1_J^]:-Q1a{2{1e/wMC0">Player</variable><variable type="KIND_SpriteKind" id="p5|PxH6%Vc=F)+?}=m#V">Projectile</variable><variable type="KIND_SpriteKind" id="ZYB$c7r4wj]$L.gZj6mj">Food</variable><variable type="KIND_SpriteKind" id="XwfTq?pNNC2)dt(u)m(3">Enemy</variable><variable id="AtOt=kYW{T}SJ9vHeZK=">mySprite</variable><variable id="Q1kh-W2=6(,YWift(^c|">value</variable><variable id="aTA[c#2To;^}cIt~sAvo">list</variable></variables><block type="pxt-on-start" id="{lnP4W{QOhctE4HYCUWb" x="0" y="0"><statement name="HANDLER"><block type="set_current_tilemap" id="eUu9dC*IKrQ,(7)h|*d;"><value name="tilemap"><shadow type="tiles_tilemap_editor"></shadow><block type="maze_generateTilemap" id="P2$^3()+H%e3;q0_vzum"><mutation xmlns="http://www.w3.org/1999/xhtml" _expanded="1" _input_init="true"></mutation><field name="algorithm">MazeAlgorithm.Ellers</field><value name="mazeWidth"><shadow type="math_number" id="AyI;(h=F4litNFp1+(~E"><field name="NUM">8</field></shadow></value><value name="mazeHeight"><shadow type="math_number" id="kW94o}$_c$yRud[BTEu~"><field name="NUM">8</field></shadow></value><value name="wall"><shadow type="tileset_tile_picker" id="8pL5{g2}!/PWo00jk#X9"><field name="tile">sprites.dungeon.floorDark0</field></shadow></value><value name="floor"><shadow type="tileset_tile_picker" id="4Om*HWL[Th+6,isR]mw?"><field name="tile">sprites.castle.tileGrass2</field></shadow></value><value name="corridorSize"><shadow type="math_number" id="nb(^JtKudky%pLbj~Oi}"><field name="NUM">2</field></shadow></value></block></value><next><block type="variables_set" id="%*U6c?*jt-ZxN!U3I1Iu"><field name="VAR" id="AtOt=kYW{T}SJ9vHeZK=">mySprite</field><value name="VALUE"><shadow type="math_number"><field name="NUM">0</field></shadow><block type="spritescreate" id="DoI@bP[*F_F-)e8iN:.m"><value name="img"><shadow type="screen_image_picker" id="#$p}3gO8.k@hA%C@3LTo"><field name="img">img`
22
........................
33
.....ffff...............
44
...fff22fff.............
@@ -23,4 +23,4 @@ fbbbbf2222fd4...........
2323
........................
2424
........................
2525
........................
26-
`</field><data>{"commentRefs":[],"fieldData":{"img":"H%h*C/IU:r(-{iCq9fnk"}}</data></shadow></value><value name="kind"><shadow type="spritekind" id="T}`E1HD+CLQKrUA`F9{v"><field name="MEMBER">Player</field></shadow></value></block></value><next><block type="mapplaceontile" id="j]nDg]e*.ckV-MYe:lr@"><value name="sprite"><shadow type="variables_get" id=":/Zqf=1z:ttANcBbW`HT"><field name="VAR" id="WR{lx^-=?vmD;j/?h|c|">mySprite</field></shadow></value><value name="loc"><shadow type="mapgettile" id="AoZZXP*@wF@;LI[,z-J+"><value name="col"><shadow type="math_number" id="fMUam(l_iczY_wBIvxUo"><field name="NUM">2</field></shadow></value><value name="row"><shadow type="math_number" id="zeJsyIcGCTw$LvHBlIR6"><field name="NUM">2</field></shadow></value></shadow></value><next><block type="game_control_sprite" id="E[nB@r9c`%j`VVq`t}lk"><mutation xmlns="http://www.w3.org/1999/xhtml" _expanded="0" _input_init="true"></mutation><value name="sprite"><shadow type="variables_get" id="l7O~;]{H*P|0WlcJE(i_"><field name="VAR" id="WR{lx^-=?vmD;j/?h|c|">mySprite</field></shadow></value><next><block type="camerafollow" id="T5Gi2d;/gt*0cPcx#@V^"><value name="sprite"><shadow type="variables_get" id="Pa53eB1`iFl_:2j]IFve"><field name="VAR" id="WR{lx^-=?vmD;j/?h|c|">mySprite</field></shadow></value><next><block type="pxt_controls_for_of" id="9I!TH,9WbinrA8.{T-,k"><value name="VAR"><shadow type="variables_get_reporter" id="zNdI#;{8T.x3S#tq#gZ7"><field name="VAR" id="A,{^bz[yv}GoxP|3,~)a">value</field></shadow></value><value name="LIST"><shadow type="variables_get" id="f!`R!{S8-fU|J6rk10o1"><field name="VAR" id=",iYv.,6Qo,4orRY:G@L-">list</field></shadow><block type="getRandomTilesByType" id="@JB}}1(iL#Z9_5xq{+x["><value name="maxCount"><shadow type="math_number" id="$Nk}tD%pyP4h/@gqk?gS"><field name="NUM">10</field></shadow></value><value name="tile"><shadow type="tileset_tile_picker" id="v6~{8{j4f6usbC^e_=BZ"><field name="tile">sprites.castle.tileGrass2</field></shadow></value></block></value><statement name="DO"><block type="mapsettileat" id="LIjaz8$8:p17IVhatOJ%"><value name="tile"><shadow type="tileset_tile_picker" id="x~_?GX+oA~oWBLeA_D#("><field name="tile">sprites.dungeon.chestClosed</field></shadow></value><value name="loc"><shadow type="mapgettile" id="T2G)S`0i,GO^L@l4+qn|"></shadow><block type="variables_get" id="ZFYHca^Q6CkGHGv+:PGe"><field name="VAR" id="A,{^bz[yv}GoxP|3,~)a">value</field></block></value></block></statement></block></next></block></next></block></next></block></next></block></next></block></statement></block></xml>
26+
`</field><data>{"commentRefs":[],"fieldData":{"img":"#$p}3gO8.k@hA%C@3LTo"}}</data></shadow></value><value name="kind"><shadow type="spritekind" id="2BH+e*$v9*~YT7B=D{gC"><field name="MEMBER">Player</field></shadow></value></block></value><next><block type="mapplaceontile" id="avU3xP*1n0b_cm$lHeKY"><value name="sprite"><shadow type="variables_get" id="H%=bDU!/`U7Q^s3td%Sj"><field name="VAR" id="AtOt=kYW{T}SJ9vHeZK=">mySprite</field></shadow></value><value name="loc"><shadow type="mapgettile" id="Rv3Gc^50,e=Ch;.*`bT4"><value name="col"><shadow type="math_number" id="%R;p1`34r8Q+)t-vJ`r."><field name="NUM">2</field></shadow></value><value name="row"><shadow type="math_number" id="eTGPhyD=c/)3y3Y{Wq#x"><field name="NUM">2</field></shadow></value></shadow></value><next><block type="game_control_sprite" id="v!B]i`u-ruCvYhu]M-x,"><mutation xmlns="http://www.w3.org/1999/xhtml" _expanded="0" _input_init="true"></mutation><value name="sprite"><shadow type="variables_get" id="K`.l=`gdIEz9V0k+aTSV"><field name="VAR" id="AtOt=kYW{T}SJ9vHeZK=">mySprite</field></shadow></value><next><block type="camerafollow" id="-%#P5B5D@zU%AxYpYyIl"><value name="sprite"><shadow type="variables_get" id=":mkdZsT=zZu-EG_p$B5h"><field name="VAR" id="AtOt=kYW{T}SJ9vHeZK=">mySprite</field></shadow></value><next><block type="pxt_controls_for_of" id="}.MPedX{I?MLo.L540b1"><value name="VAR"><shadow type="variables_get_reporter" id="3a0K9$KfxrXdt?Zj+w-6"><field name="VAR" id="Q1kh-W2=6(,YWift(^c|">value</field></shadow></value><value name="LIST"><shadow type="variables_get" id="61bH/a;1MQKjzo43m{AM"><field name="VAR" id="aTA[c#2To;^}cIt~sAvo">list</field></shadow><block type="tilesExt_getRandomTilesByType" id="!?7mHd*?*F1|n3JgzwOK"><value name="maxCount"><shadow type="math_number" id="QjpSdjAa+/KH).uoHPR."><field name="NUM">10</field></shadow></value><value name="tile"><shadow type="tileset_tile_picker" id="4]otI{y/-qGua|RC2T-t"><field name="tile">sprites.castle.tileGrass2</field></shadow></value></block></value><statement name="DO"><block type="mapsettileat" id="}BIiJ=c}5(2]V2wW|R4."><value name="tile"><shadow type="tileset_tile_picker" id="02Pv$9CP4H5/PnL}G{.E"><field name="tile">sprites.dungeon.chestClosed</field></shadow></value><value name="loc"><shadow type="mapgettile" id="G$L]CQv7sajmHVQSMkAO"><value name="col"><shadow type="math_number" id="!|y]ze/uihU_uoPJ#mr3"><field name="NUM">0</field></shadow></value><value name="row"><shadow type="math_number" id="pu}Hu*KmaA?7{w}sZfrf"><field name="NUM">0</field></shadow></value></shadow><block type="variables_get" id="Z1Xq0bucD[/ftrvBe},D"><field name="VAR" id="Q1kh-W2=6(,YWift(^c|">value</field></block></value></block></statement></block></next></block></next></block></next></block></next></block></next></block></statement></block></xml>

main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ let mySprite = sprites.create(img`
2828
tiles.placeOnTile(mySprite, tiles.getTileLocation(2, 2))
2929
controller.moveSprite(mySprite)
3030
scene.cameraFollowSprite(mySprite)
31-
for (let value of getRandomTilesByType(sprites.castle.tileGrass2, 10)) {
31+
for (let value of tilesExt.getRandomTilesByType(sprites.castle.tileGrass2, 10)) {
3232
tiles.setTileAt(value, sprites.dungeon.chestClosed)
3333
}

maze.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ namespace maze {
1515
* @param corridorSize width of corridors
1616
* @param seed initialize the random number generator
1717
*/
18+
//% blickId=maze_generateTilemap
1819
//% block="Create $algorithm maze tilemap, width $mazeWidth height $mazeHeight wall $wall floor $floor || corridorSize $corridorSize seed $seed"
1920
//% wall.shadow=tileset_tile_picker
2021
//% floor.shadow=tileset_tile_picker

tilemapExt.ts

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
// Add your code here
2-
/**
3-
* Get a random tile of the given type
4-
* @param tile the type of tile to get a random selection of
5-
*/
61
//% blockNamespace=scene
7-
//% group=Locations
8-
//% block="array of max $maxCount $tile locations"
9-
//% tile.shadow=tileset_tile_picker
10-
function getRandomTilesByType(tile: Image, maxCount: number): tiles.Location[] {
11-
const scene = game.currentScene();
12-
if (!tile || !scene.tileMap)
13-
return undefined;
14-
const index = scene.tileMap.getImageType(tile);
15-
return scene.tileMap.sampleTilesByType(index, maxCount);
2+
namespace tilesExt {
3+
/**
4+
* Get a random tile of the given type
5+
* @param tile the type of tile to get a random selection of
6+
*/
7+
//% blockId=tilesExt_getRandomTilesByType
8+
//% group=Locations
9+
//% block="array of max $maxCount $tile locations"
10+
//% tile.shadow=tileset_tile_picker
11+
export function getRandomTilesByType(tile: Image, maxCount: number): tiles.Location[] {
12+
const scene = game.currentScene();
13+
if (!tile || !scene.tileMap)
14+
return undefined;
15+
const index = scene.tileMap.getImageType(tile);
16+
return scene.tileMap.sampleTilesByType(index, maxCount);
17+
}
1618
}

0 commit comments

Comments
 (0)