# Castle

**URL:** <https://forum.makecode.com/t/castle/31644>\
**Category:** Arcade\
**Created:** [November 11, 2024, 11:48pm UTC](https://forum.makecode.com/t/castle/31644 "2024-11-11T23:48:45Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Spooky\_Gamer](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/spooky_gamer/32/18018_2.png) [@Spooky\_Gamer](https://forum.makecode.com/u/Spooky_Gamer)\
**Post date:** [November 11, 2024, 11:48pm UTC](https://forum.makecode.com/t/castle/31644/1 "2024-11-11T23:48:45Z")

</div>

this is NOT my first game. just a new forum acc.

> **[Castle](https://arcade.makecode.com/S56667-92211-31476-11900)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

Warning! this game crashes a lot! if you find any bugs, report them, or suggest changes to the code! thanks.  
do not spoil anything the game has to offer. there isnt a lot, but there will be much more later.  
Extra Stuff.  
Heavily based off of Spooky’s Jumpscare Mansion  
no end yet. it will be at door 500 later.  
Have fun!

---

<div class="post-metadata">

**Author:** ![anon30657772](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@anon30657772](https://forum.makecode.com/u/anon30657772)\
**Post date:** [November 13, 2024, 3:06pm UTC](https://forum.makecode.com/t/castle/31644/2 "2024-11-13T15:06:43Z")

</div>

Awesome game! I love the art of the enemy and the walls! And I like the idea of how you set the castle levels.

> **One thing however:**
>
> > Your level loading code sometimes crashes the game:  
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/optimized/3X/2/1/21269573094c611cc396623152b080416b05724d_2_690x52.png)
> 
> > The reason is because you are generating a random number between zero and the LENGTH of the list (from 0 to 5). This isn’t right because the “Get value at” block uses the INDEX of the level which starts counting from ZERO.  
> > Say we wanted to select the 5th level. The index would actually be 4 because it starts counting from zero.
> 
> > Since the “length of” block counts from 1 the max generated number can be a 5 which in index position doesn’t exist and results in the game crashing when it tries to load it.
> 
> > To fix this, simply make the random go from 0 to the length of the list - 1 !

I hope my explanation wasn’t too all over the place. Feel free to ask questions! Otherwise, keep up the good work!

---

<div class="post-metadata">

**Author:** ![MicroMan7](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/microman7/32/18103_2.png) [@MicroMan7](https://forum.makecode.com/u/MicroMan7)\
**Post date:** [November 14, 2024, 5:15am UTC](https://forum.makecode.com/t/castle/31644/3 "2024-11-14T05:15:05Z")

</div>

Very cool, is that RAY CASTING? :boom:

---

<div class="post-metadata">

**Author:** ![Spooky\_Gamer](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/spooky_gamer/32/18018_2.png) [@Spooky\_Gamer](https://forum.makecode.com/u/Spooky_Gamer)\
**Post date:** [November 16, 2024, 12:57am UTC](https://forum.makecode.com/t/castle/31644/4 "2024-11-16T00:57:51Z")

</div>

oh, nice! thanks a lot! this will speed up testing for sure!

---

<div class="post-metadata">

**Author:** ![XDgamer8967](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/xdgamer8967/32/15497_2.png) [@XDgamer8967](https://forum.makecode.com/u/XDgamer8967)\
**Post date:** [November 16, 2024, 5:22pm UTC](https://forum.makecode.com/t/castle/31644/5 "2024-11-16T17:22:43Z")

</div>

yo welcome back

---

<div class="post-metadata">

**Author:** ![MicroMan7](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/microman7/32/18103_2.png) [@MicroMan7](https://forum.makecode.com/u/MicroMan7)\
**Post date:** [November 17, 2024, 8:36pm UTC](https://forum.makecode.com/t/castle/31644/6 "2024-11-17T20:36:02Z")

</div>

I’m pretty sure I made it out the castle 🙂
