Deltarune (Chapter 3) script viewer

← back to main script listing

gml_Object_obj_board_wheel_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
        maxslices = 16;
7
    if (slicetype == 1)
8
    {
9
        maxslices = 4 + irandom(12);
10
        for (i = 0; i < maxslices; i++)
11
        {
12
            sliceicon[i] = 3301;
13
            slicetext[i] = "no. " + string(i);
14
            slicetextcolor[i] = choose(16777215, 65535, 4235519);
15
        }
16
    }
17
    init = 1;
18
}
19
if (keyboard_check_pressed(vk_alt))
20
    init = 0;
21
draw_set_color(c_black);
22
ossafe_fill_rectangle(130, 60, 520, 320, false);
23
draw_set_color(c_blue);
24
xx = 340;
25
yy = 180;
26
r = 100;
27
draw_circle(xx, yy, r, false);
28
draw_set_color(c_black);
29
siner -= rotationalspeed;
30
ang = 360 / maxslices;
31
whichslicechosen = -1;
32
draw_set_font(fnt_main);
33
draw_set_halign(fa_right);
34
var minangle, maxangle;
35
for (i = 0; i < maxslices; i++)
36
{
37
    draw_set_color(c_white);
38
    finalang = (ang * i) + (ang / 2) + siner;
39
    var slicechosen = 0;
40
    minangle = (finalang - (ang / 2)) % 360;
41
    maxangle = (finalang + (ang / 2)) % 360;
42
    if (minangle > maxangle)
43
    {
44
        slicechosen = 1;
45
        whichslicechosen = i;
46
    }
47
    var selectedcolor = 16777215;
48
    if (slicechosen)
49
        selectedcolor = 65535;
50
    draw_line(xx, yy, xx + lengthdir_x(r, finalang + (ang / 2)), yy + lengthdir_y(r, finalang + (ang / 2)));
51
    x1 = xx;
52
    y1 = yy;
53
    x2 = xx + lengthdir_x(r, finalang - (ang / 2));
54
    y2 = yy + lengthdir_y(r, finalang - (ang / 2));
55
    x3 = xx + lengthdir_x(r, finalang + (ang / 2));
56
    y3 = yy + lengthdir_y(r, finalang + (ang / 2));
57
    var piecealpha = 1;
58
    if (pushcon == 1)
59
    {
60
        piecealpha = 1;
61
    }
62
    else if (pushcon >= 2)
63
    {
64
        piecealpha = 0.5;
65
        if (rotationalspeed < 8)
66
        {
67
            if (slicechosen)
68
                piecealpha = 1;
69
            else
70
                piecealpha = (1 / (abs(rotationalspeed * 4) + 1)) + 0.5;
71
        }
72
    }
73
    draw_sprite_pos(spr_board_wheel_slice_test, i, xx, yy, x3, y3, x2, y2, xx, yy, piecealpha);
74
    draw_set_color(slicetextcolor[i]);
75
    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);
76
    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);
77
    draw_text_transformed(xx + lengthdir_x(50, finalang + 8), yy + lengthdir_y(50, finalang + 8), slicetext[i], 1, 1, finalang);
78
}
79
draw_set_halign(fa_left);
80
rotationalspeed = clamp(rotationalspeed - rotationalfriction, 0, 999);
81
if (pushcon == 1)
82
{
83
    pushsiner++;
84
    pushamount = abs(sin(pushsiner / 8)) * 100;
85
    if (button1_p())
86
    {
87
        pushsiner = 0;
88
        pushcon = 2;
89
        idealrotationalspeed = rotationalspeed + 4 + (pushamount / 5) + (8 / maxslices);
90
        if (idealrotationalspeed > 30)
91
            idealrotationalspeed = 30;
92
        
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");
93
        rotationalfriction = 0.2 + (idealrotationalspeed / 100);
94
        pushamount = 0;
95
    }
96
}
97
if (pushcon == 2)
98
{
99
    pushsiner++;
100
    if (pushsiner > 5)
101
    {
102
        if (abs(rotationalspeed) < 0.5)
103
        {
104
            rotationalfriction = 0.1;
105
            pushcon = 3;
106
            pushsiner = 0;
107
        }
108
    }
109
}
110
if (pushcon == 3)
111
{
112
    pushsiner++;
113
    if (abs((finalang - (ang / 2)) % ang) < 3 || abs((finalang - (ang / 2)) % ang) > (ang - 3))
114
    {
115
        rotationalfriction = 0.05;
116
        rotationalspeed += 0.06;
117
    }
118
    else if (abs(rotationalspeed) < 0.2)
119
    {
120
        pushcon = 1;
121
        pushsiner = 0;
122
    }
123
}
124
draw_set_color(c_red);
125
draw_arrow(xx + r + 40 + pushamount, yy, xx + r + pushamount, yy, 10 + (pushamount / 4));
126
draw_text(xx + r + 40, yy + 40, whichslicechosen);
127
draw_text(xx + r + 40, yy + 60, minangle);
128
draw_text(xx + r + 40, yy + 80, maxangle);
129
draw_text(xx + r + 40, yy + 100, finalang);
130
draw_text(xx + r + 40, yy + 120, abs(finalang - (ang / 2)) % ang);
131
draw_text(xx + r + 40, yy + 140, abs((finalang % ang) - ang));