Okay, I've struggled with this for 24 hours, I need some help.
I've done this in Max w/standard objects, it works fine. When I move it to JS, things get wonky.
I've already finished a patch for the Launchpad that works as a generative sequencer (like Nodal or Elysium). I'm trying to recode it for efficiency, as I barrelled through the initial coding just as a proof of concept, and at l/4 or 1/8 note resolutions it works fine, but at higher rez's its not stable timing wise. So this is the main engine for interpretation, as I've rewritten it.
The code I'm posting is supposed to deal with eight different jit.matrices, each one being a different direction. Each time it receives a bang, it should advance the square in whatever ever direction the plane its inserted on is moving.
The problem I'm having is that jit.repos is doing the repositioning, but its not removing the old location. There should be a progressing square on the matrixctl, but instead its additive. Please, someone tell me what I'm doing wrong here, or confirm that there is something amiss with the JS implementation of the jit.repos object, because my forehead is bleeding from all this head-beating-against-wall activity I've been doing.
I should mention this patch is for M4L, but I've tried the same JS in Max and it behaves the same. I've also posted over at Ableton.
I expect someone is going to tell me I should be using particles for this, and there is a really nice tutorial in the docs....well, I know, but I have my own reasons for doing things this way. As far as I can tell, this should work.
I'm not providing the patch, just the js. Hook up a 16x16 matrixctl to outlet(0) to see what is going on, and input three coordinates (direction 1-8, x, y) to get the "plinko" started. Banging in the input should advance time (or hook up a metro to it). Lemme know if anyone has the slightest clue what I'm talking about. Thanks in advance.
x_adj=[1, 0, -1, 1, -1, 1, 0, -1];
y_adj=[1, 1, 1, 0, 0, -1, -1, -1];
function list(d,x,y) //drops the plinko
post("x", x, "y", y, "val", potential.getcell(x,y));
function init() //init parameters
dump=program.getcell(xx, yy); //if so, look up program
post("dump", dump,"n"); //and post results
disp_potential(xx,yy); //display in matrixctl
function clear_display() //clear display each turn
function disp_potential(x,y) //send values to display
outlet(0, x, y, 1);