Deltarune (Chapter 4) script viewer

← back to main script listing

gml_Object_obj_perspective_test_Step_0

(view raw script w/o annotations or w/e)
1
if (!init)
2
{
3
    depth = 100000 - (y * 10);
4
    init = true;
5
    var _xx = x - ((partcount / 2) * 10);
6
    for (i = 0; i < partcount; i++)
7
    {
8
        parts[i] = instance_create(x, y, obj_marker);
9
        parts[i].sprite_index = spr_perspective_orb;
10
        parts[i].image_speed = 0;
11
        xpos[i] = _xx;
12
        shadows[i] = instance_create(x, y, obj_marker);
13
        shadows[i].sprite_index = spr_perspective_orb;
14
        shadows[i].image_speed = 0;
15
        shadows[i].image_blend = c_black;
16
        shadows[i].depth = depth + 500;
17
        _xx += 10;
18
    }
19
}
20
var _sine = sin(siner / 60) * pi;
21
siner++;
22
for (i = 0; i < partcount; i++)
23
{
24
    var _vec3 = new Vector3(0, 0, 0);
25
    var _centerx = camerax() + (surface_get_width(application_surface) / 2);
26
    var _centery = 80;
27
    var _loopPos = _sine + ((i / 12) * 2 * pi);
28
    var _newX = xpos[i];
29
    var _height = (cos(_loopPos * 1) * 100) - 120;
30
    var _newY = other.y + _height;
31
    var _newZ = 300 + (sin(_loopPos * 1) * 60);
32
    var _playerdis = playerlook ? ((obj_mainchara.x + 15) - _newX) : 0;
33
    var _scale = 1;
34
    with (parts[i])
35
    {
36
        _vec3 = scr_perspective_scale_depth(_newX, _newY, _newZ, _centerx, _centery, 300, other.depth);
37
        x = _vec3.x;
38
        y = _vec3.y;
39
        depth = other.depth + ((_newZ - 300) * 10);
40
        _scale = _vec3.z;
41
        if (other.scalesnap > 0)
42
            _scale = round(_scale / other.scalesnap) * other.scalesnap;
43
        if (_playerdis != 0)
44
            image_xscale *= -sign(_playerdis);
45
        image_xscale = _scale;
46
        image_yscale = _scale;
47
        image_blend = merge_color(c_black, c_white, clamp01(_vec3.z / 1.5));
48
    }
49
    with (shadows[i])
50
    {
51
        x = _vec3.x;
52
        y = _centery + ((other.y - _centery) * _vec3.z);
53
        depth = other.depth + 10000;
54
        var _depthscale = clamp01((400 - (other.y - _newY)) / 400);
55
        image_xscale = _scale * _depthscale;
56
        if (_playerdis != 0)
57
            image_xscale *= -sign(_playerdis);
58
        if (other.shadowscale)
59
            _scale /= 2;
60
        image_yscale = _scale * _depthscale;
61
    }
62
}