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
22

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 🍬

22


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


This is so weird


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!


this is gonna be super useful!



[Please log in to post a comment]