• Hey! Guest! The 40th (!!!) GMC Jam will take place between February 25th, 12:00 UTC to March 1st 12:00 UTC. Why not join in this very special anniversary jam! Click here to find out more!

GMS 2.3+ [Solved] Quick question: draw_surface_part from bottom to top instead of top to bottom?

Heya,

As the thread title asks, is there a way to use draw_surface_part such that a surface draws from bottom to top? Right now, I'm able to draw a portion of the surface but it only draws from top to bottom (i.e. the surface is clipped away from the bottom, whereas I want it to clip away from the top. Here's the code that I currently have:

GML:
draw_surface_part(surf, 0, 0, g_width, 500, 0, 0)
If I change the height from 500 to 400, it will clip 100 pixels from the surface's bottom. Changing the "top" and "y" arguments don't seem to work either.

many thanks.
 
Last edited:

gnysek

Member
Arguments for this function are draw_surface_part(id, left, top, w, h, x, y );, beware that there's no bottom or right params.

So, drawing 100px from top should be:

draw_surface_part(id, 0, 100, g_width, height-100, x, y );
 
Thanks for the reply @gnysek .

Unfortunately, when I try that, the surface is clipped from the bottom by shifting up by the amount that was clipped instead of inverting the clipping direction.

I'd be a bit surprised if GMS only allows surfaces to be clipped from the bottom, but not the top.
 

gnysek

Member
Unfortunately, when I try that, the surface is clipped from the bottom by shifting up by the amount that was clipped instead of inverting the clipping direction.
I have no problem with clipping it from any side (full surface on right, clipped on left) - you must be doing something wrong, or calculating parameters wrongly:

1614022649267.png

In above case, by using draw_surface_part(surface, 100, 200, 200, 200, 10, 210);, it's cut from left by 100 pixels, from top by 200 pixels, from right by 405 (705 - 100 (left) - 200 (width)), from bottom by 46 (446 - 200(top) - 200(height)).
 
Top