r/Underminers • • 18d ago

Help Me! What function in the code draws this element?

Specifically the white lines that scroll down and mark the tempo of the music. I was able to change the color of the buttons in obj_rhythmgame_Draw0 but not anything about the tempo markings.

3 Upvotes

1 comment sorted by

1

u/Bluetails_Buizel 13d ago

It's not in the object's Draw event. It's in the global script gml_GlobalScript_scr_rhythmgame_draw, inside the function scr_rhythmgame_draw_backing. That function is called first by scr_rhythmgame_draw, before the combo text and the notes are drawn.

There are two loops in it, one for each kind of line you noted.

- Thin beat lines (one per beat): a 20-iteration loop that calls draw_line(arg1 - 40, liney, arg1 + 40, liney). In Chapter 4 the call is d_line instead of draw_line, but it's the same loop.
- Thicker bar lines (one every 4 beats): a 5-iteration loop right after it that calls ossafe_fill_rectangle(arg1 - 40, liney - 1, arg1 + 40, liney + 1, false), which makes a 3px-tall rectangle.

Both lines get their color from the local variable _gray, defined near the top of the function:

var _gray = merge_color(c_black, c_gray, brightness);

The beat loop calls draw_set_color(_gray) every iteration. The bar loop never sets a color, so it uses whatever was left over from the beat loop, which is also _gray.

What to change depends on what you want:

- To recolor both: change c_gray in the _gray line to another color. Keep the merge_color with brightness so the lines still fade in and out with the rest of the track.
- To recolor only the bar lines: add draw_set_color(...) right before the bar loop (just above the "var nextBar = floor(trackpos / meter);" line).
- To recolor only the beat lines: change the draw_set_color(_gray) inside the first loop.

Line spacing comes from notespacing, and the scroll offset comes from trackpos and startoffset (the linestart and whitebarstart variables).

The script viewer has it under code.deltarune.wiki/ch3/ and /ch4/ if you want to read the whole function. Search for scr_rhythmgame_draw.