Deltarune (Chapter 3) script viewer

← back to main script listing

gml_Object_obj_ch3_green_room_racing_car_Step_0

(view raw script w/o annotations or w/e)
1
if (!can_control)
2
    exit;
3
press_l = 0;
4
press_r = 0;
5
press_d = 0;
6
press_u = 0;
7
press_1 = 0;
8
press_2 = 0;
9
if (left_h())
10
    press_l = 1;
11
if (right_h())
12
    press_r = 1;
13
if (up_h())
14
    press_u = 1;
15
if (down_h())
16
    press_d = 1;
17
if (button1_p())
18
    press_1 = 1;
19
if (button2_p())
20
    press_2 = 1;
21
px = 0;
22
py = 0;
23
if (press_r == 1)
24
    px = wspeed;
25
if (press_l == 1)
26
    px = -wspeed;
27
if (press_d == 1)
28
    py = wspeed;
29
if (press_u == 1)
30
    py = -wspeed;
31
var _xx = px;
32
var _yy = py;
33
var is_bumped = false;
34
if (place_meeting(x + _xx, y, obj_ch3_green_room_racing_solid))
35
{
36
    is_bumped = true;
37
    bkx = 0;
38
    if (px > 0)
39
    {
40
        for (i = px; i >= 0; i -= 1)
41
        {
42
            if (!place_meeting(x + i, y, obj_ch3_green_room_racing_solid))
43
            {
44
                px = i;
45
                bkx = 1;
46
                break;
47
            }
48
        }
49
    }
50
    if (px < 0)
51
    {
52
        for (i = px; i <= 0; i += 1)
53
        {
54
            if (!place_meeting(x + i, y, obj_ch3_green_room_racing_solid))
55
            {
56
                px = i;
57
                bkx = 1;
58
                break;
59
            }
60
        }
61
    }
62
    if (bkx == 0)
63
        px = 0;
64
}
65
if (place_meeting(x, y + _yy, obj_ch3_green_room_racing_solid))
66
{
67
    is_bumped = true;
68
    bky = 0;
69
    if (py > 0)
70
    {
71
        for (i = py; i >= 0; i -= 1)
72
        {
73
            if (!place_meeting(x, y + i, obj_ch3_green_room_racing_solid))
74
            {
75
                py = i;
76
                bky = 1;
77
                break;
78
            }
79
        }
80
    }
81
    if (py < 0)
82
    {
83
        for (i = py; i <= 0; i += 1)
84
        {
85
            if (!place_meeting(x, y + i, obj_ch3_green_room_racing_solid))
86
            {
87
                py = i;
88
                bky = 1;
89
                break;
90
            }
91
        }
92
    }
93
    if (bky == 0)
94
        py = 0;
95
}
96
var won = false;
97
if (place_meeting(x + _xx, y, obj_ch3_green_room_racing_goal))
98
{
99
    is_bumped = false;
100
    won = true;
101
    bkx = 0;
102
    if (px > 0)
103
    {
104
        for (i = px; i >= 0; i -= 1)
105
        {
106
            if (!place_meeting(x + i, y, obj_ch3_green_room_racing_goal))
107
            {
108
                px = i;
109
                bkx = 1;
110
                break;
111
            }
112
        }
113
    }
114
    if (px < 0)
115
    {
116
        for (i = px; i <= 0; i += 1)
117
        {
118
            if (!place_meeting(x + i, y, obj_ch3_green_room_racing_goal))
119
            {
120
                px = i;
121
                bkx = 1;
122
                break;
123
            }
124
        }
125
    }
126
    if (bkx == 0)
127
        px = 0;
128
}
129
if (!is_bumped)
130
{
131
    if (sfx_buffer_timer > 0)
132
        sfx_buffer_timer--;
133
}
134
_xx = px;
135
_yy = py;
136
x += _xx;
137
y += _yy;
138
player_moved = px != 0 || py != 0;
139
if (sfx_honk_buffer_timer <= 0)
140
{
141
    if (player_moved)
142
    {
143
        sfx_honk_buffer_timer = sfx_honk_buffer;
144
        snd_play_x(snd_carhonk, 0.25, 1.8);
145
    }
146
}
147
else
148
{
149
    sfx_honk_buffer_timer--;
150
}
151
if (won)
152
    win();
153
if (is_bumped && sfx_buffer_timer <= 0)
154
    bump_car();