Deltarune (Chapter 4) script viewer

← back to main script listing

gml_Object_obj_gravity_ball_Step_0

(view raw script w/o annotations or w/e)
1
var _bottom = 340;
2
var _vol = obj_mike_controller.microphone_volume / 50;
3
if (action == 1)
4
{
5
    thrown = 0;
6
    x = obj_mike_controller.mx;
7
    y = obj_mike_controller.my + 24;
8
    if (!grab_snd)
9
    {
10
        grab_snd = 1;
11
        var _s = snd_play(snd_item);
12
        snd_volume(_s, 0.25, 0);
13
    }
14
}
15
else
16
{
17
    grab_snd = -1;
18
}
19
if (!place_meeting(x, y, obj_gravity_hoop))
20
    can_score = true;
21
if (action == 0)
22
{
23
    if (thrown == 0)
24
    {
25
        var _averagex2frame = (x + xprevious) / 2;
26
        var _averagey2frame = (y + yprevious) / 2;
27
        var _averagex4frame = (last_x[1] + last_x[2]) / 2;
28
        var _averagey4frame = (last_y[1] + last_y[2]) / 2;
29
        var _spd = max(2, point_distance(_averagex4frame, _averagey4frame, _averagex2frame, _averagey2frame) / 4);
30
        motion_set(point_direction(_averagex4frame, _averagey4frame, _averagex2frame, _averagey2frame), _spd);
31
        if (_spd > 2)
32
        {
33
            thrown = 1;
34
            var _s = snd_play_pitch(snd_meow, random_range(0.8, 1));
35
            snd_volume(_s, 0.25, 0);
36
        }
37
    }
38
    if (speed > 0 && gravity == 0)
39
    {
40
        var _a = 
scr_afterimage
scr_afterimage

function
scr_afterimage()
{ afterimage = instance_create(x, y, obj_afterimage); afterimage.sprite_index = sprite_index; afterimage.image_index = image_index; afterimage.image_blend = image_blend; afterimage.image_speed = 0; afterimage.depth = depth; afterimage.image_xscale = image_xscale; afterimage.image_yscale = image_yscale; afterimage.image_angle = image_angle; return afterimage; }
();
41
        _a.image_blend = merge_colour(c_gray, c_black, 0.75);
42
    }
43
    if (y > (cameray() + _bottom))
44
    {
45
        y = cameray() + _bottom;
46
        vspeed = -abs(vspeed * irandom_range(0.7, 0.9));
47
        hspeed *= 0.5;
48
        action = 2;
49
    }
50
}
51
if (action == 2)
52
{
53
    if (y >= (cameray() + _bottom))
54
    {
55
        y = cameray() + _bottom;
56
        vspeed = -abs(vspeed * irandom_range(0.8, 0.9));
57
        hspeed -= 0.2;
58
        if (x > 140)
59
        {
60
            if (hspeed > -2)
61
                hspeed = -2;
62
        }
63
        else
64
        {
65
            hspeed *= 0.5;
66
        }
67
    }
68
}
69
image_angle -= hspeed;
70
if (action == 5)
71
    action = 0;
72
var lbound = camerax() + 10;
73
var rbound = camerax() + 900;
74
var ubound = cameray() - 200;
75
var dbound = cameray() + _bottom;
76
if (x < lbound)
77
{
78
    hspeed = abs(hspeed);
79
    x = lbound + 1;
80
}
81
if (x > rbound)
82
{
83
    hspeed = -abs(hspeed);
84
    x = rbound - 1;
85
}
86
if (y < ubound)
87
{
88
    if (vspeed < 1)
89
        vspeed = 1;
90
    y = ubound + 1;
91
}
92
if (y > dbound)
93
{
94
    vspeed = -abs(vspeed);
95
    y = dbound - 1;
96
}
97
if (x < (lbound + 50) && y > (dbound - 50))
98
{
99
    x = lbound + 50;
100
    y = dbound - 50;
101
}
102
var _o = collision_circle(x, y, 10, obj_gravity_ball, 1, 1);
103
if (_o)
104
{
105
    if (_o.action != 1)
106
    {
107
        var _h = lengthdir_x(1, point_direction(_o.x, _o.y, x, y));
108
        var _v = lengthdir_y(1, point_direction(_o.x, _o.y, x, y));
109
        hspeed += (_h / 2);
110
        vspeed += (_v / 2);
111
        x += _h;
112
        y += _v;
113
    }
114
}
115
if (action != 1)
116
{
117
    if (_vol > 0.2)
118
    {
119
        gravity = _vol;
120
        friction = 0.1;
121
        hspeed -= lengthdir_x(_vol / 5, point_direction(obj_mike_controller.mx, obj_mike_controller.my + 24, obj_heart.x + 10, obj_heart.y + 10));
122
    }
123
    else
124
    {
125
        gravity = 0;
126
        friction = 0;
127
    }
128
}
129
if (fever_timer >= 0)
130
{
131
    var _a = instance_create(x, y, obj_animation);
132
    _a.sprite_index = spr_realisticexplosion;
133
    _a.image_speed = 1;
134
    _a.depth = depth + 1;
135
    with (_a)
136
        
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; }
("image_alpha", 1, 0, 16);
137
}
138
score_buffer--;
139
fever_timer--;