Jekobus
YaBB Newbies
Offline
Posts: 4
Re: Help with Rotating Zoog
Reply #6 - Sep 28th , 2009, 10:34am
Thanks guys. I really appreciate all the help. Technically I've done everything required but I'd like to try to add a little more flare to my program. I was thinking of either changing Zoog's eye color, head color, body color, or any combination of the three based on either his position or some other factor. Basically I want the effect of a gradual change in color. I've been playing with the random() function but it produces some wild results that slow down my program. I'll post my "final" program below if anyone wants to take a look and give some input on how to have some of Zoog's parts change color. float xpos = 275; float ypos = 275; //X and Y positions for Zoog float theta = .0; //Angle of Zoog's rotation float s = 1; //Variable for the scale void setup() { size(550,550); frameRate(30); smooth(); } void draw() { background(255); rectMode(CENTER); ellipseMode(CENTER); //Draw "Left" button fill(0); rect(40,500,50,50); stroke(255); line(15,500,40,475); line(15,500,40,525); line(15,500,65,500); //Draw "Right" button rect(105,500,50,50); line(130,500,105,475); line(130,500,105,525); line(80,500,130,500); //Draw "Up" button rect(170,500,50,50); line(145,500,170,475); line(170,475,195,500); line(170,475,170,525); //Draw "Down" button rect(235,500,50,50); line(235,525,260,500); line(235,525,210,500); line(235,525,235,475); //Draw "Rotate CCW" button rect(300,500,50,50); ellipse(300,500,30,30); line(285,500,270,488); line(285,500,295,495); //Draw "Rotate CW" button rect(365,500,50,50); ellipse(365,500,30,30); line(340,500,325,512); line(340,512,350,500); line(350,500,365,510); //Draw "Shrink" button rect(430,500,50,50); rect(430,500,30,30); line(445,485,455,475); line(445,485,445,480); line(445,485,450,485); line(415,485,405,475); line(415,485,415,480); line(415,485,410,485); line(415,515,405,525); line(415,515,410,515); line(415,515,415,520); line(445,515,455,525); line(445,515,450,515); line(445,515,445,520); //Draw "Grow" button rect(495,500,50,50); rect(495,500,30,30); line(510,485,520,475); line(520,475,515,485); line(520,475,510,480); line(510,515,520,525); line(520,525,515,515); line(520,525,510,520); line(480,485,470,475); line(470,475,475,485); line(470,475,480,480); line(480,515,470,525); line(470,525,475,515); line(470,525,480,520); //Move origin to (xpos,ypos) translate(xpos,ypos); rotate(theta); scale(s); //Zoog's Body stroke(0); fill(0,0,255); rect(0,0,20,100); //Zoog's head fill(0,255,0); ellipse(0,0-30,60,60); //Zoog's eyes fill(255,0,0); ellipse(0-19,0-30,16,32); ellipse(0+19,0-30,16,32); //Zoog's legs line(0-10,0+50,0-20,0+60); line(0+10,0+50,0+20,0+60); //Move Zoog left if 'a' key is pressed or the "Left" button is clicked if(((keyPressed) && (key == 'a') || (key == 'A')) || (mousePressed && mouseX >= 15 && mouseX <= 65 && mouseY <= 525 && mouseY >= 475)) { xpos--; } //Move Zoog right if 's' key is pressed or the "Right" button is clicked if(((keyPressed) && (key == 's') || (key == 'S')) || (mousePressed && mouseX >= 80 && mouseX <= 130 && mouseY <= 525 && mouseY >= 475)) { xpos++; } //Move Zoog up if 'd' key is pressed or the "Up" button is clicked if(((keyPressed) && (key == 'd') || (key == 'D')) || (mousePressed && mouseX >= 145 && mouseX <= 195 && mouseY <= 525 && mouseY >= 475)) { ypos--; } //Move Zoog down if 'f' key is pressed or the "Down" button is clicked if(((keyPressed) && (key == 'f') || (key == 'F')) || mousePressed && mouseX >= 210 && mouseX <= 260 && mouseY <= 525 && mouseY >= 475) { ypos++; } //Rotate Zoog counter-clockwise if 'r' key is pressed or the "Rotate CCW" button is clicked if(((keyPressed) && (key == 'r') || (key == 'R')) || mousePressed && mouseX >= 275 && mouseX <= 325 && mouseY <= 525 && mouseY >= 475) { theta-=.02; } //Rotate Zoog clockwise if 'e' key is pressed or the "Rotate CW" button is clicked if(((keyPressed) && (key == 'e') || (key == 'E')) || mousePressed && mouseX >= 340 && mouseX <= 390 && mouseY <= 525 && mouseY >= 475) { theta += .02; } //Shrink Zoog if the 'q' key is pressed or the "Shrink" button is clicked if(((keyPressed) && (key == 'q') || (key == 'Q')) || mousePressed && mouseX >= 405 && mouseX <= 455 && mouseY <= 525 && mouseY >= 475) { s -= .01; } //Expand Zoog if the 'w' key is pressed or the "Grow" button is clicked if(((keyPressed) && (key == 'w') || (key == 'W')) || mousePressed && mouseX >= 470 && mouseX <=520 && mouseY <= 525 && mouseY >= 475) { s += .01; } }