Deltarune (Chapter 4) script viewer

← back to main script listing

gml_Object_obj_homealone_kitchen_choco_Draw_0

(view raw script w/o annotations or w/e)
1
if (!is_thrown && t == 0)
2
    draw_self();
3
if (t == 1)
4
{
5
    bounce_xpos = obj_homealone_heart.x;
6
    bounce_ypos = obj_homealone_heart.y;
7
    bounce_bottle = 
scr_marker
scr_marker

function
scr_marker(arg0, arg1, arg2)
{ thismarker = instance_create(arg0, arg1, obj_marker); with (thismarker) { sprite_index = arg2; image_speed = 0; } return thismarker; }
(bounce_xpos, bounce_ypos, sprite_index);
8
    bounce_bottle.depth = depth - 100;
9
    base_alpha = 1;
10
}
11
if (t >= 1)
12
{
13
    var base_x = x + 10;
14
    var base_y = y - 10;
15
    xDist = base_x - bounce_xpos;
16
    yDist = base_y - bounce_ypos;
17
    smear_width = 1;
18
    smear_length = abs(sqrt(sqr(xDist) + sqr(yDist)));
19
    smear_angle = degtorad(point_direction(base_x, base_y, bounce_xpos, bounce_ypos));
20
    alph = 0.1 / smear_length;
21
    base_alpha -= 0.25;
22
    for (var i = 0; i < smear_length; i += smear_width)
23
        draw_sprite_ext(spr_noellehouse_kitchen_choco_afterimage, 0, base_x + (cos(smear_angle) * i) + (cos(smear_angle) * (smear_width / 2)), (base_y - (sin(smear_angle) * i)) + (sin(smear_angle) * (smear_width / 2)), 1, 1, 0, c_white, base_alpha * ((t / 8) + (i / smear_length)));
24
    if (t == 2)
25
    {
26
        bounce = true;
27
        snd_play(snd_hurt1);
28
        with (obj_homealone_kitchen)
29
            hit_heart = true;
30
    }
31
    if (base_alpha <= 0)
32
    {
33
        if (loop)
34
        {
35
            t = 0;
36
            g = 0;
37
        }
38
        else
39
        {
40
            throw_choco = false;
41
            t = 0;
42
            g = 0;
43
            is_thrown = true;
44
        }
45
    }
46
}
47
if (bounce)
48
{
49
    bounce_timer++;
50
    if (bounce_timer >= 2)
51
    {
52
        var velocity = bounce_timer * 4;
53
        with (bounce_bottle)
54
        {
55
            var ypos = clamp(obj_homealone_heart.y + 10, y, 212);
56
            if (obj_homealone_heart.image_angle < 0)
57
                hspeed = (y != ypos) ? -2 : 0;
58
            else
59
                hspeed = (y != ypos) ? 2 : 0;
60
            y = 
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); } }
(y, ypos, velocity);
61
        }
62
    }
63
}