Log In  

Hi everyone!

So with the new tline function in Pico-8 0.2.0, it seems pretty obvious to start making mapped quadrilaterals and triangles, so I did just that.

Cart #trasevol_tquad_ttri-3 | 2020-05-11 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
21

Both functions are independant from each other (i.e. can be used separately) and can be taken from the code here and used in any other project, with or without attribution. (I do appreciate it though! :))

The two functions are:

tquad(xa, ya, xb, yb, xc, yc, xd, yd, mx, my, w, h)
  mx and my are map coordinates (in tiles), and w and h are width and height in tiles. (so w=1 h=1 means drawing one whole tile)
  xa, ya, xb, yb, xc, yc, xd, yd are the screen coordinated for the corners of the quad to be drawn.
  please note that the correspondence with the map coordinates is ordered clockwise, as can be seen with ABCD on the top-right corner in the cart above.

ttri(xa, ya, xb, yb, xc, yc, sxa, sya, sxb, syb, sxc, syc)
  xa, ya, xb, yb, xc, yc are the screen coordinates for the corners of the triangle to be drawn.
  sxa, sya, sxb, syb, sxc, syc are the corresponding coordinates on the map to sample texture from.
  Those map coordinates are tile coordinates. (0.5, 0.5 means the middle of the top-most left-most tile on the map)

I wrote those functions to be fairly efficient, but I'm sure some better optimized alternatives will be coming very soon and we'll get a good-old thunderdome for tquad and ttri. Consider me happy to open the festivities!

Anyway that's it! I hope you have fun with this!

Remy 🍬

P#76381 2020-05-11 14:52 ( Edited 2020-05-11 17:15)

10

Mine is slower but exhibits a lot less artifacts (+ support arbitrary sided polygon - useful after znear/zfar clipping)
Note: default renderer is your tquad ;)
Update: removed 'w' parameter (useful for persp. correct - irrelevant here).
How to use:

-- takes an arbitrary number of vertices+map coordinates
-- must form a convex shape
polytex({{x=x0,y=y0,u=mx0,v=my0},{x=x1,y=y1,u=mx1,v=my1},...})

Cart #hoyepifone-0 | 2020-05-23 | Code ▽ | Embed ▽ | No License
10

P#76387 2020-05-11 18:19 ( Edited 2020-05-23 13:03)

This is so weird

P#76442 2020-05-12 14:28

I legit wonder how far you could take this.
Am I gonna wake up someday and find out somebody remade Tomb Raider?

Either way, awesome stuff!

P#76443 2020-05-12 15:17

this is gonna be super useful!

P#76660 2020-05-15 19:03

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-29 13:48:48 | 0.011s | Q:24