Deltarune (Chapter 3) script viewer

← back to main script listing

gml_Object_obj_board_quizwheel_Draw_0

(view raw script w/o annotations or w/e)
1
if (init == 0)
2
{
3
    pushcon = 1;
4
    pushamount = 0;
5
    if (slicetype == 0)
6
    {
7
    }
8
    if (slicetype == 1)
9
    {
10
        maxslices = 4 + irandom(12);
11
        for (i = 0; i < maxslices; i++)
12
        {
13
            sliceicon[i] = 3301;
14
            slicetext[i] = "no. " + string(i);
15
            slicetextcolor[i] = choose(16777215, 65535, 4235519);
16
        }
17
    }
18
    init = 1;
19
}
20
if (keyboard_check_pressed(vk_alt))
21
    init = 0;
22
draw_set_color(c_black);
23
ossafe_fill_rectangle(120, 60, 520, 320, false);
24
draw_set_color(c_blue);
25
xx = 340;
26
yy = 180;
27
r = 100;
28
draw_circle(xx, yy, r, false);
29
draw_set_color(c_black);
30
siner -= rotationalspeed;
31
ang = 360 / maxslices;
32
whichslicechosen = -1;
33
draw_set_font(fnt_main);
34
draw_set_halign(fa_right);
35
if (!surface_exists(slicesurf))
36
    slicesurf = surface_create(r * 2, r * 2);
37
var minangle, maxangle;
38
for (i = 0; i < maxslices; i++)
39
{
40
    draw_set_color(c_white);
41
    finalang = (ang * i) + (ang / 2) + siner;
42
    var slicechosen = 0;
43
    minangle = (finalang - (ang / 2)) % 360;
44
    maxangle = (finalang + (ang / 2)) % 360;
45
    if (minangle > maxangle)
46
    {
47
        slicechosen = 1;
48
        whichslicechosen = i;
49
    }
50
    var selectedcolor = 16777215;
51
    if (slicechosen)
52
        selectedcolor = 65535;
53
    draw_line(xx, yy, xx + lengthdir_x(r, finalang + (ang / 2)), yy + lengthdir_y(r, finalang + (ang / 2)));
54
    x1 = xx + lengthdir_x(10, finalang + (ang / 2));
55
    y1 = yy + lengthdir_y(10, finalang + (ang / 2));
56
    x2 = xx + lengthdir_x(r, finalang - (ang / 2));
57
    y2 = yy + lengthdir_y(r, finalang - (ang / 2));
58
    x3 = xx + lengthdir_x(r, finalang + (ang / 2));
59
    y3 = yy + lengthdir_y(r, finalang + (ang / 2));
60
    x4 = xx + lengthdir_x(10, finalang - (ang / 2));
61
    y4 = yy + lengthdir_y(10, finalang - (ang / 2));
62
    var piecealpha = 1;
63
    if (pushcon == 1)
64
    {
65
        piecealpha = 1;
66
    }
67
    else if (pushcon >= 2)
68
    {
69
        piecealpha = 0.5;
70
        if (rotationalspeed < 30)
71
        {
72
            if (slicechosen)
73
                piecealpha = 1;
74
            else
75
                piecealpha = (1 / (abs(rotationalspeed * 4) + 1)) + 0.5;
76
        }
77
    }
78
    surface_set_target(slicesurf);
79
    draw_clear_alpha(c_black, 0);
80
    draw_primitive_begin(pr_trianglefan);
81
    draw_set_color(slicebgcolor[i]);
82
    draw_vertex(r, r);
83
    var _degreecap = round(ang / 12);
84
    for (var i2 = 0; i2 <= _degreecap; i2++)
85
    {
86
        var _xx = r + lengthdir_x(r, (finalang - (ang / 2)) + lerp(0, ang, i2 / _degreecap));
87
        var _yy = r + lengthdir_y(r, (finalang - (ang / 2)) + lerp(0, ang, i2 / _degreecap));
88
        draw_vertex(_xx, _yy);
89
    }
90
    draw_primitive_end();
91
    gpu_set_blendmode_ext_sepalpha(bm_src_alpha, bm_inv_src_alpha, bm_dest_alpha, bm_zero);
92
    draw_sprite_ext(spr_board_wheel_slice_test_2, i, r, r, 3, 3, finalang, c_white, piecealpha);
93
    draw_set_blend_mode(bm_normal);
94
    surface_reset_target();
95
    draw_surface(slicesurf, xx - r, yy - r);
96
    if (pushcon >= 3 && (sliceflash % 2 || sliceflash > 8) && slicechosen)
97
    {
98
        draw_set_blend_mode(bm_add);
99
        draw_surface_ext(slicesurf, xx - r, yy - r - 2, 1, 1, 0, c_white, piecealpha / 4);
100
        draw_surface_ext(slicesurf, (xx - r) + 2, yy - r, 1, 1, 0, c_white, piecealpha / 4);
101
        draw_surface_ext(slicesurf, xx - r - 2, yy - r, 1, 1, 0, c_white, piecealpha / 4);
102
        draw_surface_ext(slicesurf, xx - r, (yy - r) + 2, 1, 1, 0, c_white, piecealpha / 4);
103
        draw_set_blend_mode(bm_normal);
104
    }
105
    draw_set_color(slicetextcolor[i]);
106
    draw_sprite_ext(sliceicon[i], 0, xx + lengthdir_x(r - 20, finalang), yy + lengthdir_y(r - 20, finalang), 2, 2, finalang, c_white, image_alpha);
107
    draw_sprite_ext(spr_numbersfontbig, i, xx + lengthdir_x(r - 20, finalang), yy + lengthdir_y(r - 20, finalang), 2, 2, finalang, selectedcolor, image_alpha / 4);
108
    draw_text_transformed(xx + lengthdir_x(80, finalang + 8), yy + lengthdir_y(80, finalang + 8), slicetext[i], 1, 1, finalang);
109
}
110
for (i = 0; i < maxslices; i++)
111
{
112
    finalang = (ang * i) + (ang / 2) + siner;
113
    draw_set_color(c_white);
114
    draw_line_width(xx, yy, xx + lengthdir_x(r, finalang - (ang / 2)), yy + lengthdir_y(r, finalang - (ang / 2)), 4);
115
}
116
draw_sprite_ext(spr_ch3_wheel_center, 3, xx, yy, 1, 1, finalang, c_white, 1);
117
draw_set_halign(fa_left);
118
rotationalspeed = clamp(rotationalspeed - rotationalfriction, 0, 999);
119
if (pushcon == 1)
120
{
121
    if (button1_h())
122
    {
123
        pushsiner++;
124
        pushamount = abs(sin(pushsiner / 8)) * 100;
125
        meterfill = pushamount;
126
        spinready = 1;
127
    }
128
    else if (!button1_h() && spinready == 1)
129
    {
130
        pushsiner = 0;
131
        pushcon = 2;
132
        idealrotationalspeed = rotationalspeed + 4 + (pushamount / 5) + (8 / maxslices);
133
        if (idealrotationalspeed > 30)
134
            idealrotationalspeed = 30;
135
        
scr_lerpvar
scr_lerpvar

function
scr_lerpvar()
{ if (argument_count < 6) ___lerpvar =
scr_lerpvar_instance(id, argument[0], argument[1], argument[2], argument[3]);
else ___lerpvar =
scr_lerpvar_instance(id, argument[0], argument[1], argument[2], argument[3], argument[4], argument[5]);
return ___lerpvar; } function scr_lerpvar_respect() { if (argument_count < 6) ___lerpvar =
scr_lerpvar_instance(id, argument[0], argument[1], argument[2], argument[3]);
else ___lerpvar =
scr_lerpvar_instance(id, argument[0], argument[1], argument[2], argument[3], argument[4], argument[5]);
___lerpvar.respectglobalinteract = true; return ___lerpvar; }
("rotationalspeed", rotationalspeed, idealrotationalspeed, 3, 1, "out");
136
        rotationalfriction = 0.2 + (idealrotationalspeed / 100);
137
        pushamount = 0;
138
    }
139
    else
140
    {
141
        meterfill = 0;
142
        pushamount = 0;
143
    }
144
}
145
else
146
{
147
    meterfill = 
scr_movetowards
scr_movetowards

function
scr_movetowards(arg0, arg1, arg2)
{ if (arg0 == arg1) return arg0; else if (arg0 > arg1) return max(arg0 - arg2, arg1); else return min(arg0 + arg2, arg1); } function scr_obj_movetowards_obj(arg0, arg1, arg2 = 0, arg3 = 0) { scr_obj_movetowards_point(arg0.x + arg2, arg0.y + arg3, arg1); } function scr_obj_movetowards_point(arg0, arg1, arg2) { var _distance = point_distance(x, y, arg0, arg1); if (arg2 >= _distance) { x = arg0; y = arg1; } else { var _direction = point_direction(x, y, arg0, arg1); x += lengthdir_x(arg2, _direction); y += lengthdir_y(arg2, _direction); } }
(meterfill, 0, 20);
148
}
149
draw_sprite(spr_ch3_wheel_power_meter, 0, xx + 64, yy);
150
surface_set_target(slicesurf);
151
draw_clear_alpha(c_black, 0);
152
draw_set_blend_mode(bm_normal);
153
draw_sprite(spr_ch3_wheel_power_meter, 1, 64, r);
154
gpu_set_blendmode(bm_subtract);
155
draw_primitive_begin(pr_trianglefan);
156
draw_set_color(c_white);
157
draw_vertex(0, r);
158
for (var i2 = 0; i2 <= 4; i2++)
159
{
160
    var _xx = lengthdir_x(r * 2, lerp(45, -50, (1 - (meterfill / 100)) * (i2 / 4)));
161
    var _yy = r + lengthdir_y(r * 2, lerp(45, -50, (1 - (meterfill / 100)) * (i2 / 4)));
162
    draw_vertex(_xx, _yy);
163
}
164
draw_primitive_end();
165
draw_set_blend_mode(bm_normal);
166
surface_reset_target();
167
draw_surface(slicesurf, xx, yy - r);
168
if (pushcon == 2)
169
{
170
    pushsiner++;
171
    if (pushsiner > 5)
172
    {
173
        if (abs(rotationalspeed) < 0.5)
174
        {
175
            rotationalfriction = 0.1;
176
            pushcon = 3;
177
            pushsiner = 0;
178
        }
179
    }
180
}
181
if (pushcon >= 3)
182
{
183
    pushsiner++;
184
    if (abs((finalang - (ang / 2)) % ang) < 3 || abs((finalang - (ang / 2)) % ang) > (ang - 3))
185
    {
186
        rotationalfriction = 0.05;
187
        rotationalspeed += 0.06;
188
    }
189
    else if (abs(rotationalspeed) < 0.2 && pushcon == 3)
190
    {
191
        pushcon = 4;
192
    }
193
    else if (pushcon == 4)
194
    {
195
        sliceflash++;
196
        if (sliceflash > 16)
197
        {
198
            daddy.tilecon = 2;
199
            daddy.quizchoice = whichslicechosen;
200
            debug_message(whichslicechosen);
201
            pushsiner = 0;
202
            instance_destroy();
203
        }
204
    }
205
}
206
draw_set_color(c_red);
207
draw_arrow(xx + r + 40 + pushamount, yy, xx + r + pushamount, yy, 10 + (pushamount / 4));
208
draw_text(xx + r + 40, yy + 40, whichslicechosen);
209
draw_text(xx + r + 40, yy + 60, minangle);
210
draw_text(xx + r + 40, yy + 80, maxangle);
211
draw_text(xx + r + 40, yy + 100, finalang);
212
draw_text(xx + r + 40, yy + 120, abs(finalang - (ang / 2)) % ang);
213
draw_text(xx + r + 40, yy + 140, abs((finalang % ang) - ang));