# 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:** 3

<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 29, 2023, 10:17pm UTC](https://forum.makecode.com/t/new-3d-engine-help-filling-4-sided-polygons/18641/41 "2023-06-29T22:17:14Z")

</div>

I fall through the world when I try to go on the slopes 😕

---

<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 29, 2023, 10:44pm UTC](https://forum.makecode.com/t/new-3d-engine-help-filling-4-sided-polygons/18641/42 "2023-06-29T22:44:15Z")

</div>

If you change the side count (with up/down) you can glitch through the world, or if the sides are 3 or less. Otherwise, I’ve tested thoroughly and have never glitched out of the world.

---

<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:** [June 30, 2023, 9:38pm UTC](https://forum.makecode.com/t/new-3d-engine-help-filling-4-sided-polygons/18641/43 "2023-06-30T21:38:45Z")

</div>

Same here…

---

<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:** [July 3, 2023, 5:08pm UTC](https://forum.makecode.com/t/new-3d-engine-help-filling-4-sided-polygons/18641/44 "2023-07-03T17:08:16Z")

</div>

Sorry, the collision wasn’t super great but I will continue to work on it… I didn’t do enough testing and the old method wasn’t good because it didn’t take into account multiple polygons per frame at once. For now, I’ve removed the collision so I can work on a new system, but I implemented depth sorting. This was extremely painful to implement because of 1 bug (related to keeping the textures in the same place even though the rendering order changes) that took me most of an afternoon and evening to resolve while the rest of the code for depth sorting took like an hour. There are some rendering flaws (very minor, on some corners and when you move too fast), and the system wouldn’t work for a full 3d world, but in exchange it is heavily optimized. It’s only for when you’re outside the tunnel (for now) so it should be sufficient. With all that being said, here’s the demo at this point:

> **[renderer-prototype](https://arcade.makecode.com/34133-11857-89908-71480)**
>
> 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:** [July 4, 2023, 9:35pm UTC](https://forum.makecode.com/t/new-3d-engine-help-filling-4-sided-polygons/18641/45 "2023-07-04T21:35:00Z")

</div>

i mad the resolution four times bigger and the bigger the resolution the more ofset the tunnel is  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/d/d1ef5d1dd37cce6baa94bd47348f707229843e07.png)  
4 times bigger  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/c/ce4d00733fcc23cc65d4ebf8ce65559ea8c68857.png)  
normal size  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/9/91fe76eed60a482944aa9c2793ba4d3fb40bcf68.png)  
8 times bigger

but over all the fps is great even at 1920x1440 i still get a good 40-80 fps (at the normal screen size (160x120) i get 270-300 fps)

---

<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:** [July 5, 2023, 3:31am UTC](https://forum.makecode.com/t/new-3d-engine-help-filling-4-sided-polygons/18641/46 "2023-07-05T03:31:21Z")

</div>

Thanks for letting me know about that bug! I hardcoded some stuff but I’ll try to fix that moving forward. I am away for now but I’ll be back and coding in the near future!

(I think if you go into typescript into where it draws the polygons, there are variables for the position it draws and in that is `+ 80` for width and `+ 60` for height, supposed to draw it in the middle of the screen. If those are changed to `screen.width / 2` and `screen.height / 2`, this b7g should be fixed.)

---

<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:** [December 12, 2023, 5:24pm UTC](https://forum.makecode.com/t/new-3d-engine-help-filling-4-sided-polygons/18641/47 "2023-12-12T17:24:05Z")

</div>

alright

---

<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:** [January 12, 2024, 5:44pm UTC](https://forum.makecode.com/t/new-3d-engine-help-filling-4-sided-polygons/18641/48 "2024-01-12T17:44:54Z")

</div>

now that i think about it 300fps is about what i get in minecraft 💀

---

<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:** [January 12, 2024, 11:15pm UTC](https://forum.makecode.com/t/new-3d-engine-help-filling-4-sided-polygons/18641/49 "2024-01-12T23:15:28Z")

</div>

I can hardly reach a stable 60fps in Minecraft at a 12 chunk render distance XD

---

<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:** [January 12, 2024, 11:16pm UTC](https://forum.makecode.com/t/new-3d-engine-help-filling-4-sided-polygons/18641/50 "2024-01-12T23:16:37Z")

</div>

Also here’s a version where the screen’s dimensions aren’t hardcoded (and I just threw in the kiwiphoenix364/pxt-double-res extension.) I still don’t have collision in the game though. Maybe eventually…

> **[renderer-prototype](https://arcade.makecode.com/25597-13179-76786-26803)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

---

<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:** [January 16, 2024, 10:52pm UTC](https://forum.makecode.com/t/new-3d-engine-help-filling-4-sided-polygons/18641/51 "2024-01-16T22:52:17Z")

</div>

Venge is gonna look crazy.

---

<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:** [January 17, 2024, 7:03pm UTC](https://forum.makecode.com/t/new-3d-engine-help-filling-4-sided-polygons/18641/52 "2024-01-17T19:03:17Z")

</div>

Are you going to create run? That would be really cool

---

<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:** [January 17, 2024, 7:09pm UTC](https://forum.makecode.com/t/new-3d-engine-help-filling-4-sided-polygons/18641/53 "2024-01-17T19:09:17Z")

</div>

Here’s my new version with collision… Again… (but it works this time)

> **[renderer-prototype](https://arcade.makecode.com/20591-40973-91184-63622)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

Thanks to Bing AI for showing me some [stackoverflow pages](https://stackoverflow.com/questions/9043805/test-if-two-lines-intersect-javascript-function) and helping write some matrix math code to determine the intersection point between 2 lines. The weird collision logic I did myself though. There are still some bugs like getting stuck on the outside of the tube, but you shouldn’t be able to easily glitch in/out of it without changing the number of sides. There are some issues with corners, more easily visible if you switch it to 3 sides and jump straight up, but it is a vast improvement over previous iterations. These issues probably won’t be as difficult to fix though.

---

<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:** [January 17, 2024, 8:20pm UTC](https://forum.makecode.com/t/new-3d-engine-help-filling-4-sided-polygons/18641/54 "2024-01-17T20:20:37Z")

</div>

Yeah, that’s the goal!

---

<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:** [January 17, 2024, 9:43pm UTC](https://forum.makecode.com/t/new-3d-engine-help-filling-4-sided-polygons/18641/55 "2024-01-17T21:43:45Z")

</div>

12? i use 24 chunk render distance lol 💀

---

<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:** [January 17, 2024, 10:00pm UTC](https://forum.makecode.com/t/new-3d-engine-help-filling-4-sided-polygons/18641/56 "2024-01-17T22:00:31Z")

</div>

I will put some twists on it though. I’m going to make it first person (unlike the original.) Gravity shifting will be added soon. If you have some ideas for things to get added, just comment them, and I might add them! They just have to fit the game and be feasible to code. No guarantees, but I’ll definitely consider recommendations.

---

<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:** [January 17, 2024, 10:07pm UTC](https://forum.makecode.com/t/new-3d-engine-help-filling-4-sided-polygons/18641/57 "2024-01-17T22:07:36Z")

</div>

I definitely want to see some kind of boss fight or combat system to go with navigation I think that would be interesting

---

<div class="post-metadata">

**Author:** ![Zenith](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/zenith/32/12906_2.png) [@Zenith](https://forum.makecode.com/u/Zenith)\
**Post date:** [January 18, 2024, 12:21am UTC](https://forum.makecode.com/t/new-3d-engine-help-filling-4-sided-polygons/18641/58 "2024-01-18T00:21:47Z")

</div>

Ummm… if you jump while it’s shifting you end up glitching out of tube/tunnel thing.  
 ![Screenshot 2024-01-17 5.40.33 PM](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/7/7ecbcc27d4e6691b83b40a610fef7ff635709e55.png)

---

<div class="post-metadata">

**Author:** ![Zenith](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/zenith/32/12906_2.png) [@Zenith](https://forum.makecode.com/u/Zenith)\
**Post date:** [January 18, 2024, 12:22am UTC](https://forum.makecode.com/t/new-3d-engine-help-filling-4-sided-polygons/18641/59 "2024-01-18T00:22:07Z")

</div>

also if you spam the multiplier or whatever it is enough it starts unraveling?  
WARNING: VERY CURSED IMAGE  
 ![Screenshot 2024-01-17 5.47.29 PM](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/1/11cc6d04aab49dfc62e9c90186cd5651132dd25b.png)  
UMMMMMMMMMM…

---

<div class="post-metadata">

**Author:** ![Zenith](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/zenith/32/12906_2.png) [@Zenith](https://forum.makecode.com/u/Zenith)\
**Post date:** [January 18, 2024, 5:48pm UTC](https://forum.makecode.com/t/new-3d-engine-help-filling-4-sided-polygons/18641/60 "2024-01-18T17:48:06Z")

</div>

@Kiwiphoenix364 can you make the character a little bit faster?

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

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