# New 3d Engine - Help filling 4-sided polygons

**URL:** <https://forum.makecode.com/t/new-3d-engine-help-filling-4-sided-polygons/18641>\
**Category:** Help\
**Tags:** graphics-and-math\
**Created:** [March 20, 2023, 5:06pm UTC](https://forum.makecode.com/t/new-3d-engine-help-filling-4-sided-polygons/18641 "2023-03-20T17:06:21Z")\
**Posts on this page:** 20\
**Page:** 2

<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:** [March 27, 2023, 11:07pm UTC](https://forum.makecode.com/t/new-3d-engine-help-filling-4-sided-polygons/18641/21 "2023-03-27T23:07:15Z")

</div>

YES @Brohann , I just added some math and this is what I have now:

> **[renderer-prototype](https://arcade.makecode.com/91608-95195-72120-48917)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

Use the second player’s controls to change the angle. (I,J,K,L)

I’ve also been working on adding collision checks, I added the ability to change the number of sides again in-game with up/down (again), but with some amounts of sides the level isn’t shown bc there is the wrong number of columns in the image. The collision checks use some math with angles to efficiently show whether you are inside the tunnel or not (I’m super happy with this logic). I don’t have the collision logic done yet, but the number of hearts switch between 7 and 3 when inside/outside the tunnel.

---

<div class="post-metadata">

**Author:** ![richard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/richard/32/5417_2.png) [@richard](https://forum.makecode.com/u/richard)\
**Post date:** [March 30, 2023, 10:08pm UTC](https://forum.makecode.com/t/new-3d-engine-help-filling-4-sided-polygons/18641/22 "2023-03-30T22:08:02Z")

</div>

Native triangle and 4-sided polygon fill is now in beta, courtesy of the wonderful @AqeeAqee! [https://arcade.makecode.com/beta#pub:\_J7PYHh23dWDw](https://arcade.makecode.com/beta#pub:_J7PYHh23dWDw)

My usual beta disclaimer: **Don’t do anything important in beta or open projects you care about! Beta is for testing new features only!**

---

<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:** [March 30, 2023, 10:19pm UTC](https://forum.makecode.com/t/new-3d-engine-help-filling-4-sided-polygons/18641/23 "2023-03-30T22:19:32Z")

</div>

YAYYYY! When will it get out of beta? It would be cool to see it very soon. Maybe even as a quick patch and not a full update if the next full update will take a while to come out (assuming the code doesn’t have bugs)? Either way, this is super exciting! Can’t wait to play around with it for my game!

---

<div class="post-metadata">

**Author:** ![richard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/richard/32/5417_2.png) [@richard](https://forum.makecode.com/u/richard)\
**Post date:** [March 30, 2023, 10:51pm UTC](https://forum.makecode.com/t/new-3d-engine-help-filling-4-sided-polygons/18641/24 "2023-03-30T22:51:37Z")

</div>

haha, I’ll try and do a hotfix for it in the next week or two!

---

<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:** [March 30, 2023, 10:59pm UTC](https://forum.makecode.com/t/new-3d-engine-help-filling-4-sided-polygons/18641/25 "2023-03-30T22:59:47Z")

</div>

Thanks!!!

---

<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:** [April 3, 2023, 4:30pm UTC](https://forum.makecode.com/t/new-3d-engine-help-filling-4-sided-polygons/18641/26 "2023-04-03T16:30:42Z")

</div>

[A Tangram Puzzles Animation](https://arcade.makecode.com/beta#pub:S29687-75979-91852-33938), demo of fillTriangle/fillPolygon4.

(Have to show a snapshot here, Gif can’t record correctly. And thumb doesn’t work, probably project was shared to formal site though I clicked on beta site?)

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

Inspired by a interesting usage of scene.createRenderable() in [one of @richard 's fill triangle demo project](https://arcade.makecode.com/beta#pub:S49613-21549-53722-36190)

Note, both projects runs on BETA site only, until this feature is published to formal site.

---

<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:** [April 3, 2023, 9:29pm UTC](https://forum.makecode.com/t/new-3d-engine-help-filling-4-sided-polygons/18641/27 "2023-04-03T21:29:52Z")

</div>

Oh dude, I love tangram! We had a project in school once where we played around with various combinations! That aside, your projects are incredible, the fast filling functions are super advanced, great job!

---

<div class="post-metadata">

**Author:** ![ChimbroDaPro](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/chimbrodapro/32/15852_2.png) [@ChimbroDaPro](https://forum.makecode.com/u/ChimbroDaPro)\
**Post date:** [April 4, 2023, 3:06pm UTC](https://forum.makecode.com/t/new-3d-engine-help-filling-4-sided-polygons/18641/28 "2023-04-04T15:06:00Z")

</div>

WOW. I don’t think I’ve ever been more confused in my entire life. Like, I’m actually trying so hard to think of a time I was more confused, but I just can’t find one.

---

<div class="post-metadata">

**Author:** ![jwunderl](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/jwunderl/32/5308_2.png) [@jwunderl](https://forum.makecode.com/u/jwunderl)\
**Post date:** [April 14, 2023, 10:39pm UTC](https://forum.makecode.com/t/new-3d-engine-help-filling-4-sided-polygons/18641/29 "2023-04-14T22:39:25Z")

</div>

Hey we did a thing

> **[Tangram](https://arcade.makecode.com/S29687-75979-91852-33938)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

Thanks again for the great prs!

---

<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:** [April 15, 2023, 12:43am UTC](https://forum.makecode.com/t/new-3d-engine-help-filling-4-sided-polygons/18641/30 "2023-04-15T00:43:06Z")

</div>

Wow, it is released hah!  
No problem! It’s my pleasure, of course, to contribute back to great Makecode Arcade!  
Thanks for you and @richard 's trust, this is a wonderful journey. 🎉

---

<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:** [April 16, 2023, 10:05pm UTC](https://forum.makecode.com/t/new-3d-engine-help-filling-4-sided-polygons/18641/31 "2023-04-16T22:05:26Z")

</div>

Thank you so much @richard, @jwunderl, @AqeeAqee, and whoever else (like other members on the MakeCode team) contributed to this release! This runs super smooth now!

> **[renderer-prototype](https://arcade.makecode.com/82170-98485-81323-67083)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

This will also allow for other 3d rendering systems to be developed, not having to work pixel-by-pixel, greatly improving performance! While my project most likely still won’t run on hardware due to the other math, these changes allow for much better performance in the sim! I could see many great uses for filled polygons in the future, and I’m excited for what will be possible in the future!

---

<div class="post-metadata">

**Author:** ![labfox29](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/labfox29/32/9252_2.png) [@labfox29](https://forum.makecode.com/u/labfox29)\
**Post date:** [May 30, 2023, 4:27pm UTC](https://forum.makecode.com/t/new-3d-engine-help-filling-4-sided-polygons/18641/32 "2023-05-30T16:27:23Z")

</div>

I wonder if anyone is going to try to expand apon this.

---

<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 16, 2023, 9:11pm UTC](https://forum.makecode.com/t/new-3d-engine-help-filling-4-sided-polygons/18641/33 "2023-06-16T21:11:14Z")

</div>

I abandoned this project for a while but now I’m back to begin making better collision. For now I just wanted to see how it would run at double res, and its surprisingly good. I will keep it as regular but it was just a fun experiment.

> **[renderer-prototype](https://arcade.makecode.com/80047-42766-70641-39555)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

---

<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 19, 2023, 4:59pm UTC](https://forum.makecode.com/t/new-3d-engine-help-filling-4-sided-polygons/18641/34 "2023-06-19T16:59:52Z")

</div>

Wow… 1,536 filled polygons…

> **[renderer-prototype](https://arcade.makecode.com/44243-98728-88365-89283)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

I added collision DETECTION, except this time its extremely accurate, using a line intersection algorithm (Thanks Bing AI, even though I had to spend like 2 hours debugging the code!), but I didn’t make it do stuff yet. If you open the console log, every time you collide with something, it will show the (assigned) index of the tile column that was collided with. BTW this project DOES run on hardware, it just can’t handle very many polys so the amount has to be cut down to around 40 to run at full perf. So I probably won’t plan on supporting hardware in the future unless I learn fX math. I also plan to add depth sorting in the future.

Also another note: With this same engine, it may be possible to make a DOOM clone if  
1: Rotation was added, so all the points in the scene rotate around the player (possibly using a lookup table to save on trig? Though that would make it slightly choppier because of the lack of precision in the amount of directions available.)  
2: A new map system was developed, perhaps using the BSP concept for depth sorting  
I probably won’t do this, but I might look into it for the future when I finish this project.

---

<div class="post-metadata">

**Author:** ![labfox29](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/labfox29/32/9252_2.png) [@labfox29](https://forum.makecode.com/u/labfox29)\
**Post date:** [June 19, 2023, 5:52pm UTC](https://forum.makecode.com/t/new-3d-engine-help-filling-4-sided-polygons/18641/35 "2023-06-19T17:52:43Z")

</div>

Not to be rude but the collision doesn’t work

---

<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 19, 2023, 7:11pm UTC](https://forum.makecode.com/t/new-3d-engine-help-filling-4-sided-polygons/18641/36 "2023-06-19T19:11:09Z")

</div>

As I said it’s collision DETECTION, but it doesn’t stop the player yet. It tells when you overlap but doesn’t do anything about it.

---

<div class="post-metadata">

**Author:** ![labfox29](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/labfox29/32/9252_2.png) [@labfox29](https://forum.makecode.com/u/labfox29)\
**Post date:** [June 19, 2023, 9:26pm UTC](https://forum.makecode.com/t/new-3d-engine-help-filling-4-sided-polygons/18641/37 "2023-06-19T21:26:15Z")

</div>

oh, oops

---

<div class="post-metadata">

**Author:** ![YuHayate](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/yuhayate/32/8275_2.png) [@YuHayate](https://forum.makecode.com/u/YuHayate)\
**Post date:** [June 28, 2023, 5:23pm UTC](https://forum.makecode.com/t/new-3d-engine-help-filling-4-sided-polygons/18641/38 "2023-06-28T17:23:24Z")

</div>

Wow very impressive

---

<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 28, 2023, 9:20pm UTC](https://forum.makecode.com/t/new-3d-engine-help-filling-4-sided-polygons/18641/39 "2023-06-28T21:20:48Z")

</div>

Here’s the next iteration, involving collision. The collision isn’t super great (a little jittery and it depends on there being a center point), but there also isn’t much documentation or wiki articles so I had to come up with it from scratch. It should work though with the gravity mechanics that I’ll implement.

> **[renderer-prototype](https://arcade.makecode.com/46200-35647-12544-35268)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

---

<div class="post-metadata">

**Author:** ![YuHayate](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/yuhayate/32/8275_2.png) [@YuHayate](https://forum.makecode.com/u/YuHayate)\
**Post date:** [June 29, 2023, 4:36pm UTC](https://forum.makecode.com/t/new-3d-engine-help-filling-4-sided-polygons/18641/40 "2023-06-29T16:36:07Z")

</div>

Wow you can even slide on curves, thats awesome, it’s smooth with a small incline

[Previous page](https://forum.makecode.com/t/new-3d-engine-help-filling-4-sided-polygons/18641.md?page=1)

[Next page](https://forum.makecode.com/t/new-3d-engine-help-filling-4-sided-polygons/18641.md?page=3)
