Undertale Yellow script viewer

← back to main script listing

gml_Object_obj_crayon_minigame_Step_0

(view raw script w/o annotations or w/e)
1
if (live_call())
2
    return global.live_result;
3
if (event_fade_in == true && draw_alpha < 1)
4
{
5
    draw_alpha += 0.1;
6
}
7
else
8
{
9
    if (audio_is_paused(mus))
10
        audio_resume_sound(mus);
11
    event_fade_in = false;
12
}
13
if (event_fade_out == true)
14
{
15
    if (draw_alpha > 0)
16
    {
17
        draw_alpha -= 0.1;
18
    }
19
    else
20
    {
21
        event_fade_out = false;
22
        instance_destroy(obj_crayon);
23
        instance_destroy(obj_crayon_box);
24
        instance_destroy(obj_crayon_indicator);
25
        instance_destroy();
26
    }
27
    exit;
28
}
29
var h_mouse = global.right_key - global.left_key;
30
var v_mouse = global.down_key - global.up_key;
31
var cursor_speed = 4;
32
if (window_get_fullscreen() == true)
33
    cursor_speed = 8;
34
if (h_mouse != 0 || v_mouse != 0)
35
    window_mouse_set(window_mouse_get_x() + (h_mouse * cursor_speed), window_mouse_get_y() + (v_mouse * cursor_speed));
36
cursor_x = mouse_x;
37
cursor_y = mouse_y;
38
cursor_x -= view_x;
39
cursor_y -= view_y;
40
if (mouse_check_button(mb_left) || keyboard_multicheck(0))
41
    cursor_click = true;
42
else
43
    cursor_click = false;
44
if (cursor_click == true)
45
{
46
    if (cursor_click_noloop == false && point_in_rectangle(cursor_x, cursor_y, obj_crayon_indicator.bbox_left, obj_crayon_indicator.bbox_top, obj_crayon_indicator.bbox_right, obj_crayon_indicator.bbox_bottom))
47
    {
48
        if (brush_size_current == brush_size_normal)
49
            brush_size_current = brush_size_large;
50
        else
51
            brush_size_current = brush_size_normal;
52
    }
53
    var cursor_x_target = cursor_x;
54
    var cursor_y_target = cursor_y;
55
    if (abs(cursor_x_last - cursor_x) > brush_size_current || abs(cursor_y_last - cursor_y) > brush_size_current)
56
    {
57
        cursor_x = cursor_x_last;
58
        cursor_y = cursor_y_last;
59
    }
60
    do
61
    {
62
        if ((cursor_x > id_xx && cursor_x < (id_xx + ds_grid_width(drawing_grid))) && (cursor_y > id_yy && cursor_y < (id_yy + ds_grid_height(drawing_grid))))
63
        {
64
            var j = -brush_size_normal;
65
            while (j < brush_size_current)
66
            {
67
                var i = -brush_size_normal;
68
                while (i < brush_size_current)
69
                {
70
                    ds_grid_set(drawing_grid, (cursor_x - id_xx) + i, (cursor_y - id_yy) + j, crayon_selected);
71
                    i++;
72
                }
73
                j++;
74
            }
75
        }
76
        if (cursor_x != cursor_x_target)
77
            cursor_x += sign(cursor_x_target - cursor_x);
78
        if (cursor_y != cursor_y_target)
79
            cursor_y += sign(cursor_y_target - cursor_y);
80
    }
81
    until (cursor_x == cursor_x_target && cursor_y == cursor_y_target);
82
}
83
for (var i = 0; i < array_length(button_x); i++)
84
{
85
    if (point_in_rectangle(cursor_x, cursor_y, button_x[i], button_y[i], button_x[i] + button_width, button_y[i] + button_height))
86
    {
87
        if (button_highlight[i] == false)
88
        {
89
            audio_play_sound(snd_mainmenu_select, 1, 0);
90
            button_highlight[i] = true;
91
        }
92
        if (cursor_click && cursor_click_noloop == false)
93
            event_user(i);
94
    }
95
    else
96
    {
97
        button_highlight[i] = false;
98
    }
99
}
100
cursor_x_last = cursor_x;
101
cursor_y_last = cursor_y;
102
if (cursor_click)
103
    cursor_click_noloop = true;
104
else
105
    cursor_click_noloop = false;