6 |
scr_verlet_updatepointsscr_verlet_updatepointsfunction scr_verlet_updatepoints(argument0, argument1, argument2) //gml_Script_scr_verlet_updatepoints
{
for (var i = 0; i < array_length(argument0); i++)
{
var p = array_get(argument0, i)
if (!(array_get(p, 4)))
{
var vx = ((array_get(p, 0)) - (array_get(p, 2))) * argument1
var vy = ((array_get(p, 1)) - (array_get(p, 3))) * argument1
array_set(p, 2, array_get(p, 0))
array_set(p, 3, array_get(p, 1))
array_set(p, 0, ((array_get(p, 0)) + vx))
array_set(p, 1, ((array_get(p, 1)) + vy))
array_set(p, 1, ((array_get(p, 1)) + argument2))
}
}
} (points, p_friction, p_gravity) |
9 |
scr_verlet_updatesticksscr_verlet_updatesticksfunction scr_verlet_updatesticks(argument0) //gml_Script_scr_verlet_updatesticks
{
for (var i = 0; i < array_length(argument0); i++)
{
var s = array_get(argument0, i)
var dx = (array_get(array_get(s, 1), 0)) - (array_get(array_get(s, 0), 0))
var dy = (array_get(array_get(s, 1), 1)) - (array_get(array_get(s, 0), 1))
var distance = sqrt(dx * dx + dy * dy)
var difference = (array_get(s, 2)) - distance
var percent = difference / distance / 2
var offsetX = dx * percent
var offsetY = dy * percent
if (!(array_get(array_get(s, 0), 4)))
{
array_set(array_get(s, 0), 0, ((array_get(array_get(s, 0), 0)) - offsetX))
array_set(array_get(s, 0), 1, ((array_get(array_get(s, 0), 1)) - offsetY))
}
if (!(array_get(array_get(s, 1), 4)))
{
array_set(array_get(s, 1), 0, ((array_get(array_get(s, 1), 0)) + offsetX))
array_set(array_get(s, 1), 1, ((array_get(array_get(s, 1), 1)) + offsetY))
}
}
} (sticks) |
10 |
scr_verlet_constrainpointsscr_verlet_constrainpointsfunction scr_verlet_constrainpoints(argument0, argument1, argument2) //gml_Script_scr_verlet_constrainpoints
{
for (var i = 0; i < array_length(argument0); i++)
{
var p = argument0[i]
if (!p[4])
{
var vx = (p[0] - p[2]) * argument1
var vy = (p[1] - p[3]) * argument1
if (p[0] > room_width)
{
p[0] = room_width
p[2] = p[0] + vx * argument2
}
else if (p[0] < 0)
{
p[0] = 0
p[2] = p[0] + vx * argument2
}
if (p[1] > room_height)
{
p[1] = room_height
p[3] = p[1] + vy * argument2
}
else if (p[1] < 0)
{
p[1] = 0
p[3] = p[1] + vy * argument2
}
}
}
} (points, p_friction, bounce) |