Microsoft MakeCode

Boulders and Gems (work in progress)

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

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!

4 Likes

This reminds me of dig dug

1 Like

Here’s a new version:

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.
4 Likes

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

1 Like

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

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 :smiling_imp:

1 Like

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

1 Like

image
Whoops

1 Like

This looks great!!

@tballmsft has been working on a similar game :wink:

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 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.

1 Like

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?

@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.)

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

1 Like

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!

2 Likes

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 :imp:)

1 Like

@tballmsft convinced me to add animated transitions:

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:

(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.)

3 Likes

That would have took you quite a while

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…

1 Like

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

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