Deltarune (Chapter 5) script viewer

← back to main script listing

gml_GlobalScript_scr_rhythmgame_draw_backing

(view raw script w/o annotations or w/e)
1
function 
scr_rhythmgame_draw_backing
scr_rhythmgame_draw_backing

function
scr_rhythmgame_draw_backing(arg0, arg1, arg2 = false, arg3 = 0)
{ if (arg2) fade = 0; if (fade == 1 && brightness == 1) draw_set_color(c_gray); else draw_set_color(merge_color(c_black, c_gray, fade * brightness)); var _gray = merge_color(c_black, c_gray, brightness); draw_set_color(c_black); var _flash = 0; var _ts = signature; var _bpm = bpm; var _posoffset = startoffset; var _rts = max(4, floor(signature)); draw_set_color(c_red); if (arg2) { var _sigmul = _ts % 1; if (_sigmul == 0) _sigmul = 1; draw_text(10, 80, "Time Signature: " + string(_ts / _sigmul) + "/" + string(4 / _sigmul)); draw_text(10, 100, "BPM: " + string(_bpm)); } draw_set_color(c_black); var _bpm_mul = 1; if (bpm_count > 1) _bpm_mul = _bpm / bpm_change[0]; if (invc > 0 && fade == 1) _flash = remap_clamped(0, 6, 0, 1, hurt_flash); draw_set_alpha(0.75); ossafe_fill_rectangle(arg1 - 40, bottomy - 200, arg1 + 40, bottomy + 50, false); draw_set_alpha(1); draw_set_blend_mode(bm_normal); var _lead = floor_to_multiple(16, _ts); var _lead_num = _lead / _ts; var whitebar = -1; var _bpmi = bpm_index; var _notespacing = notespacing; if (signature_index != 0 && bpm_index != 0) _posoffset = max(bpm_time[_bpmi], signature_time[signature_index]); else if (signature_index != 0) _posoffset = signature_time[signature_index]; else if (bpm_index != 0) _posoffset = bpm_time[_bpmi]; var linegap = arg0 * _notespacing; var linestart = bottomy + (((trackpos - _posoffset) % (_notespacing * _ts)) * arg0); draw_set_color(_gray); var liney = linestart; draw_set_color(_gray); var _bpm_changed = true; var _next_bpm = _bpm; var _next_bpm_time = -1; if (bpm_count > 1 && _bpmi < (bpm_count - 1)) { _next_bpm = bpm_change[_bpmi + 1]; _next_bpm_time = bpm_time[_bpmi + 1]; _bpm_changed = false; } var nextBar = floor(trackpos / meter); var _ts_changed = true; var _next_ts = _ts; var _next_ts_time = -1; if (signature_count > 1 && signature_index < (signature_count - 1)) { _next_ts = signature_change[signature_index + 1]; _next_ts_time = signature_time[signature_index + 1]; _ts_changed = false; } var _barcount = 0; var _pregap = linegap; if (bpm_index > 0 && ((trackpos + ((bottomy - liney) / arg0)) - 0.5) < bpm_time[bpm_index]) _pregap = (60 / bpm_change[bpm_index - 1]) * arg0; draw_set_color(c_gray); if (signature_index > 0) { var _last_ts = _ts; if ((trackpos - 0.5) < signature_time[signature_index]) _last_ts = signature_change[signature_index - 1]; if ((_last_ts % 1) != 0) liney -= (linegap / 2); } for (var i = 0; i < _rts; i++) { liney += _pregap; if (!arg2 && (liney + 1) > (bottomy + 50)) break; d_line(arg1 - 40, liney, arg1 + 40, liney); } liney = linestart; var _eighths = (_ts % 1) == 0.5; var _oddts = false; if (_eighths) { if (((trackpos - signature_time[signature_index]) % (_ts * 2)) >= _ts) _oddts = true; } for (var i = 0; i < max(20, _rts * 2); i++) { if (i > 0) liney -= linegap; ...
(arg0, arg1, arg2 = false, arg3 = 0)
2
{
3
    if (arg2)
4
        fade = 0;
5
    if (fade == 1 && brightness == 1)
6
        draw_set_color(c_gray);
7
    else
8
        draw_set_color(merge_color(c_black, c_gray, fade * brightness));
9
    var _gray = merge_color(c_black, c_gray, brightness);
10
    draw_set_color(c_black);
11
    var _flash = 0;
12
    var _ts = signature;
13
    var _bpm = bpm;
14
    var _posoffset = startoffset;
15
    var _rts = max(4, floor(signature));
16
    draw_set_color(c_red);
17
    if (arg2)
18
    {
19
        var _sigmul = _ts % 1;
20
        if (_sigmul == 0)
21
            _sigmul = 1;
22
        draw_text(10, 80, "Time Signature: " + string(_ts / _sigmul) + "/" + string(4 / _sigmul));
23
        draw_text(10, 100, "BPM: " + string(_bpm));
24
    }
25
    draw_set_color(c_black);
26
    var _bpm_mul = 1;
27
    if (bpm_count > 1)
28
        _bpm_mul = _bpm / bpm_change[0];
29
    if (invc > 0 && fade == 1)
30
        _flash = remap_clamped(0, 6, 0, 1, hurt_flash);
31
    draw_set_alpha(0.75);
32
    ossafe_fill_rectangle(arg1 - 40, bottomy - 200, arg1 + 40, bottomy + 50, false);
33
    draw_set_alpha(1);
34
    draw_set_blend_mode(bm_normal);
35
    var _lead = floor_to_multiple(16, _ts);
36
    var _lead_num = _lead / _ts;
37
    var whitebar = -1;
38
    var _bpmi = bpm_index;
39
    var _notespacing = notespacing;
40
    if (signature_index != 0 && bpm_index != 0)
41
        _posoffset = max(bpm_time[_bpmi], signature_time[signature_index]);
42
    else if (signature_index != 0)
43
        _posoffset = signature_time[signature_index];
44
    else if (bpm_index != 0)
45
        _posoffset = bpm_time[_bpmi];
46
    var linegap = arg0 * _notespacing;
47
    var linestart = bottomy + (((trackpos - _posoffset) % (_notespacing * _ts)) * arg0);
48
    draw_set_color(_gray);
49
    var liney = linestart;
50
    draw_set_color(_gray);
51
    var _bpm_changed = true;
52
    var _next_bpm = _bpm;
53
    var _next_bpm_time = -1;
54
    if (bpm_count > 1 && _bpmi < (bpm_count - 1))
55
    {
56
        _next_bpm = bpm_change[_bpmi + 1];
57
        _next_bpm_time = bpm_time[_bpmi + 1];
58
        _bpm_changed = false;
59
    }
60
    var nextBar = floor(trackpos / meter);
61
    var _ts_changed = true;
62
    var _next_ts = _ts;
63
    var _next_ts_time = -1;
64
    if (signature_count > 1 && signature_index < (signature_count - 1))
65
    {
66
        _next_ts = signature_change[signature_index + 1];
67
        _next_ts_time = signature_time[signature_index + 1];
68
        _ts_changed = false;
69
    }
70
    var _barcount = 0;
71
    var _pregap = linegap;
72
    if (bpm_index > 0 && ((trackpos + ((bottomy - liney) / arg0)) - 0.5) < bpm_time[bpm_index])
73
        _pregap = (60 / bpm_change[bpm_index - 1]) * arg0;
74
    draw_set_color(c_gray);
75
    if (signature_index > 0)
76
    {
77
        var _last_ts = _ts;
78
        if ((trackpos - 0.5) < signature_time[signature_index])
79
            _last_ts = signature_change[signature_index - 1];
80
        if ((_last_ts % 1) != 0)
81
            liney -= (linegap / 2);
82
    }
83
    for (var i = 0; i < _rts; i++)
84
    {
85
        liney += _pregap;
86
        if (!arg2 && (liney + 1) > (bottomy + 50))
87
            break;
88
        d_line(arg1 - 40, liney, arg1 + 40, liney);
89
    }
90
    liney = linestart;
91
    var _eighths = (_ts % 1) == 0.5;
92
    var _oddts = false;
93
    if (_eighths)
94
    {
95
        if (((trackpos - signature_time[signature_index]) % (_ts * 2)) >= _ts)
96
            _oddts = true;
97
    }
98
    for (var i = 0; i < max(20, _rts * 2); i++)
99
    {
100
        if (i > 0)
101
            liney -= linegap;
102
        if (!arg2 && (liney - 1) < (bottomy - 202))
103
        {
104
            if (!(_eighths && _barcount <= 0 && ((liney - 1) + (linegap / 2)) > (bottomy - 202)))
105
                break;
106
        }
107
        else if (!arg2 && (liney + 1) > (bottomy + 50))
108
        {
109
            if (_barcount <= 0)
110
                _barcount = _ts - 1;
111
            else
112
                _barcount--;
113
            continue;
114
        }
115
        if (_barcount <= 0)
116
        {
117
            if (_eighths)
118
            {
119
                if (i != 0)
120
                    liney += (linegap / 2);
121
            }
122
            ossafe_fill_rectangle(arg1 - 40, liney - 1, arg1 + 40, liney + 1, false);
123
            var linetime = trackpos + ((bottomy - liney) / arg0);
124
            if (arg2)
125
            {
126
                draw_text(arg1 - 60, liney - 1 - 8, nextBar + (i / _ts) + 1);
127
                draw_text(arg1 + 60, liney - 1 - 8, linetime);
128
            }
129
            if (!_ts_changed && (linetime + 0.5) > _next_ts_time)
130
            {
131
                _ts = _next_ts;
132
                _ts_changed = true;
133
            }
134
            if (!_bpm_changed && (linetime + 0.5) > _next_bpm_time)
135
            {
136
                if (arg2)
137
                {
138
                    draw_sprite_ext(spr_arrow_9x9, 0, arg1 + 100, (liney - 1 - 1) + 2, 1, (_next_bpm > _bpm) ? -1 : 1, 0, c_white, 1);
139
                    draw_text(arg1 + 110, liney - 1 - 8, string(_next_bpm) + " BPM");
140
                }
141
                _bpm_changed = true;
142
                _bpm = _next_bpm;
143
                linegap = (60 / _bpm) * arg0;
144
            }
145
            _barcount = _ts - 1;
146
        }
147
        else
148
        {
149
            _barcount--;
150
            d_line(arg1 - 40, liney, arg1 + 40, liney);
151
        }
152
    }
153
    if (_flash > 0)
154
    {
155
        draw_set_blend_mode(bm_add);
156
        var _flashCol = merge_color(c_black, c_red, _flash * fade * brightness);
157
        ossafe_fill_rectangle_color(arg1 - 40, bottomy - 200, arg1 + 40, bottomy + 50, c_black, c_black, _flashCol, _flashCol, false);
158
        draw_set_blend_mode(bm_normal);
159
    }
160
    draw_set_color(c_white);
161
}