-
-
Notifications
You must be signed in to change notification settings - Fork 492
ttri
ttri(x1, y1, x2, y2, x3, y3, u1, v1, u2, v2, u3, v3, [texsrc=0], [chromakey=-1], [z1=0], [z2=0], [z3=0])
- x1, y1 : the screen coordinates of the first corner
- x2, y2 : the screen coordinates of the second corner
- x3, y3 : the screen coordinates of the third corner
- u1, v1 : the UV coordinates of the first corner
- u2, v2 : the UV coordinates of the second corner
- u3, v3 : the UV coordinates of the third corner
-
texsrc : if 0 (default), the triangle's texture is read from
SPRITES
RAM. If 1, the texture comes from theMAP
RAM.
If 2, the texture comes from the screen RAM in the next VBANK (the one following the VBANK on which thettri()
is set to be displayed) (e.g., attri()
onvbank(0)
with the texsrc=2 will usevbank(1)
as its texture at the time of its execution and vice versa). - chromakey : index (or array of indexes 0.80) of the color(s) that will be used as transparent
- z1, z2, z3 : depth parameters for perspective correction and depth buffer
The letters "U" and "V" denote the axes of the 2D texture because "X", "Y" are already used.
These can be thought of as the window inside SPRITES
or MAP
RAM. Note that the sprite sheet or map in this case is treated as a single large image, with U and V addressing its pixels directly, rather than by sprite ID. So for example the top left corner of sprite #2 would be located at u=16
(horizontal), v=0
(vertical).
This function draws a triangle filled with texture from either SPRITES
or MAP
RAM or VBANK.
A depth buffer is implemented in ttri when z1, z2, z3
arguments are set. The depth buffer can be cleared using the cls()
function.
-- title: triangle demo
-- author: MonstersGoBoom
-- desc: wiki demo for ttri
-- script: lua
-- input: gamepad
usize = 32
vsize = 32
function TIC()
cls(1)
if btn(0) then usize=usize-1 end
if btn(1) then usize=usize+1 end
if btn(2) then vsize=vsize-1 end
if btn(3) then vsize=vsize+1 end
-- draw a scaling view into the map ram
ttri(0,0,
64,0,
0,64,
0,0,
usize,0,
0,vsize,
true,
14)
ttri(64,0,
0,64,
64,64,
usize,0,
0,vsize,
usize,vsize,
true,
14)
end
- Sprite x,y,z rotation with ttri here
TIC-80 tiny computer https://tic80.com | Twitter | Telegram | Terms
Built-in Editors
Console
Platform
RAM & VRAM | Display | Palette | Bits per Pixel (BPP) |
.tic
Format | Supported Languages
Other
Tutorials | Code Snippets | Libraries | External Tools | FFT
API
- BDR (0.90)
- BOOT (1.0)
- MENU
- OVR (deprecated)
- SCN (deprecated)
- TIC
- btn & btnp
- circ & circb
- clip
- cls
- elli & ellib (0.90)
- exit
- fget & fset (0.80)
- font
- key & keyp
- line
- map
- memcpy & memset
- mget & mset
- mouse
- music
- peek, peek4
- peek1, peek2 (1.0)
- pix
- pmem
- poke, poke4
- poke1, poke2 (1.0)
- rect & rectb
- reset
- sfx
- spr
- sync
- ttri (1.0)
- time
- trace
- tri & trib (0.90)
- tstamp (0.80)
- vbank (1.0)