# Boulders and Gems (work in progress)

**URL:** <https://forum.makecode.com/t/boulders-and-gems-work-in-progress/3365>\
**Category:** Show & Tell\
**Tags:** game\
**Created:** [September 4, 2020, 11:58pm UTC](https://forum.makecode.com/t/boulders-and-gems-work-in-progress/3365 "2020-09-04T23:58:51Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![kwx](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/kwx/32/1545_2.png) [@kwx](https://forum.makecode.com/u/kwx)\
**Post date:** [September 4, 2020, 11:58pm UTC](https://forum.makecode.com/t/boulders-and-gems-work-in-progress/3365/1 "2020-09-04T23:58:51Z")

</div>

Can you collect all the gems without getting crushed by boulders?

> **[Boulders and Gems](https://arcade.makecode.com/99846-20673-19874-37018)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

This is a work in progress and it’s obviously inspired by Boulder Dash, but with a focus on puzzles instead of quick reactions. (There’s no timer, and no need for fast inputs.) It currently has five levels. The first two are quick tutorials, but later ones get a bit more devious.

If you get stuck, press the A+B buttons together to restart the level at the cost of a life.

I’ll look into adding enemies and more levels next, and maybe making the graphics and effects a bit less placeholder-y.

From the coding side, this should be using only Blocks functionality, though I did some editing in JS for convenience which may have resulted in leftover bits. I’m new to MakeCode Arcade so I likely missed out on easier ways to do things.

There’s slightly tricky logic to keep the directional inputs responsive even though the world is updating only 5 times/second. It’s also very important to avoid accidental double movement since that can be deadly in this game.

I haven’t had a chance to try this on real hardware yet, so it’s possible that it doesn’t run well. (The rock falling physics are rather crude.) Please let me know how it works for you if you try it, or if you find bugs or have suggestions. Enjoy!

---

<div class="post-metadata">

**Author:** ![Dreadmask197](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/dreadmask197/32/10494_2.png) [@Dreadmask197](https://forum.makecode.com/u/Dreadmask197)\
**Post date:** [September 5, 2020, 12:31am UTC](https://forum.makecode.com/t/boulders-and-gems-work-in-progress/3365/2 "2020-09-05T00:31:28Z")

</div>

This reminds me of dig dug

---

<div class="post-metadata">

**Author:** ![kwx](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/kwx/32/1545_2.png) [@kwx](https://forum.makecode.com/u/kwx)\
**Post date:** [September 6, 2020, 8:08pm UTC](https://forum.makecode.com/t/boulders-and-gems-work-in-progress/3365/3 "2020-09-06T20:08:06Z")

</div>

Here’s a new version:

> **[Boulders and Gems](https://arcade.makecode.com/28391-34235-57168-80111)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

Changes:

- long-press the B button to restart a level. (Pressing A+B together didn’t work in the simulator with touch/mouse input.)
- added a 6th level.

---

<div class="post-metadata">

**Author:** ![Dreadmask197](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/dreadmask197/32/10494_2.png) [@Dreadmask197](https://forum.makecode.com/u/Dreadmask197)\
**Post date:** [September 10, 2020, 12:59am UTC](https://forum.makecode.com/t/boulders-and-gems-work-in-progress/3365/4 "2020-09-10T00:59:03Z")

</div>

I can’t get past the third level. It’s hard but fun!! The game is lit 🔥

---

<div class="post-metadata">

**Author:** ![kwx](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/kwx/32/1545_2.png) [@kwx](https://forum.makecode.com/u/kwx)\
**Post date:** [September 10, 2020, 1:16am UTC](https://forum.makecode.com/t/boulders-and-gems-work-in-progress/3365/5 "2020-09-10T01:16:07Z")

</div>

Thanks! Here’s an updated version with a level select function, walk onto the “?” mark to skip levels:

> **[Boulders and Gems](https://arcade.makecode.com/40925-99041-82474-53815)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

It fixes a few bugs, i.e. it now blocks input after switching levels to avoid accidental movement, and I’ve slightly tweaked some of the levels. Watch out for traps in level 4 😈

---

<div class="post-metadata">

**Author:** ![kwx](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/kwx/32/1545_2.png) [@kwx](https://forum.makecode.com/u/kwx)\
**Post date:** [September 10, 2020, 6:37am UTC](https://forum.makecode.com/t/boulders-and-gems-work-in-progress/3365/6 "2020-09-10T06:37:11Z")

</div>

I added two new levels. Level 8 might be a bit unreasonable, if you’re able to solve it please let me know.

> **[Boulders and Gems](https://arcade.makecode.com/73009-78281-51325-18849)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

---

<div class="post-metadata">

**Author:** ![Dreadmask197](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/dreadmask197/32/10494_2.png) [@Dreadmask197](https://forum.makecode.com/u/Dreadmask197)\
**Post date:** [September 10, 2020, 11:27am UTC](https://forum.makecode.com/t/boulders-and-gems-work-in-progress/3365/7 "2020-09-10T11:27:47Z")

</div>

![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/5/5ae05675ea4857eebfb32f4749f4f6644126aaec.png)  
Whoops

---

<div class="post-metadata">

**Author:** ![darzu](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/darzu/32/1882_2.png) [@darzu](https://forum.makecode.com/u/darzu)\
**Post date:** [September 10, 2020, 4:27pm UTC](https://forum.makecode.com/t/boulders-and-gems-work-in-progress/3365/8 "2020-09-10T16:27:43Z")

</div>

This looks great!!

@tballmsft has been working on a similar game 😉

---

<div class="post-metadata">

**Author:** ![kwx](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/kwx/32/1545_2.png) [@kwx](https://forum.makecode.com/u/kwx)\
**Post date:** [September 10, 2020, 4:58pm UTC](https://forum.makecode.com/t/boulders-and-gems-work-in-progress/3365/9 "2020-09-10T16:58:39Z")

</div>

Thanks for the pointer, I remember seeing a link to @tballmsft’s post as I was publishing my version, the forum’s “have you seen these similar topics” feature works impressively well. Unfortunately I couldn’t get it working, I’ll follow up in that thread.

@darzu, I have started using the [https://github.com/microsoft/pxt-tilemaps](https://github.com/microsoft/pxt-tilemaps) extension which greatly simplified the level setup, thanks for that.

I still have some slightly gnarly code in `startLevel` to determine the dimensions of tilemaps and the pixel size of a tile using blocks code, that data only seemed to be available at the JS level by poking around in internals.

---

<div class="post-metadata">

**Author:** ![darzu](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/darzu/32/1882_2.png) [@darzu](https://forum.makecode.com/u/darzu)\
**Post date:** [September 10, 2020, 5:04pm UTC](https://forum.makecode.com/t/boulders-and-gems-work-in-progress/3365/10 "2020-09-10T17:04:15Z")

</div>

Thanks for the feedback! We could probably add some blocks to simplify that. Do you have a recommendation for what block would be most useful?

---

<div class="post-metadata">

**Author:** ![kwx](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/kwx/32/1545_2.png) [@kwx](https://forum.makecode.com/u/kwx)\
**Post date:** [September 10, 2020, 5:14pm UTC](https://forum.makecode.com/t/boulders-and-gems-work-in-progress/3365/11 "2020-09-10T17:14:54Z")

</div>

@darzu, I think it would be easiest to follow the example of the existing sprite attribute value getter, the one showing as `mySprite▼ x▼` in the editor. For tilemaps, I think the tricky part is to avoid confusion between pixel sizes and tile counts, so using width/height could be ambiguous. Maybe _rows_ and _columns_ tilemap attributes for the tile counts, and a separate _tileSize_ in pixels?

(I had been using “place sprite on tile” to get x/y values from the sprite.)

---

<div class="post-metadata">

**Author:** ![jacob\_c](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/jacob_c/32/1532_2.png) [@jacob\_c](https://forum.makecode.com/u/jacob_c)\
**Post date:** [September 10, 2020, 5:18pm UTC](https://forum.makecode.com/t/boulders-and-gems-work-in-progress/3365/12 "2020-09-10T17:18:02Z")

</div>

> [@kwx](#):
>
> I still have some slightly gnarly code in `startLevel` to determine the dimensions of tilemaps and the pixel size of a tile using blocks code.

I _think_ the blocks you want are actually in the tilemaps extension already (though I may be misunderstanding your request):

 ![Screen Shot 2020-09-10 at 10.14.19 AM](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/9/9b7ac2621d610d2c3dd22ff412f13370b12ad818.png)

---

<div class="post-metadata">

**Author:** ![kwx](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/kwx/32/1545_2.png) [@kwx](https://forum.makecode.com/u/kwx)\
**Post date:** [September 10, 2020, 5:24pm UTC](https://forum.makecode.com/t/boulders-and-gems-work-in-progress/3365/13 "2020-09-10T17:24:44Z")

</div>

Ah, nevermind then. I had implemented the workaround when I was originally using the built-in tilemap functionality, and totally missed that the extension already has that. It works as expected, thanks!

---

<div class="post-metadata">

**Author:** ![kwx](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/kwx/32/1545_2.png) [@kwx](https://forum.makecode.com/u/kwx)\
**Post date:** [September 10, 2020, 5:56pm UTC](https://forum.makecode.com/t/boulders-and-gems-work-in-progress/3365/14 "2020-09-10T17:56:43Z")

</div>

> **[Boulders and Gems](https://arcade.makecode.com/82533-15420-59157-81720)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

I updated the code to use the tile rows/columns/width attributes to simplify it, and fixed a rock physics glitch which had prevented rocks from dropping in some cases. (I need a test suite, I manually went through all levels to make sure the change didn’t break any of the puzzles. It still took me three tries to solve level 8…)

For anyone curious, the rock physics aren’t quite the same as in the original Boulder Dash. The original had gems drop differently from boulders, while mine treats both the same. Also, you can’t outrun a dropping rock, and boulder pushing works up/left/right into an empty space, not just left/right. I’m not planning on changing that, it seems more consistent for this puzzle-focused variant.

There are a few cases where you can use quick inputs to nudge a falling boulder, but none of the levels require that. (At least for now 👿)

---

<div class="post-metadata">

**Author:** ![kwx](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/kwx/32/1545_2.png) [@kwx](https://forum.makecode.com/u/kwx)\
**Post date:** [September 11, 2020, 5:46am UTC](https://forum.makecode.com/t/boulders-and-gems-work-in-progress/3365/15 "2020-09-11T05:46:46Z")

</div>

@tballmsft convinced me to add animated transitions:

> **[Boulders and Gems](https://arcade.makecode.com/14387-51095-53420-83010)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

I went with a tile-based approach since changing the game to use sprites for everything would be a fairly major undertaking. It’s still a bit tedious, and I largely gave up on keeping the code strictly blocks-compatible, but the setup looks surprisingly intuitive in the blocks editor:

 ![makecode-setupAnimations](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/4/4a9ef97f5818412b593e6089e2dc82af194f67a1.png)

(Sorry about the frequent updates, I’ll try to be less chatty about my game. Let me know if there’s a preferred way to handle re-releases if this annoys people.)

---

<div class="post-metadata">

**Author:** ![LcAtonal](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/lcatonal/32/16800_2.png) [@LcAtonal](https://forum.makecode.com/u/LcAtonal)\
**Post date:** [September 11, 2020, 8:27am UTC](https://forum.makecode.com/t/boulders-and-gems-work-in-progress/3365/16 "2020-09-11T08:27:59Z")

</div>

That would have took you quite a while

---

<div class="post-metadata">

**Author:** ![kwx](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/kwx/32/1545_2.png) [@kwx](https://forum.makecode.com/u/kwx)\
**Post date:** [September 11, 2020, 4:21pm UTC](https://forum.makecode.com/t/boulders-and-gems-work-in-progress/3365/17 "2020-09-11T16:21:37Z")

</div>

It wasn’t that bad, basically some cut&paste both for the code and tiles. The picture editor’s rectangle select made it easy to shift a copied tile over by a few pixels, and there aren’t all that many unique pieces needed. I wouldn’t want to do that for more than two objects though…

---

<div class="post-metadata">

**Author:** ![darzu](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/darzu/32/1882_2.png) [@darzu](https://forum.makecode.com/u/darzu)\
**Post date:** [September 11, 2020, 4:49pm UTC](https://forum.makecode.com/t/boulders-and-gems-work-in-progress/3365/18 "2020-09-11T16:49:43Z")

</div>

Also it might be useful to know I’ve been working on an extension to make grid-based games easier to make:

> [@GemCrush and "Sprite Grid" extension beta](https://forum.makecode.com/t/gemcrush-and-sprite-grid-extension-beta/1842):
>
> Hello world, I tried to make a Bejeweled-like game in blocks and found it very difficult, so I created a “sprite grid” extension that can track sprites on a grid. The extension is here (early beta): [https://github.com/microsoft/arcade-grid](https://github.com/microsoft/arcade-grid) And the game is here: [https://makecode.com/\_RbDi9mYx6TwJ](https://makecode.com/_RbDi9mYx6TwJ) Grid extension blocks: Cheers, Daryl

---

<div class="post-metadata">

**Author:** ![Dreadmask197](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/dreadmask197/32/10494_2.png) [@Dreadmask197](https://forum.makecode.com/u/Dreadmask197)\
**Post date:** [September 13, 2020, 11:49am UTC](https://forum.makecode.com/t/boulders-and-gems-work-in-progress/3365/19 "2020-09-13T11:49:04Z")

</div>

Cool with the animations and arrays you put in. It actually looks like the boulders are falling

---

<div class="post-metadata">

**Author:** ![NxNMatrixGL](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/nxnmatrixgl/32/2553_2.png) [@NxNMatrixGL](https://forum.makecode.com/u/NxNMatrixGL)\
**Post date:** [December 24, 2020, 4:28pm UTC](https://forum.makecode.com/t/boulders-and-gems-work-in-progress/3365/20 "2020-12-24T16:28:50Z")

</div>

I got a VIC-20 for my son a year ago and he is a big fan of many of the VIC-20 games. He expressed interest in making some VIC-20 games on MS MakeCode Arcade - Squish’em, Clowns, Cloudburst, and Boulder Dan (a 2013 clone version of Boulder Dash). I have to show him this one. Boulder Dan is one of his favorites!

[Next page](https://forum.makecode.com/t/boulders-and-gems-work-in-progress/3365.md?page=2)
