Moving in the maze

I just watched Dan's maze tutorial on coding train and I'd like to figure out how to get the highlighter moving with the arrow keys. I'm getting kinda stuck because I'm not sure how I can add in the parameters after it creates the maze pattern. Any help would be great!

http://alpha.editor.p5js.org/seb646/sketches/SkbygZYbW

Tagged:

Answers

  • edited June 2017

    I have this :

            if(keyIsPressed){
                    if(keyCode == UP_ARROW){
                         y = y-w;
                         noStroke();
                         fill(random(0,255),random(0,255),random(0,255));
                         rect(x, y, w, w);
                    }
                        if(keyCode == DOWN_ARROW){
                        y = y+w;
                      noStroke();
                        fill(random(0,255),random(0,255),random(0,255));
                        rect(x, y, w, w);
                    }
                        if(keyCode == LEFT_ARROW){
                        x = x-w
                        noStroke();
                        fill(random(0,255),random(0,255),random(0,255));
                        rect(x, y, w, w);
                    }
                        if(keyCode == RIGHT_ARROW){
                         x = x+w;
                         noStroke();
                         fill(random(0,255),random(0,255),random(0,255));
                       rect(x, y, w, w);
                    }
                }
    

    It's all what I can do

Sign In or Register to comment.