Undertale Yellow script viewer

← back to main script listing

gml_GlobalScript_draw_sprite_clip

(view raw script w/o annotations or w/e)
1
function draw_sprite_clip(argument0, argument1, argument2, argument3, argument4, argument5, argument6, argument7) //gml_Script_draw_sprite_clip
2
{
3
    var s = argument0
4
    var sw = sprite_get_width(s)
5
    var sh = sprite_get_height(s)
6
    var sx = sprite_get_xoffset(s)
7
    var sy = sprite_get_yoffset(s)
8
    var si = argument1
9
    var _x = argument2
10
    var _y = argument3
11
    var cx1 = argument4
12
    var cy1 = argument5
13
    var cx2 = cx1 + argument6
14
    var cy2 = cy1 + argument7
15
    var bx1 = _x - sprite_get_xoffset(s)
16
    var by1 = _y - sprite_get_yoffset(s)
17
    var bx2 = bx1 + sprite_get_width(s)
18
    var by2 = by1 + sprite_get_height(s)
19
    switch rectangle_in_rectangle(bx1, by1, bx2, by2, cx1, cy1, cx2, cy2)
20
    {
21
        case 1:
22
            draw_sprite(s, si, _x, _y)
23
            return true;
24
        case 2:
25
            var lx1 = max(0, (cx1 - bx1))
26
            var ly1 = max(0, (cy1 - by1))
27
            var lx2 = sw + (min(0, (cx2 - bx2)))
28
            var ly2 = sh + (min(0, (cy2 - by2)))
29
            draw_sprite_part(s, si, lx1, ly1, (lx2 - lx1), (ly2 - ly1), (_x + lx1 - sx), (_y + ly1 - sy))
30
            return true;
31
    }
32
33
}