# Random Map Event Generation 🗺 (like Slay the Spire)

**URL:** <https://forum.makecode.com/t/random-map-event-generation-like-slay-the-spire/29739>\
**Category:** Show & Tell\
**Tags:** graphics-and-math, make, demo\
**Created:** [July 18, 2024, 5:04pm UTC](https://forum.makecode.com/t/random-map-event-generation-like-slay-the-spire/29739 "2024-07-18T17:04:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Luke](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/luke/32/32519_2.png) [@Luke](https://forum.makecode.com/u/Luke)\
**Post date:** [July 18, 2024, 5:04pm UTC](https://forum.makecode.com/t/random-map-event-generation-like-slay-the-spire/29739/1 "2024-07-18T17:04:56Z")

</div>

> **[Random Map Generation](https://arcade.makecode.com/86229-22431-40912-84220)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

A to move to next event  
If a crossroad, B to select other path  
up and down to move map  
Menu to toggle map

This was way more difficult to implement than the previous map I’ve coded due to the 3-4 paths instead of one, but it’s definitely worth it. [Old map here](https://forum.makecode.com/t/card-game-sprites-behaving-in-satisfying-unintentional-ways/20445/10) (adding this to Card Delver is going to take a while 🫠)  
The map is only 1 big sprite so you can scale this map as large as you want without lagging the game with an insane amount of sprites.  
Each time you reset the simulator you will get a completely random map but it always ends with the purple events (boss fights/chests)  
The event names and images are just placeholders, I left them blank incase anyone wants to use this code too.

---

<div class="post-metadata">

**Author:** ![randomuser](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/randomuser/32/32505_2.png) [@randomuser](https://forum.makecode.com/u/randomuser)\
**Post date:** [July 22, 2024, 4:26am UTC](https://forum.makecode.com/t/random-map-event-generation-like-slay-the-spire/29739/2 "2024-07-22T04:26:02Z")

</div>

Why was there no hype around this? This is cool!! I can see it being useful for expanding procedural games like the infinite platformer into more mario-style games in which not just the levels but the maps are generated as well.

---

<div class="post-metadata">

**Author:** ![Luke](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/luke/32/32519_2.png) [@Luke](https://forum.makecode.com/u/Luke)\
**Post date:** [July 22, 2024, 3:09pm UTC](https://forum.makecode.com/t/random-map-event-generation-like-slay-the-spire/29739/3 "2024-07-22T15:09:51Z")

</div>

Yeah it has so much use outside of card delver where it was designed (main issue is that the code is an abomination lol)

---

<div class="post-metadata">

**Author:** ![Allegory\_Cheese](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/allegory_cheese/32/31845_2.png) [@Allegory\_Cheese](https://forum.makecode.com/u/Allegory_Cheese)\
**Post date:** [November 29, 2025, 9:38pm UTC](https://forum.makecode.com/t/random-map-event-generation-like-slay-the-spire/29739/4 "2025-11-29T21:38:29Z")

</div>

> [@Luke](#):
>
> [https://arcade.makecode.com/86229-22431-40912-84220](https://arcade.makecode.com/86229-22431-40912-84220)

luke how do u make the lines connect?

---

<div class="post-metadata">

**Author:** ![Luke](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/luke/32/32519_2.png) [@Luke](https://forum.makecode.com/u/Luke)\
**Post date:** [November 30, 2025, 1:02am UTC](https://forum.makecode.com/t/random-map-event-generation-like-slay-the-spire/29739/5 "2025-11-30T01:02:54Z")

</div>

![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/3/6/3605176abf8103c18e920c9432c7473d40d7bd77.png)

used it here:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/6/f/6fa5cc81d5fde96fa6d3b4fbb1b4a9862d4002fe.png)

and here is its final implementation in card delver (i drew the line with an x offset to get the 2px thick lines)

![Map](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/8/f/8f027cb2275650b28b8a942148967578216e304a.gif)

i might post the full explanation for the code once im done relearning it but the gist of it is

1. randomly generate something with enough variation to be unique yet consistency so it’s actually playable. I use the RNG extension so that all random variables can be “rerolled” to form the exact same map after the seed is set
2. store that data with nested arrays (store map data)
3. track player position on the map as an array
4. draw the map and player location data to a sprite that works the same way each time it’s opened
