We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I am trying to move a grid of shapes off screen as individual objects, but i'm having trouble with needing to track the x,y for a wrap around once the object exits the frame, and the x,y needed in a for loop to create a grid. I have more detailed questions in the code. I know it must be something simple. I've tried making new variables like an xSpace and a ySpace for use in a for loop that would add onto each xy location, but the way I have it setup isn't quite working.
Here is what I'm working on, I'd appreciate any help: https://dropbox.com/s/au3btfalgo3zcw9/AnalogDriftArray.zip
Answers
"Animating a For Loop"
Cannot work. draw() show stuff on screen only after the call ends. See What are setup() and draw()? and other articles of the Technical FAQ.
Screen is only updated at end of draw()
What you can do: save images in for-loop (in an arraylist) and replay images later
;-)
or:
try to get rid of the inner for-loops
to achieve a simple grid, you just want a double for loop without any wrap
see line 26 to 29 mainly :
to see the cells / bricks / stones as individuals I gave them each a random color.
also when you display() it in the class, use the values in the class. Don't use parameters
same goes for function move() in the class where you gave ratex and ratey as parameters instead of using driftXspeed and driftYspeed
;-)
Thanks everyone! Chrisir your simple grid example is closer to what I am trying to do, which is to rebuild aspects of the EAB videolab Mainly it's pattern generation and real time keying. This is why I need rateX and rateY parameters for exponential performative change in drift speed.
I worked further with the code before everyones help and used syphon to send frames to MAX for chromakeying 5 videos into separate layers of 4 patterns generated in processing. Now with the more grid like an less buggy thanks to your help I'm on to the next problem. Thanks again everyone.
you're welcome!
@ Philho, you wrote, draw() show stuff on screen only after the call ends (draw() ends).
I understand that.
When we would use pure Java in eclipse, would that issue remain or could we there say freely "update my screen now" at any time we wanted?
I mean is that a general java restriction of some sort or does it come in because of processing? I remeber when using Pascal or so, the screen was updated throughout....
Thanks!
(It's a sidenote but still)
;-)
For Java development using other frameworks, go to http://www.java-gaming.org
I understand that the grid is set in the setup, but what if I want to change the spacing dynamically? I've added controls for changing the size of the shapes with CONTROL shrinking and ALT enlarging. I would like to grow grid spacing with the growth of shapes. If I could do it in draw I would make variables for xGridSpace & yGridSpace and have a calculation that took ShapeW and ShapeH into account.
Something like this about works, it's really glitchy tho. Any thoughts?
you can just redefine the whole thing by calling the lines from setup() (put them into an extra function)