/* Notes: Need to get down NPR-pencil function/technique can distort lines using sine function and perlin noise (more smooth/natural) Objects composed of -lines -shading Optimization of Pencil Drawing -once rendered, need to find way to stop constantly re-computing values -whats the slowest part? Pencil function needs to -take in a series of points to pass through -perhaps also have primitives which can be drawn (circle...) -interpolate line through points -perturb endpoints -sine/perlin distort points along line -make texture of pencil Character class -platformer... -position/velocity... Effects -draw as walk -wigglevision, continually redraw lines */ /* import ddf.minim.*; Minim minim; AudioPlayer player; */ //test drawing forest int screen_x = 1000; int bg_size = 2048; //number of pixels in background image in x direction //in order to continuously render int screen_y = 500; //use these two to normalize for resolution //and screen size PImage paper; ArrayList vert; character guy; ArrayList trees; ArrayList ground_list; float xpos = 0; //positon of left edge of screen float motion_x = 0; float fade = 300; float last_render_x = 300; int temp = 0; void setup() { size(1000,500); smooth(); //start music /* minim = new Minim(this); player = minim.loadFile("talk.mp3"); player.play(); */ frameRate(30); trees = new ArrayList(); ground_list = new ArrayList(); //paper = loadImage("crumpled_paper.jpg"); //paper = loadImage("plain-white-paper.jpg"); trees.add(new tree(100,200,200)); trees.add(new tree(400, 100, 300)); trees.add(new tree(500,150,250)); trees.add(new tree(800,0,400)); ground_list.add(new ground(0,400)); ground_list.add(new ground(300,400)); ground_list.add(new ground(600,400)); ground_list.add(new ground(900,400)); guy = new character(); } void draw() { //keep adding more stuff if (xpos > last_render_x) { last_render_x += 300; ground_list.add(new ground(last_render_x + 600,400)); int num_trees = round(random(0,2)); for (int i = 0; i < num_trees; ++i) { float tall = random(50,450); trees.add(new tree(random(last_render_x + 600, last_render_x + 900),height-100-tall,tall)); } } //background(255); xpos += motion_x; if (motion_x != 0) { guy.move(); } pushMatrix(); translate(-xpos,0); //determine where to put background //image(paper,((int)xpos/bg_size)*bg_size,0); // image(paper,((int)xpos/bg_size - 1)*bg_size,0); //image(paper,((int)xpos/bg_size + 1) * bg_size,0); background(255); fill(0,fade); fade -= 1; noStroke(); rect(xpos,0,width,height); stroke(0); guy.update(); //show ground if (fade < 100) { //show trees tree temp; stroke(00,70); for (int i = 0; i < trees.size(); ++i) { temp = (tree)trees.get(i); temp.render(xpos); } ground temp1; stroke(0); for (int i = 0; i < ground_list.size(); ++i) { temp1 = (ground)ground_list.get(i); temp1.render(xpos); } } popMatrix(); } void keyPressed() { if (keyCode == RIGHT) { motion_x = 5; } else if (keyCode == LEFT) { motion_x = -5; } guy.move(); } void keyReleased() { motion_x = 0; guy.stop(); } void stop() {/* player.close(); minim.stop(); super.stop(); */ }