• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GML Getting pixel-perfect part of a sprite's UV coordinates

I

IndirectY

Guest
I'm trying to write a script that only draws a part of a sprite, using vertex only.

For example, there is a sprite with a size of 128x32 and I will run the script to draw only a half (0,0 to 64,32), or a quarter (0,0 to 32,32), but drawn as the same size of 128x32.

So I got the left value and the right value using sprite_get_uvs(), multiplied them by 0.5 (or 0.25), and passed the values to vertex_normal(). And the results does not look right.

test.png

If the script was done right, both cyan and blue should be visible. But as you see in the 50% one (64x32), only cyan is visible. for 25% (32x32), pink is taking 2 strokes and blue is not visible.

I tried ( uv[0] + uv[2] ) * x too, but it does not look right when x=1 or x=0.25.

So, what should I do to get the correct UV values for this?
 
Top