//proj1 ///GLOBALS/// float goldX, goldY; float letharX, letharY, letharDX=3, letharDY=2; float heroX, heroY; float step,len,frankStep; //????? float horizon; void setup() { size(600,500); horizon= height/4; letharX= width/2; letharY= height/2; } void draw() { // NEXT FRAME // scene(); grass(); lethar(); gold(); fill(0); text( letharX, 100,100 ); } void scene() { //scene: sky & horizon background(100,200,300); fill(0,200,60); rectMode(CORNER); rect(0,horizon, width,height); } void grass(){ //waving grass //Draw blades of grass across the screen// stroke(25,255,0); // line(x, height, x+til, height-40); for(float x=0;xwidth) letharDX *= -1; if (letharY>height) letharDY *= -1; letharX= letharX+letharDX; letharY= letharY+letharDY; // Draw lethar body( letharX, letharY ); head( letharX, letharY-40, 30 ); } //Draw Lethar's head// void head (float hh, float xh, float yh) { fill(0); rect( 30, 20, 55, 55); noStroke(); colorMode(HSB, 100); for (int i = 0; i < 100; i++) { for (int j = 0; j < 100; j++) { stroke(i, j, 100); point(i, j); } //for// } } //Draw Lethar's eye// void eye(float hh, float xh, float yh ) { fill(255); //-- ellipse(81, 70, 16, 32); ellipse(xh-hh/6, yh-hh/4, 10,10 ); //left eye ellipse(xh+hh/6, yh-hh/4, 10,10 ); //rigt eye } void body(float x, float y) { //Draw Lethar's body// rectMode(CENTER); //-- rect(30,20,55,55); rect( x, y, 55,55); noStroke(); colorMode(RGB, 100); for (int i = 0; i < 100; i++) { for (int j = 0; j < 100; j++) { stroke(i, j, 0); point(letharX+i, letharY+j); }//or// } } //Draw Letahr's legs// void twolegs() { stroke(0); line(90,150,80,160); line(110,150,120,160); } void leg(float hh, float x, float y){ //draw one leg line(x,y, x+step, y+len); line(x,y+len, x-frankStep, x+len); } void leg2(float hh, float x, float y) { //draw second leg line(x, y, x+step, y+len); line(x,y+len, x-frankStep, x+len); } //A function to display the gold// void gold() { //Draw the gold// if(goldY>horizon) { fill(random(200,250), random(100,200), random(150) ); ellipse(goldX, goldY, 40+random(20), 40+random(20) ); fill(random(150,250), random(150,200),random (100) ); ellipse(goldX, goldY, 30+random (15), 30+random(15) ); fill(255, 255, 0); ellipse(goldX, goldY, 20+random(20), 20+random(20) ); } }