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-01-12 10:38:58 +01:00
|
|
|
inputs[| 0] = nodeValue("Background", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone);
|
2024-01-12 05:03:35 +01:00
|
|
|
|
|
|
|
inputs[| 1] = nodeValue("Sprite", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone);
|
|
|
|
|
|
|
|
inputs[| 2] = nodeValue("Amount", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 10);
|
|
|
|
|
2024-03-24 10:02:54 +01:00
|
|
|
inputs[| 3] = nodeValue("Area", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, DEF_AREA)
|
2024-01-12 05:03:35 +01:00
|
|
|
.setDisplay(VALUE_DISPLAY.area);
|
|
|
|
|
|
|
|
inputs[| 4] = nodeValue("Direction", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 45, 135, 0, 0 ] )
|
|
|
|
.setDisplay(VALUE_DISPLAY.rotation_random);
|
|
|
|
|
|
|
|
inputs[| 5] = nodeValue("Speed", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 1, 1 ])
|
|
|
|
.setDisplay(VALUE_DISPLAY.range);
|
|
|
|
|
|
|
|
inputs[| 6] = nodeValue("Color", self, JUNCTION_CONNECT.input, VALUE_TYPE.gradient, new gradientObject(c_white));
|
|
|
|
|
|
|
|
inputs[| 7] = nodeValue("Alpha", self, JUNCTION_CONNECT.input, VALUE_TYPE.curve, CURVE_DEF_11);
|
|
|
|
|
2024-05-17 09:01:36 +02:00
|
|
|
inputs[| 8] = nodeValue("Seed", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, seed_random(6))
|
2024-06-08 06:31:21 +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
|
|
|
|
|
|
|
inputs[| 9] = nodeValue("Angular speed", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ -45, 45 ])
|
|
|
|
.setDisplay(VALUE_DISPLAY.range);
|
|
|
|
|
|
|
|
inputs[| 10] = nodeValue("Angular acceleration", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ -2, 2 ])
|
|
|
|
.setDisplay(VALUE_DISPLAY.range);
|
|
|
|
|
|
|
|
inputs[| 11] = nodeValue("Turn", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false);
|
|
|
|
|
2024-01-12 10:38:58 +01:00
|
|
|
inputs[| 12] = nodeValue("Dimension", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, DEF_SURF)
|
|
|
|
.setDisplay(VALUE_DISPLAY.vector);
|
|
|
|
|
2024-01-14 12:20:23 +01:00
|
|
|
inputs[| 13] = nodeValue("Size", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 1, 1 ])
|
|
|
|
.setDisplay(VALUE_DISPLAY.range, { linked : true });
|
|
|
|
|
2024-01-12 05:03:35 +01:00
|
|
|
outputs[| 0] = nodeValue("Output", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
|
|
|
|
|
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;
|
|
|
|
var hv = inputs[| 3].drawOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny); _hov |= hv;
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
var _outSurf = outputs[| 0].getValue();
|
2024-01-12 10:38:58 +01:00
|
|
|
_outSurf = surface_verify(_outSurf, _dim[0], _dim[1]);
|
2024-01-12 05:03:35 +01:00
|
|
|
outputs[| 0].setValue(_outSurf);
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|