Deltarune (Chapter 3) script viewer

← back to main script listing

gml_GlobalScript_centerx

(view raw script w/o annotations or w/e)
1
function centerx()
2
{
3
    var truexcenter;
4
    if (argument_count == 0)
5
    {
6
        var x1 = x - (sprite_get_xoffset(sprite_index) * image_xscale);
7
        var x2 = x1 + sprite_width;
8
        truexcenter = (x1 + x2) / 2;
9
    }
10
    if (argument_count == 1)
11
    {
12
        var x1 = x - (sprite_get_xoffset(argument0.sprite_index) * argument0.image_xscale);
13
        var x2 = x1 + (sprite_get_width(argument0.sprite_index) * argument0.image_xscale);
14
        truexcenter = (x1 + x2) / 2;
15
    }
16
    if (argument_count == 2)
17
    {
18
        if (argument[1] != 0)
19
            truexcenter = (bbox_left + bbox_right) / 2;
20
    }
21
    return truexcenter;
22
}