Hi, everyone. I'm currently trying to study array and classes. But I just can't seem to quite grasp it. Right now my goal is to make a background like the warp effect seen in the YouTube link below
http://www.youtube.com/watch?feature=player_detailpage&v=eaC6adlQg5Q#t=163s
It's from a game called Dariusburst for iOS.
This is what I have so far and I'm working in increments. Right now I'm focusing on a single set of lines to loop back to origin as it reach the screen's edge.
- int l=15; //line length
- int x=0;
- void setup() {
- size(500, 500);
- smooth();
- }
- void draw() {
- background(255);
- x++;
- if (x>500){
- x=0;
- }
- for (int j=0; j<500; j+=20) {
- line((j+x)-l,50,j+x,50);
- }
- }
So far, I have a for array of the lines but the ENTIRE set of line go all the way past the edge of the screen before going back to the origin (int x). What I want is each line in the set to loop back rather than waiting for the last line in the set to pass through to the right.
As far as I can figure it out, I need to make an array of variables. Unfortunately, this is exactly where I'm tripping up. I can't seem to understand exactly how this work. I can make a basic for array but not with variable on what I know right now.
Once I have figured this out with your help, I plan to use another for array with rotate to spread this single line all over the screen to recreate the similar effect as in the youtube clip.
Thank you in advance for any advice and information.
1