# Raycasting 3D render -- Blocks Edition

**URL:** <https://forum.makecode.com/t/raycasting-3d-render-blocks-edition/12921>\
**Category:** Game Design\
**Tags:** game, graphics-and-math, extension\
**Created:** [April 1, 2022, 6:23pm UTC](https://forum.makecode.com/t/raycasting-3d-render-blocks-edition/12921 "2022-04-01T18:23:28Z")\
**Posts on this page:** 20\
**Page:** 4

<div class="post-metadata">

**Author:** ![AqeeAqee](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/aqeeaqee/32/5424_2.png) [@AqeeAqee](https://forum.makecode.com/u/AqeeAqee)\
**Post date:** [June 6, 2022, 8:16pm UTC](https://forum.makecode.com/t/raycasting-3d-render-blocks-edition/12921/62 "2022-06-06T20:16:16Z")

</div>

### preview Walking Sway 2

- set with this block as well, but 1~2 would be fine, and be float number, eg.: 1.5
- the ratio of sway L/R and “jump” U/D is 1:3, can be adjust only in my code. To simplify the code and keep perf, they are in difference unit now, L/R is in screen pixel, U/D is in Z dimension pixel(ZOffset/ZPosition)
- let me know if you feel current ratio is not reasonable or not comfortable.  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/optimized/2X/d/de0fe109f7b60ab8d91def99cddc0d4632ea4514_2_517x48.png)

> **[previewSway\_v2\_Raycasting](https://arcade.makecode.com/91969-65993-44293-92060)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

---

<div class="post-metadata">

**Author:** ![AqeeAqee](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/aqeeaqee/32/5424_2.png) [@AqeeAqee](https://forum.makecode.com/u/AqeeAqee)\
**Post date:** [June 6, 2022, 9:28pm UTC](https://forum.makecode.com/t/raycasting-3d-render-blocks-edition/12921/63 "2022-06-06T21:28:21Z")

</div>

@jwunderl @CarltonFade @Kiwiphoenix364  
Hi guys!  
**as to the multi-level and floor/ceiling:**  
Thanks for your valuable suggestions! These will be adopt when I coding them.

I did some test, the FPS will down to about 8 on device/console with just drawing walls twice. So this extension is not fast enough to do these features right now, I think. We can’t add these until perf has a significant impovement some day.  
But, I know, these are all attractive features, I love them too. I will do my best to optimize perf furture. I am thinking about a new optimized algorithm based on raycasting. But it is a big change, need some time to rewrite almost **ALL** the rendering codes of walls, and then check it works or not.  
Hope I can made it. 🤣

And leave your comments above 2 new previews pls. It won’t be merge into the extension, until you are satisfied with these results.

Thanks a lot for your support as always!

---

<div class="post-metadata">

**Author:** ![AqeeAqee](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/aqeeaqee/32/5424_2.png) [@AqeeAqee](https://forum.makecode.com/u/AqeeAqee)\
**Post date:** [June 6, 2022, 9:28pm UTC](https://forum.makecode.com/t/raycasting-3d-render-blocks-edition/12921/64 "2022-06-06T21:28:30Z")

</div>

Hi @Sarge  
You mean the “myself” showing before a tilemap loaded, right?  
Actually, this fixed in last release, but I found It was covered back by an accident. Will be fixed again in next release.  
Sorry for that!

---

<div class="post-metadata">

**Author:** ![CarltonFade](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/carltonfade/32/6381_2.png) [@CarltonFade](https://forum.makecode.com/u/CarltonFade)\
**Post date:** [June 6, 2022, 9:28pm UTC](https://forum.makecode.com/t/raycasting-3d-render-blocks-edition/12921/65 "2022-06-06T21:28:35Z")

</div>

Well done Aqee!

Also, well done on the Camera Sway! It works really well, exactly as I thought it would look!  
I’m looking to more of the wizardry you’re able to pull off.

Have a great day!

---

<div class="post-metadata">

**Author:** ![AqeeAqee](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/aqeeaqee/32/5424_2.png) [@AqeeAqee](https://forum.makecode.com/u/AqeeAqee)\
**Post date:** [June 7, 2022, 5:06pm UTC](https://forum.makecode.com/t/raycasting-3d-render-blocks-edition/12921/66 "2022-06-07T17:06:44Z")

</div>

Go ahead, lol 😅

---

<div class="post-metadata">

**Author:** ![brandodon](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/brandodon/32/3625_2.png) [@brandodon](https://forum.makecode.com/u/brandodon)\
**Post date:** [June 7, 2022, 5:07pm UTC](https://forum.makecode.com/t/raycasting-3d-render-blocks-edition/12921/67 "2022-06-07T17:07:21Z")

</div>

Do you think that you could maybe optimize by having a way to like load in walls with rendering? maybe looking like Minecraft’s system of only loading what’s in sight, and the sprites always stay there? idk that’s just a suggestion.

---

<div class="post-metadata">

**Author:** ![jackal](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/jackal/32/19506_2.png) [@jackal](https://forum.makecode.com/u/jackal)\
**Post date:** [June 7, 2022, 5:07pm UTC](https://forum.makecode.com/t/raycasting-3d-render-blocks-edition/12921/68 "2022-06-07T17:07:30Z")

</div>

Quick question: in future updates would be able to use the p2 controls for looking up and down?  
(I won’t be mad/dissapointed if you say no, Makecode has a lot of capabilities, but not really for 3D/2.5D games)

---

<div class="post-metadata">

**Author:** ![Kiwiphoenix364](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/kiwiphoenix364/32/14368_2.png) [@Kiwiphoenix364](https://forum.makecode.com/u/Kiwiphoenix364)\
**Post date:** [June 7, 2022, 6:39pm UTC](https://forum.makecode.com/t/raycasting-3d-render-blocks-edition/12921/69 "2022-06-07T18:39:13Z")

</div>

I know you’re rewriting the engine (and probably don’t want more suggestions), but it would be nice to have an option to render sideways as well, so you could make a first person 2d platformer!

---

<div class="post-metadata">

**Author:** ![AqeeAqee](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/aqeeaqee/32/5424_2.png) [@AqeeAqee](https://forum.makecode.com/u/AqeeAqee)\
**Post date:** [June 7, 2022, 9:00pm UTC](https://forum.makecode.com/t/raycasting-3d-render-blocks-edition/12921/70 "2022-06-07T21:00:01Z")

</div>

Ah, thanks for your advice for optimaization.  
Our Arcade devices has some diff from a PC/Mac, we have no real external storage which will take advantage of loading partial resouces. If some day we can save/load files in SD card, this will be useful.

---

<div class="post-metadata">

**Author:** ![AqeeAqee](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/aqeeaqee/32/5424_2.png) [@AqeeAqee](https://forum.makecode.com/u/AqeeAqee)\
**Post date:** [June 7, 2022, 9:00pm UTC](https://forum.makecode.com/t/raycasting-3d-render-blocks-edition/12921/71 "2022-06-07T21:00:10Z")

</div>

> [@Kiwiphoenix364](#):
>
> render sideways

Sorry, not sure your meaning with “sideways”.  
Once a time, I tried to play my meowbit turned 90°, like this. Is it what you want?  
(just a test at that time, keys doesn’t remapping yet )

> **[platformer-Raycasting](https://arcade.makecode.com/91203-15174-59752-84926)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

---

<div class="post-metadata">

**Author:** ![AqeeAqee](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/aqeeaqee/32/5424_2.png) [@AqeeAqee](https://forum.makecode.com/u/AqeeAqee)\
**Post date:** [June 7, 2022, 9:00pm UTC](https://forum.makecode.com/t/raycasting-3d-render-blocks-edition/12921/72 "2022-06-07T21:00:14Z")

</div>

p2 controls may be considered to support.  
But raycasting can’t looking up/down very well. Maybe a little angle is possible, but not very useful, I thinks.

---

<div class="post-metadata">

**Author:** ![Kiwiphoenix364](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/kiwiphoenix364/32/14368_2.png) [@Kiwiphoenix364](https://forum.makecode.com/u/Kiwiphoenix364)\
**Post date:** [June 7, 2022, 9:09pm UTC](https://forum.makecode.com/t/raycasting-3d-render-blocks-edition/12921/73 "2022-06-07T21:09:29Z")

</div>

Yeah, I mean have the option to render it sideways, so you have looking up/down, INSTEAD of left/right, so you are basically the sprite in a platforming game, but you can’t look/move left or right. You can move up/down/forward/backwards instead of left/right/forward/backwards. (Kind of hard to explain, but basically you make the renderer flip the image by 90°.

---

<div class="post-metadata">

**Author:** ![AqeeAqee](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/aqeeaqee/32/5424_2.png) [@AqeeAqee](https://forum.makecode.com/u/AqeeAqee)\
**Post date:** [June 8, 2022, 4:21pm UTC](https://forum.makecode.com/t/raycasting-3d-render-blocks-edition/12921/74 "2022-06-08T16:21:31Z")

</div>

Sorry, I am still not able to guess out what rendering effect you want. Would like paste a screenshot of that kind of game?  
What I imagined is a traditional platform, like mario, but in 3D,something like this:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/6/61fcb5b708d5cd73eabda763dc8e9b696a1f1517.jpeg)

---

<div class="post-metadata">

**Author:** ![Kiwiphoenix364](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/kiwiphoenix364/32/14368_2.png) [@Kiwiphoenix364](https://forum.makecode.com/u/Kiwiphoenix364)\
**Post date:** [June 8, 2022, 6:16pm UTC](https://forum.makecode.com/t/raycasting-3d-render-blocks-edition/12921/75 "2022-06-08T18:16:49Z")

</div>

Yep, that’s what I imagined, but in first person instead of 3rd person.

---

<div class="post-metadata">

**Author:** ![AqeeAqee](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/aqeeaqee/32/5424_2.png) [@AqeeAqee](https://forum.makecode.com/u/AqeeAqee)\
**Post date:** [June 8, 2022, 9:28pm UTC](https://forum.makecode.com/t/raycasting-3d-render-blocks-edition/12921/76 "2022-06-08T21:28:32Z")

</div>

That’s easy, just remove the “person”, right?  
But how to play with It?

---

<div class="post-metadata">

**Author:** ![Sarge](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/sarge/32/19590_2.png) [@Sarge](https://forum.makecode.com/u/Sarge)\
**Post date:** [June 8, 2022, 10:06pm UTC](https://forum.makecode.com/t/raycasting-3d-render-blocks-edition/12921/77 "2022-06-08T22:06:12Z")

</div>

How would you make a 3rd person camera with this though? Perhaps myself sprite following the sprite you want to control but i can’t figure out how to make directions properly

---

<div class="post-metadata">

**Author:** ![personalnote](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/personalnote/32/31359_2.png) [@personalnote](https://forum.makecode.com/u/personalnote)\
**Post date:** [June 8, 2022, 11:58pm UTC](https://forum.makecode.com/t/raycasting-3d-render-blocks-edition/12921/78 "2022-06-08T23:58:35Z")

</div>

I think he means that you play as the 2d character through a first-person perspective. You can’t turn left or right but only can look up and down as it is in traditional 2D platformers.

The only problem I see is making the camera look up and down, but if you can manage something like y-shearing (a technique ppl used in the Doom engine to give the illusion of looking up and down), I think it could work.

---

<div class="post-metadata">

**Author:** ![AqeeAqee](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/aqeeaqee/32/5424_2.png) [@AqeeAqee](https://forum.makecode.com/u/AqeeAqee)\
**Post date:** [June 9, 2022, 7:01pm UTC](https://forum.makecode.com/t/raycasting-3d-render-blocks-edition/12921/79 "2022-06-09T19:01:56Z")

</div>

@Kiwiphoenix364 @Sarge @personalnote

- Yes, this kind of game just is of a traditional 2d platform game, as well as control, except rendering tiles with 3d cube images. These Images can be build from tile image, and cached, and updated when view angle changing.
- The y-shearing, I read it in one of your posts before, I will try to make it later when I am free.
- Whatever, 1st person or 3rd person, this rendering is out of raycasting algorithm doing. But this effect is funny and maybe some one want it. And it’s possible to implement, and not very difficult, I think. It could be a new rendering extension. So shell we open a new thread, for discussing and developing it?

---

<div class="post-metadata">

**Author:** ![Sarge](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/sarge/32/19590_2.png) [@Sarge](https://forum.makecode.com/u/Sarge)\
**Post date:** [June 9, 2022, 8:39pm UTC](https://forum.makecode.com/t/raycasting-3d-render-blocks-edition/12921/80 "2022-06-09T20:39:46Z")

</div>

> [@AqeeAqee](#):
>
> Whatever, 1st person or 3rd person, this rendering is out of raycasting algorithm doing. But this effect is funny and maybe some one want it. And it’s possible to implement, and not very difficult, I think. It could be a new rendering extension. So shell we open a new thread, for discussing and developing it?

I think that would be nice

---

<div class="post-metadata">

**Author:** ![AqeeAqee](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/aqeeaqee/32/5424_2.png) [@AqeeAqee](https://forum.makecode.com/u/AqeeAqee)\
**Post date:** [June 14, 2022, 5:12pm UTC](https://forum.makecode.com/t/raycasting-3d-render-blocks-edition/12921/81 "2022-06-14T17:12:39Z")

</div>

Hi all  
**v0.3.14** just released.

- again, fix takeover myselft sprite before tilemap loaded.
- add particle effect support. Need provide duration value, doesn’t support default(empty) value.
- add walking sway, set with “move With Controller” block
- add get/setSpriteAttribute(), and docs
- say frame closer to sprite
- enlarge say size
- some slight perf optimization

issue:  
large area copying cause tremble(sayText and particle)

> **[demo\_pxt-RaycastingV0.3.14](https://arcade.makecode.com/68514-71798-13887-34316)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

_If you didn’t updated prev version v0.3.13, you need do following this time:_  
\*\* there will be two extension “pxt-Raycasting” and “pxt-raycasting”, delete previous one please.\*  
\*\* update setAttribute() name in your codes if there is.\*

[Previous page](https://forum.makecode.com/t/raycasting-3d-render-blocks-edition/12921.md?page=3)

[Next page](https://forum.makecode.com/t/raycasting-3d-render-blocks-edition/12921.md?page=5)
