2024-01-12 05:03:35 +01:00
|
|
|
function Node_MK_Brownian(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
|
|
|
name = "MK Brownian";
|
|
|
|
update_on_frame = true;
|
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(0, nodeValue_Surface("Background", self));
|
2024-01-12 05:03:35 +01:00
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(1, nodeValue_Surface("Sprite", self));
|
2024-01-12 05:03:35 +01:00
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(2, nodeValue_Int("Amount", self, 10));
|
2024-01-12 05:03:35 +01:00
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(3, nodeValue_Area("Area", self, DEF_AREA));
|
2024-01-12 05:03:35 +01:00
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(4, nodeValue_Rotation_Random("Direction", self, [ 0, 45, 135, 0, 0 ] ));
|
2024-01-12 05:03:35 +01:00
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(5, nodeValue_Range("Speed", self, [ 1, 1 ]));
|
2024-01-12 05:03:35 +01:00
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(6, nodeValue_Gradient("Color", self, new gradientObject(cola(c_white))));
|
2024-01-12 05:03:35 +01:00
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(7, nodeValue("Alpha", self, JUNCTION_CONNECT.input, VALUE_TYPE.curve, CURVE_DEF_11));
|
2024-01-12 05:03:35 +01:00
|
|
|
|
2024-08-18 09:13:41 +02:00
|
|
|
newInput(8, nodeValue_Int("Seed", self, seed_random(6)))
|
2024-08-08 06:57:51 +02:00
|
|
|
.setDisplay(VALUE_DISPLAY._default, { side_button : button(function() { randomize(); inputs[8].setValue(seed_random(6)); }).setIcon(THEME.icon_random, 0, COLORS._main_icon) });
|
2024-01-12 05:03:35 +01:00
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(9, nodeValue_Range("Angular speed", self, [ -45, 45 ]));
|
2024-01-12 05:03:35 +01:00
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(10, nodeValue_Range("Angular acceleration", self, [ -2, 2 ]));
|
2024-01-12 05:03:35 +01:00
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(11, nodeValue_Bool("Turn", self, false));
|
2024-01-12 05:03:35 +01:00
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(12, nodeValue_Dimension(self));
|
2024-01-12 10:38:58 +01:00
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(13, nodeValue_Range("Size", self, [ 1, 1 ], { linked : true }));
|
2024-01-14 12:20:23 +01:00
|
|
|
|
2024-08-08 06:57:51 +02:00
|
|
|
outputs[0] = nodeValue_Output("Output", self, VALUE_TYPE.surface, noone);
|
2024-01-12 05:03:35 +01:00
|
|
|
|
2024-01-12 10:38:58 +01:00
|
|
|
input_display_list = [ new Inspector_Sprite(s_MKFX), 8,
|
|
|
|
["Dimension", false], 0, 12,
|
2024-01-12 05:03:35 +01:00
|
|
|
["Particles", false], 1,
|
|
|
|
["Spawn", false], 3, 2,
|
|
|
|
["Movement", false], 5, 4, 9,
|
2024-01-22 03:55:19 +01:00
|
|
|
["Smooth turn", true, 11], 10,
|
2024-01-14 12:20:23 +01:00
|
|
|
["Render", false], 13, 6, 7,
|
2024-01-12 05:03:35 +01:00
|
|
|
];
|
|
|
|
|
2024-03-14 14:35:19 +01:00
|
|
|
static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
|
2024-07-02 12:18:32 +02:00
|
|
|
var _hov = false;
|
2024-08-08 06:57:51 +02:00
|
|
|
var hv = inputs[3].drawOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny); _hov |= hv;
|
2024-07-02 12:18:32 +02:00
|
|
|
|
|
|
|
return _hov;
|
2024-01-12 05:03:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static getPosition = function(ind, t, _area, _sped, _dire, _dirs, _turn, _dira) { #region
|
|
|
|
random_set_seed(ind);
|
|
|
|
|
|
|
|
var _px = irandom_range(_area[0] - _area[2], _area[0] + _area[2]);
|
|
|
|
var _py = irandom_range(_area[1] - _area[3], _area[1] + _area[3]);
|
|
|
|
|
|
|
|
var spd = random_range(_sped[0], _sped[1]);
|
|
|
|
var dir = angle_random_eval(_dire);
|
|
|
|
var dis = random_range(_dirs[0], _dirs[1]);
|
|
|
|
var dia = random_range(_dira[0], _dira[1]);
|
|
|
|
|
|
|
|
repeat(t) {
|
|
|
|
_px += lengthdir_x(spd, dir);
|
|
|
|
_py += lengthdir_y(spd, dir);
|
|
|
|
|
|
|
|
if(_turn) {
|
|
|
|
var a = random_range(_dira[0], _dira[1]);
|
|
|
|
dis += a;
|
|
|
|
} else {
|
|
|
|
dis = random_range(_dirs[0], _dirs[1]);
|
|
|
|
}
|
|
|
|
|
|
|
|
dir += dis;
|
|
|
|
}
|
|
|
|
|
|
|
|
return [ _px, _py ];
|
|
|
|
} #endregion
|
|
|
|
|
|
|
|
static update = function() { #region
|
|
|
|
var _surf = getInputData(0);
|
|
|
|
var _sprt = getInputData(1);
|
|
|
|
var _amou = getInputData(2);
|
|
|
|
var _area = getInputData(3);
|
|
|
|
var _dire = getInputData(4);
|
|
|
|
var _sped = getInputData(5);
|
|
|
|
var _colr = getInputData(6);
|
|
|
|
var _alph = getInputData(7);
|
|
|
|
var _seed = getInputData(8);
|
|
|
|
var _dirs = getInputData(9);
|
|
|
|
var _dira = getInputData(10);
|
|
|
|
var _turn = getInputData(11);
|
2024-01-12 10:38:58 +01:00
|
|
|
var _dim = getInputData(12);
|
2024-01-14 12:20:23 +01:00
|
|
|
var _size = getInputData(13);
|
2024-01-12 05:03:35 +01:00
|
|
|
|
|
|
|
var _sed = _seed;
|
|
|
|
|
2024-01-12 10:38:58 +01:00
|
|
|
if(is_surface(_surf)) _dim = surface_get_dimension(_surf)
|
2024-01-12 05:03:35 +01:00
|
|
|
|
2024-08-08 06:57:51 +02:00
|
|
|
var _outSurf = outputs[0].getValue();
|
2024-01-12 10:38:58 +01:00
|
|
|
_outSurf = surface_verify(_outSurf, _dim[0], _dim[1]);
|
2024-08-08 06:57:51 +02:00
|
|
|
outputs[0].setValue(_outSurf);
|
2024-01-12 05:03:35 +01:00
|
|
|
|
|
|
|
surface_set_target(_outSurf);
|
|
|
|
DRAW_CLEAR
|
2024-01-12 10:38:58 +01:00
|
|
|
|
2024-01-12 05:03:35 +01:00
|
|
|
BLEND_OVERRIDE
|
|
|
|
draw_surface_safe(_surf);
|
|
|
|
BLEND_ALPHA_MULP
|
|
|
|
|
2024-01-14 12:20:23 +01:00
|
|
|
shader_set(sh_draw_divide);
|
2024-01-12 05:03:35 +01:00
|
|
|
for( var i = 0; i < _amou; i++ ) {
|
|
|
|
_sed += 100;
|
|
|
|
|
|
|
|
var _lifs = irandom_seed(TOTAL_FRAMES, _sed);
|
|
|
|
var _lif = (_lifs + CURRENT_FRAME) % TOTAL_FRAMES;
|
|
|
|
|
|
|
|
var _pos = getPosition(_sed, _lif, _area, _sped, _dire, _dirs, _turn, _dira);
|
|
|
|
var _cc = _colr.eval(_lifs / TOTAL_FRAMES);
|
|
|
|
var _aa = eval_curve_x(_alph, _lif / TOTAL_FRAMES);
|
|
|
|
|
2024-01-14 12:20:23 +01:00
|
|
|
random_set_seed(_sed + 50);
|
|
|
|
var _ss = random_range(_size[0], _size[1]);
|
|
|
|
|
2024-01-12 05:03:35 +01:00
|
|
|
if(_sprt == noone) {
|
|
|
|
draw_set_color(_cc);
|
|
|
|
draw_set_alpha(_aa);
|
2024-01-14 12:20:23 +01:00
|
|
|
|
2024-01-22 03:55:19 +01:00
|
|
|
dynaSurf_circle_fill(_pos[0], _pos[1], round(_ss));
|
2024-01-14 12:20:23 +01:00
|
|
|
|
2024-01-12 05:03:35 +01:00
|
|
|
draw_set_alpha(1);
|
|
|
|
} else {
|
|
|
|
var _p = _sprt;
|
2024-03-31 05:36:11 +02:00
|
|
|
if(is_array(_p)) _p = array_safe_get_fast(_p, irandom(array_length(_p) - 1));
|
2024-01-12 05:03:35 +01:00
|
|
|
|
2024-01-14 12:20:23 +01:00
|
|
|
draw_surface_ext_safe(_p, _pos[0], _pos[1], _ss, _ss, 0, _cc, _aa);
|
2024-01-12 05:03:35 +01:00
|
|
|
}
|
|
|
|
}
|
2024-01-14 12:20:23 +01:00
|
|
|
shader_reset();
|
|
|
|
|
2024-01-12 05:03:35 +01:00
|
|
|
BLEND_NORMAL
|
|
|
|
surface_reset_target();
|
|
|
|
} #endregion
|
|
|
|
}
|