Modify a text file: $/q2._rashid_.pde
$/q2._rashid_.pde
//Project 2 //Farah Rashid String title = "Project #2"; String owner = "Farah Rashid"; //Global declarations float horizon; House home; Hero franky; Dog rocky; Monster ted; Star sol; int ntrees =2; Tree [] trees = new Tree [ntrees]; boolean day = true; // more declarations int frames = 30; //set the size of the output window void setup() { size( 800,700); smooth(); frameRate(frames); horizon = height/2; //Instatiate the objects. franky = new Hero(); rocky = new Dog(); ted = new Monster(); home = new House(); sol = new Star(); for (int n=0; n
width) { dx = -dx; } // Bounce if (x < 0) { dx = -dx; } if (y > height) { dy = -dy; } if (y < horizon) { dy = -dy; } } class sun { float x= 0, y = 50, dx =1, dy =0; float w, h= 30; color c = color (#F8FFAD); } //METHODS// void show() { if (day) c = color(255,255,0); // Yellow sun. else c = color(200,180,180); // Pale moon. fill(c); ellipse( x,y, w,h ); } void move() { if (x > width) { sunset(); } // Night & Day. x = x + dx; y = y + dy; } void sunset() { day = ! day; // Switch nite/day x = 0; // Reset to left } }